mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Migrate 'invalid callee' diagnostic
This commit is contained in:
parent
b40f11c8a9
commit
cb9f666fdf
@ -56,8 +56,10 @@ hir_typeck_functional_record_update_on_non_struct =
|
||||
|
||||
hir_typeck_help_set_edition_cargo = set `edition = "{$edition}"` in `Cargo.toml`
|
||||
hir_typeck_help_set_edition_standalone = pass `--edition {$edition}` to `rustc`
|
||||
hir_typeck_lang_start_expected_sig_note = the `start` lang item should have the signature `fn(fn() -> T, isize, *const *const u8, u8) -> isize`
|
||||
|
||||
hir_typeck_invalid_callee = expected function, found {$ty}
|
||||
|
||||
hir_typeck_lang_start_expected_sig_note = the `start` lang item should have the signature `fn(fn() -> T, isize, *const *const u8, u8) -> isize`
|
||||
hir_typeck_lang_start_incorrect_number_params = incorrect number of parameters for the `start` lang item
|
||||
hir_typeck_lang_start_incorrect_number_params_note_expected_count = the `start` lang item should have four parameters, but found {$found_param_count}
|
||||
|
||||
|
@ -3,7 +3,6 @@ use super::method::MethodCallee;
|
||||
use super::{Expectation, FnCtxt, TupleArgumentsFlag};
|
||||
|
||||
use crate::errors;
|
||||
use crate::type_error_struct;
|
||||
use rustc_ast::util::parser::PREC_POSTFIX;
|
||||
use rustc_errors::{Applicability, Diagnostic, ErrorGuaranteed, StashKey};
|
||||
use rustc_hir as hir;
|
||||
@ -603,17 +602,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
}
|
||||
|
||||
let callee_ty = self.resolve_vars_if_possible(callee_ty);
|
||||
let mut err = type_error_struct!(
|
||||
self.tcx.sess,
|
||||
callee_expr.span,
|
||||
callee_ty,
|
||||
E0618,
|
||||
"expected function, found {}",
|
||||
match &unit_variant {
|
||||
let mut err = self.tcx.sess.create_err(errors::InvalidCallee {
|
||||
span: callee_expr.span,
|
||||
ty: match &unit_variant {
|
||||
Some((_, kind, path)) => format!("{kind} `{path}`"),
|
||||
None => format!("`{callee_ty}`"),
|
||||
}
|
||||
);
|
||||
});
|
||||
if callee_ty.references_error() {
|
||||
err.downgrade_to_delayed_bug();
|
||||
}
|
||||
|
||||
self.identify_bad_closure_def_and_call(
|
||||
&mut err,
|
||||
|
@ -282,6 +282,14 @@ impl HelpUseLatestEdition {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(hir_typeck_invalid_callee, code = "E0618")]
|
||||
pub struct InvalidCallee {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub ty: String,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
pub enum OptionResultRefMismatch {
|
||||
#[suggestion(
|
||||
|
Loading…
Reference in New Issue
Block a user