diff options
| author | clubby789 <jamie@hill-daniel.co.uk> | 2023-09-15 01:18:38 +0000 |
|---|---|---|
| committer | clubby789 <jamie@hill-daniel.co.uk> | 2023-09-15 14:24:58 +0000 |
| commit | 8696ee8b0991888c8adc256eb85e5fc1da02b648 (patch) | |
| tree | 0f77e1c69afdc9146e300bc6a6b86a100035fa0d | |
| parent | cb9f666fdf50bf80b71a54ccfcb7dfe4ad4c84d4 (diff) | |
| download | rust-8696ee8b0991888c8adc256eb85e5fc1da02b648.tar.gz rust-8696ee8b0991888c8adc256eb85e5fc1da02b648.zip | |
Migrate 'missing fn lang items' diagnostic
| -rw-r--r-- | compiler/rustc_hir_typeck/messages.ftl | 3 | ||||
| -rw-r--r-- | compiler/rustc_hir_typeck/src/callee.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_hir_typeck/src/errors.rs | 8 |
3 files changed, 13 insertions, 10 deletions
diff --git a/compiler/rustc_hir_typeck/messages.ftl b/compiler/rustc_hir_typeck/messages.ftl index 33be8b09adf..f7506879b5d 100644 --- a/compiler/rustc_hir_typeck/messages.ftl +++ b/compiler/rustc_hir_typeck/messages.ftl @@ -72,6 +72,9 @@ hir_typeck_lang_start_incorrect_ret_ty = the return type of the `start` lang ite hir_typeck_method_call_on_unknown_raw_pointee = cannot call a method on a raw pointer with an unknown pointee type +hir_typeck_missing_fn_lang_items = failed to find an overloaded call trait for closure call + .help = make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods + hir_typeck_missing_parentheses_in_range = can't call method `{$method_name}` on type `{$ty_str}` hir_typeck_no_associated_item = no {$item_kind} named `{$item_name}` found for {$ty_prefix} `{$ty_str}`{$trait_missing_method -> diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 93e6f4e51d4..b39919ece71 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -607,7 +607,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty: match &unit_variant { Some((_, kind, path)) => format!("{kind} `{path}`"), None => format!("`{callee_ty}`"), - } + }, }); if callee_ty.references_error() { err.downgrade_to_delayed_bug(); @@ -882,15 +882,7 @@ impl<'a, 'tcx> DeferredCallResolution<'tcx> { None => { // This can happen if `#![no_core]` is used and the `fn/fn_mut/fn_once` // lang items are not defined (issue #86238). - let mut err = fcx.inh.tcx.sess.struct_span_err( - self.call_expr.span, - "failed to find an overloaded call trait for closure call", - ); - err.help( - "make sure the `fn`/`fn_mut`/`fn_once` lang items are defined \ - and have correctly defined `call`/`call_mut`/`call_once` methods", - ); - err.emit(); + fcx.inh.tcx.sess.emit_err(errors::MissingFnLangItems { span: self.call_expr.span }); } } } diff --git a/compiler/rustc_hir_typeck/src/errors.rs b/compiler/rustc_hir_typeck/src/errors.rs index 28659b74e84..40c0676c8d2 100644 --- a/compiler/rustc_hir_typeck/src/errors.rs +++ b/compiler/rustc_hir_typeck/src/errors.rs @@ -84,6 +84,14 @@ pub struct MethodCallOnUnknownRawPointee { } #[derive(Diagnostic)] +#[diag(hir_typeck_missing_fn_lang_items)] +#[help] +pub struct MissingFnLangItems { + #[primary_span] + pub span: Span, +} + +#[derive(Diagnostic)] #[diag(hir_typeck_functional_record_update_on_non_struct, code = "E0436")] pub struct FunctionalRecordUpdateOnNonStruct { #[primary_span] |
