Skip to content

Commit ae9bc33

Browse files
committed
Migrate 'missing fn lang items' diagnostic
1 parent b2123f8 commit ae9bc33

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

compiler/rustc_hir_typeck/messages.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ hir_typeck_lang_start_incorrect_ret_ty = the return type of the `start` lang ite
7272
hir_typeck_method_call_on_unknown_raw_pointee =
7373
cannot call a method on a raw pointer with an unknown pointee type
7474
75+
hir_typeck_missing_fn_lang_items = failed to find an overloaded call trait for closure call
76+
.help = make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
77+
7578
hir_typeck_missing_parentheses_in_range = can't call method `{$method_name}` on type `{$ty_str}`
7679
7780
hir_typeck_no_associated_item = no {$item_kind} named `{$item_name}` found for {$ty_prefix} `{$ty_str}`{$trait_missing_method ->

compiler/rustc_hir_typeck/src/callee.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
607607
ty: match &unit_variant {
608608
Some((_, kind, path)) => format!("{kind} `{path}`"),
609609
None => format!("`{callee_ty}`"),
610-
}
610+
},
611611
});
612612
if callee_ty.references_error() {
613613
err.downgrade_to_delayed_bug();
@@ -882,15 +882,7 @@ impl<'a, 'tcx> DeferredCallResolution<'tcx> {
882882
None => {
883883
// This can happen if `#![no_core]` is used and the `fn/fn_mut/fn_once`
884884
// lang items are not defined (issue #86238).
885-
let mut err = fcx.inh.tcx.sess.struct_span_err(
886-
self.call_expr.span,
887-
"failed to find an overloaded call trait for closure call",
888-
);
889-
err.help(
890-
"make sure the `fn`/`fn_mut`/`fn_once` lang items are defined \
891-
and have correctly defined `call`/`call_mut`/`call_once` methods",
892-
);
893-
err.emit();
885+
fcx.inh.tcx.sess.emit_err(errors::MissingFnLangItems { span: self.call_expr.span });
894886
}
895887
}
896888
}

compiler/rustc_hir_typeck/src/errors.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ pub struct MethodCallOnUnknownRawPointee {
8383
pub span: Span,
8484
}
8585

86+
#[derive(Diagnostic)]
87+
#[diag(hir_typeck_missing_fn_lang_items)]
88+
#[help]
89+
pub struct MissingFnLangItems {
90+
#[primary_span]
91+
pub span: Span,
92+
}
93+
8694
#[derive(Diagnostic)]
8795
#[diag(hir_typeck_functional_record_update_on_non_struct, code = "E0436")]
8896
pub struct FunctionalRecordUpdateOnNonStruct {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy