1 use super::method::probe::{IsSuggestion, Mode, ProbeScope};
2 use super::method::MethodCallee;
3 use super::{Expectation, FnCtxt, TupleArgumentsFlag};
5 use crate::type_error_struct;
6 use rustc_ast::util::parser::PREC_POSTFIX;
7 use rustc_errors::{struct_span_err, Applicability, Diagnostic, StashKey};
9 use rustc_hir::def::{self, CtorKind, Namespace, Res};
10 use rustc_hir::def_id::DefId;
13 traits::{self, Obligation},
16 infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind},
17 traits::ObligationCause,
19 use rustc_middle::ty::adjustment::{
20 Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability,
22 use rustc_middle::ty::SubstsRef;
23 use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitable};
24 use rustc_span::def_id::LocalDefId;
25 use rustc_span::symbol::{sym, Ident};
27 use rustc_target::spec::abi;
28 use rustc_trait_selection::autoderef::Autoderef;
29 use rustc_trait_selection::infer::InferCtxtExt as _;
30 use rustc_trait_selection::traits::error_reporting::DefIdOrName;
31 use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
33 use std::{iter, slice};
35 /// Checks that it is legal to call methods of the trait corresponding
36 /// to `trait_id` (this only cares about the trait, not the specific
37 /// method that is called).
38 pub fn check_legal_trait_for_method_call(
41 receiver: Option<Span>,
45 if tcx.lang_items().drop_trait() == Some(trait_id) {
46 let mut err = struct_span_err!(tcx.sess, span, E0040, "explicit use of destructor method");
47 err.span_label(span, "explicit destructor calls not allowed");
49 let (sp, suggestion) = receiver
50 .and_then(|s| tcx.sess.source_map().span_to_snippet(s).ok())
51 .filter(|snippet| !snippet.is_empty())
52 .map(|snippet| (expr_span, format!("drop({snippet})")))
53 .unwrap_or_else(|| (span, "drop".to_string()));
57 "consider using `drop` function",
59 Applicability::MaybeIncorrect,
69 DeferredClosure(LocalDefId, ty::FnSig<'tcx>),
70 /// E.g., enum variant constructors.
71 Overloaded(MethodCallee<'tcx>),
74 impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
77 call_expr: &'tcx hir::Expr<'tcx>,
78 callee_expr: &'tcx hir::Expr<'tcx>,
79 arg_exprs: &'tcx [hir::Expr<'tcx>],
80 expected: Expectation<'tcx>,
82 let original_callee_ty = match &callee_expr.kind {
83 hir::ExprKind::Path(hir::QPath::Resolved(..) | hir::QPath::TypeRelative(..)) => self
84 .check_expr_with_expectation_and_args(
86 Expectation::NoExpectation,
89 _ => self.check_expr(callee_expr),
92 let expr_ty = self.structurally_resolved_type(call_expr.span, original_callee_ty);
94 let mut autoderef = self.autoderef(callee_expr.span, expr_ty);
95 let mut result = None;
96 while result.is_none() && autoderef.next().is_some() {
97 result = self.try_overloaded_call_step(call_expr, callee_expr, arg_exprs, &autoderef);
99 self.register_predicates(autoderef.into_obligations());
101 let output = match result {
103 // this will report an error since original_callee_ty is not a fn
104 self.confirm_builtin_call(
113 Some(CallStep::Builtin(callee_ty)) => {
114 self.confirm_builtin_call(call_expr, callee_expr, callee_ty, arg_exprs, expected)
117 Some(CallStep::DeferredClosure(def_id, fn_sig)) => {
118 self.confirm_deferred_closure_call(call_expr, arg_exprs, expected, def_id, fn_sig)
121 Some(CallStep::Overloaded(method_callee)) => {
122 self.confirm_overloaded_call(call_expr, arg_exprs, expected, method_callee)
126 // we must check that return type of called functions is WF:
127 self.register_wf_obligation(output.into(), call_expr.span, traits::WellFormed(None));
132 #[instrument(level = "debug", skip(self, call_expr, callee_expr, arg_exprs, autoderef), ret)]
133 fn try_overloaded_call_step(
135 call_expr: &'tcx hir::Expr<'tcx>,
136 callee_expr: &'tcx hir::Expr<'tcx>,
137 arg_exprs: &'tcx [hir::Expr<'tcx>],
138 autoderef: &Autoderef<'a, 'tcx>,
139 ) -> Option<CallStep<'tcx>> {
141 self.structurally_resolved_type(autoderef.span(), autoderef.final_ty(false));
143 // If the callee is a bare function or a closure, then we're all set.
144 match *adjusted_ty.kind() {
145 ty::FnDef(..) | ty::FnPtr(_) => {
146 let adjustments = self.adjust_steps(autoderef);
147 self.apply_adjustments(callee_expr, adjustments);
148 return Some(CallStep::Builtin(adjusted_ty));
151 ty::Closure(def_id, substs) => {
152 let def_id = def_id.expect_local();
154 // Check whether this is a call to a closure where we
155 // haven't yet decided on whether the closure is fn vs
156 // fnmut vs fnonce. If so, we have to defer further processing.
157 if self.closure_kind(substs).is_none() {
158 let closure_sig = substs.as_closure().sig();
159 let closure_sig = self.replace_bound_vars_with_fresh_vars(
164 let adjustments = self.adjust_steps(autoderef);
165 self.record_deferred_call_resolution(
167 DeferredCallResolution {
173 closure_substs: substs,
176 return Some(CallStep::DeferredClosure(def_id, closure_sig));
180 // Hack: we know that there are traits implementing Fn for &F
181 // where F:Fn and so forth. In the particular case of types
182 // like `f: &mut FnMut()`, if there is a call `f()`, we would
183 // normally translate to `FnMut::call_mut(&mut f, ())`, but
184 // that winds up potentially requiring the user to mark their
185 // variable as `mut` which feels unnecessary and unexpected.
187 // fn foo(f: &mut impl FnMut()) { f() }
188 // ^ without this hack `f` would have to be declared as mutable
190 // The simplest fix by far is to just ignore this case and deref again,
191 // so we wind up with `FnMut::call_mut(&mut *f, ())`.
192 ty::Ref(..) if autoderef.step_count() == 0 => {
203 // Now, we look for the implementation of a Fn trait on the object's type.
204 // We first do it with the explicit instruction to look for an impl of
205 // `Fn<Tuple>`, with the tuple `Tuple` having an arity corresponding
206 // to the number of call parameters.
207 // If that fails (or_else branch), we try again without specifying the
208 // shape of the tuple (hence the None). This allows to detect an Fn trait
209 // is implemented, and use this information for diagnostic.
210 self.try_overloaded_call_traits(call_expr, adjusted_ty, Some(arg_exprs))
211 .or_else(|| self.try_overloaded_call_traits(call_expr, adjusted_ty, None))
212 .map(|(autoref, method)| {
213 let mut adjustments = self.adjust_steps(autoderef);
214 adjustments.extend(autoref);
215 self.apply_adjustments(callee_expr, adjustments);
216 CallStep::Overloaded(method)
220 fn try_overloaded_call_traits(
222 call_expr: &hir::Expr<'_>,
223 adjusted_ty: Ty<'tcx>,
224 opt_arg_exprs: Option<&'tcx [hir::Expr<'tcx>]>,
225 ) -> Option<(Option<Adjustment<'tcx>>, MethodCallee<'tcx>)> {
226 // Try the options that are least restrictive on the caller first.
227 for (opt_trait_def_id, method_name, borrow) in [
228 (self.tcx.lang_items().fn_trait(), Ident::with_dummy_span(sym::call), true),
229 (self.tcx.lang_items().fn_mut_trait(), Ident::with_dummy_span(sym::call_mut), true),
230 (self.tcx.lang_items().fn_once_trait(), Ident::with_dummy_span(sym::call_once), false),
232 let Some(trait_def_id) = opt_trait_def_id else { continue };
234 let opt_input_type = opt_arg_exprs.map(|arg_exprs| {
235 self.tcx.mk_tup(arg_exprs.iter().map(|e| {
236 self.next_ty_var(TypeVariableOrigin {
237 kind: TypeVariableOriginKind::TypeInference,
243 if let Some(ok) = self.lookup_method_in_trait(
248 opt_input_type.as_ref().map(slice::from_ref),
250 let method = self.register_infer_ok_obligations(ok);
251 let mut autoref = None;
253 // Check for &self vs &mut self in the method signature. Since this is either
254 // the Fn or FnMut trait, it should be one of those.
255 let ty::Ref(region, _, mutbl) = method.sig.inputs()[0].kind() else {
256 // The `fn`/`fn_mut` lang item is ill-formed, which should have
257 // caused an error elsewhere.
260 .delay_span_bug(call_expr.span, "input to call/call_mut is not a ref?");
264 let mutbl = match mutbl {
265 hir::Mutability::Not => AutoBorrowMutability::Not,
266 hir::Mutability::Mut => AutoBorrowMutability::Mut {
267 // For initial two-phase borrow
268 // deployment, conservatively omit
269 // overloaded function call ops.
270 allow_two_phase_borrow: AllowTwoPhase::No,
273 autoref = Some(Adjustment {
274 kind: Adjust::Borrow(AutoBorrow::Ref(*region, mutbl)),
275 target: method.sig.inputs()[0],
278 return Some((autoref, method));
285 /// Give appropriate suggestion when encountering `||{/* not callable */}()`, where the
286 /// likely intention is to call the closure, suggest `(||{})()`. (#55851)
287 fn identify_bad_closure_def_and_call(
289 err: &mut Diagnostic,
291 callee_node: &hir::ExprKind<'_>,
294 let hir = self.tcx.hir();
295 let parent_hir_id = hir.get_parent_node(hir_id);
296 let parent_node = hir.get(parent_hir_id);
298 hir::Node::Expr(hir::Expr {
299 kind: hir::ExprKind::Closure(&hir::Closure { fn_decl_span, body, .. }),
302 hir::ExprKind::Block(..),
303 ) = (parent_node, callee_node)
305 let fn_decl_span = if hir.body(body).generator_kind
306 == Some(hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Closure))
308 // Actually need to unwrap a few more layers of HIR to get to
309 // the _real_ closure...
310 let async_closure = hir.get_parent_node(hir.get_parent_node(parent_hir_id));
311 if let hir::Node::Expr(hir::Expr {
312 kind: hir::ExprKind::Closure(&hir::Closure { fn_decl_span, .. }),
314 }) = hir.get(async_closure)
324 let start = fn_decl_span.shrink_to_lo();
325 let end = callee_span.shrink_to_hi();
326 err.multipart_suggestion(
327 "if you meant to create this closure and immediately call it, surround the \
328 closure with parentheses",
329 vec![(start, "(".to_string()), (end, ")".to_string())],
330 Applicability::MaybeIncorrect,
335 /// Give appropriate suggestion when encountering `[("a", 0) ("b", 1)]`, where the
336 /// likely intention is to create an array containing tuples.
337 fn maybe_suggest_bad_array_definition(
339 err: &mut Diagnostic,
340 call_expr: &'tcx hir::Expr<'tcx>,
341 callee_expr: &'tcx hir::Expr<'tcx>,
343 let hir_id = self.tcx.hir().get_parent_node(call_expr.hir_id);
344 let parent_node = self.tcx.hir().get(hir_id);
346 hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Array(_), .. }),
347 hir::ExprKind::Tup(exp),
348 hir::ExprKind::Call(_, args),
349 ) = (parent_node, &callee_expr.kind, &call_expr.kind)
350 && args.len() == exp.len()
352 let start = callee_expr.span.shrink_to_hi();
355 "consider separating array elements with a comma",
357 Applicability::MaybeIncorrect,
364 fn confirm_builtin_call(
366 call_expr: &'tcx hir::Expr<'tcx>,
367 callee_expr: &'tcx hir::Expr<'tcx>,
369 arg_exprs: &'tcx [hir::Expr<'tcx>],
370 expected: Expectation<'tcx>,
372 let (fn_sig, def_id) = match *callee_ty.kind() {
373 ty::FnDef(def_id, subst) => {
374 let fn_sig = self.tcx.bound_fn_sig(def_id).subst(self.tcx, subst);
376 // Unit testing: function items annotated with
377 // `#[rustc_evaluate_where_clauses]` trigger special output
378 // to let us test the trait evaluation system.
379 if self.tcx.has_attr(def_id, sym::rustc_evaluate_where_clauses) {
380 let predicates = self.tcx.predicates_of(def_id);
381 let predicates = predicates.instantiate(self.tcx, subst);
382 for (predicate, predicate_span) in
383 predicates.predicates.iter().zip(&predicates.spans)
385 let obligation = Obligation::new(
387 ObligationCause::dummy_with_span(callee_expr.span),
391 let result = self.evaluate_obligation(&obligation);
396 &format!("evaluate({:?}) = {:?}", predicate, result),
398 .span_label(*predicate_span, "predicate")
402 (fn_sig, Some(def_id))
404 ty::FnPtr(sig) => (sig, None),
406 if let hir::ExprKind::Path(hir::QPath::Resolved(_, path)) = &callee_expr.kind
407 && let [segment] = path.segments
408 && let Some(mut diag) = self
412 .steal_diagnostic(segment.ident.span, StashKey::CallIntoMethod)
414 // Try suggesting `foo(a)` -> `a.foo()` if possible.
416 self.suggest_call_as_method(
431 self.report_invalid_callee(call_expr, callee_expr, callee_ty, arg_exprs);
433 // This is the "default" function signature, used in case of error.
434 // In that case, we check each argument against "error" in order to
435 // set up all the node type bindings.
437 ty::Binder::dummy(self.tcx.mk_fn_sig(
438 self.err_args(arg_exprs.len()).into_iter(),
441 hir::Unsafety::Normal,
449 // Replace any late-bound regions that appear in the function
450 // signature with region variables. We also have to
451 // renormalize the associated types at this point, since they
452 // previously appeared within a `Binder<>` and hence would not
453 // have been normalized before.
454 let fn_sig = self.replace_bound_vars_with_fresh_vars(call_expr.span, infer::FnCall, fn_sig);
455 let fn_sig = self.normalize_associated_types_in(call_expr.span, fn_sig);
457 // Call the generic checker.
458 let expected_arg_tys = self.expected_inputs_for_expected_output(
464 self.check_argument_types(
471 TupleArgumentsFlag::DontTupleArguments,
475 if fn_sig.abi == abi::Abi::RustCall {
476 let sp = arg_exprs.last().map_or(call_expr.span, |expr| expr.span);
477 if let Some(ty) = fn_sig.inputs().last().copied() {
480 self.tcx.require_lang_item(hir::LangItem::Tuple, Some(sp)),
481 traits::ObligationCause::new(sp, self.body_id, traits::RustCall),
484 self.tcx.sess.span_err(
486 "functions with the \"rust-call\" ABI must take a single non-self tuple argument",
494 /// Attempts to reinterpret `method(rcvr, args...)` as `rcvr.method(args...)`
495 /// and suggesting the fix if the method probe is successful.
496 fn suggest_call_as_method(
498 diag: &mut Diagnostic,
499 segment: &'tcx hir::PathSegment<'tcx>,
500 arg_exprs: &'tcx [hir::Expr<'tcx>],
501 call_expr: &'tcx hir::Expr<'tcx>,
502 expected: Expectation<'tcx>,
503 ) -> Option<Ty<'tcx>> {
504 if let [callee_expr, rest @ ..] = arg_exprs {
505 let callee_ty = self.check_expr(callee_expr);
506 // First, do a probe with `IsSuggestion(true)` to avoid emitting
507 // any strange errors. If it's successful, then we'll do a true
516 // We didn't record the in scope traits during late resolution
517 // so we need to probe AllTraits unfortunately
518 ProbeScope::AllTraits,
523 let pick = self.confirm_method(
531 if pick.illegal_sized_bound.is_some() {
535 let up_to_rcvr_span = segment.ident.span.until(callee_expr.span);
536 let rest_span = callee_expr.span.shrink_to_hi().to(call_expr.span.shrink_to_hi());
537 let rest_snippet = if let Some(first) = rest.first() {
541 .span_to_snippet(first.span.to(call_expr.span.shrink_to_hi()))
546 if let Ok(rest_snippet) = rest_snippet {
547 let sugg = if callee_expr.precedence().order() >= PREC_POSTFIX {
549 (up_to_rcvr_span, "".to_string()),
550 (rest_span, format!(".{}({rest_snippet}", segment.ident)),
554 (up_to_rcvr_span, "(".to_string()),
555 (rest_span, format!(").{}({rest_snippet}", segment.ident)),
558 let self_ty = self.resolve_vars_if_possible(pick.callee.sig.inputs()[0]);
559 diag.multipart_suggestion(
561 "use the `.` operator to call the method `{}{}` on `{self_ty}`",
563 .associated_item(pick.callee.def_id)
564 .trait_container(self.tcx)
567 |trait_def_id| self.tcx.def_path_str(trait_def_id) + "::"
572 Applicability::MaybeIncorrect,
575 // Let's check the method fully now
576 let return_ty = self.check_method_argument_types(
581 TupleArgumentsFlag::DontTupleArguments,
585 return Some(return_ty);
592 fn report_invalid_callee(
594 call_expr: &'tcx hir::Expr<'tcx>,
595 callee_expr: &'tcx hir::Expr<'tcx>,
597 arg_exprs: &'tcx [hir::Expr<'tcx>],
599 let mut unit_variant = None;
600 if let hir::ExprKind::Path(qpath) = &callee_expr.kind
601 && let Res::Def(def::DefKind::Ctor(kind, CtorKind::Const), _)
602 = self.typeck_results.borrow().qpath_res(qpath, callee_expr.hir_id)
603 // Only suggest removing parens if there are no arguments
604 && arg_exprs.is_empty()
606 let descr = match kind {
607 def::CtorOf::Struct => "struct",
608 def::CtorOf::Variant => "enum variant",
610 let removal_span = callee_expr.span.shrink_to_hi().to(call_expr.span.shrink_to_hi());
611 unit_variant = Some((removal_span, descr, rustc_hir_pretty::qpath_to_string(qpath)));
614 let callee_ty = self.resolve_vars_if_possible(callee_ty);
615 let mut err = type_error_struct!(
620 "expected function, found {}",
621 match &unit_variant {
622 Some((_, kind, path)) => format!("{kind} `{path}`"),
623 None => format!("`{callee_ty}`"),
627 self.identify_bad_closure_def_and_call(
634 if let Some((removal_span, kind, path)) = &unit_variant {
635 err.span_suggestion_verbose(
638 "`{path}` is a unit {kind}, and does not take parentheses to be constructed",
641 Applicability::MachineApplicable,
645 let mut inner_callee_path = None;
646 let def = match callee_expr.kind {
647 hir::ExprKind::Path(ref qpath) => {
648 self.typeck_results.borrow().qpath_res(qpath, callee_expr.hir_id)
650 hir::ExprKind::Call(ref inner_callee, _) => {
651 // If the call spans more than one line and the callee kind is
652 // itself another `ExprCall`, that's a clue that we might just be
653 // missing a semicolon (Issue #51055)
654 let call_is_multiline = self.tcx.sess.source_map().is_multiline(call_expr.span);
655 if call_is_multiline {
657 callee_expr.span.shrink_to_hi(),
658 "consider using a semicolon here",
660 Applicability::MaybeIncorrect,
663 if let hir::ExprKind::Path(ref inner_qpath) = inner_callee.kind {
664 inner_callee_path = Some(inner_qpath);
665 self.typeck_results.borrow().qpath_res(inner_qpath, inner_callee.hir_id)
673 if !self.maybe_suggest_bad_array_definition(&mut err, call_expr, callee_expr) {
674 if let Some((maybe_def, output_ty, _)) =
675 self.extract_callable_info(callee_expr, callee_ty)
676 && !self.type_is_sized_modulo_regions(self.param_env, output_ty, callee_expr.span)
678 let descr = match maybe_def {
679 DefIdOrName::DefId(def_id) => self.tcx.def_kind(def_id).descr(def_id),
680 DefIdOrName::Name(name) => name,
684 format!("this {descr} returns an unsized value `{output_ty}`, so it cannot be called")
686 if let DefIdOrName::DefId(def_id) = maybe_def
687 && let Some(def_span) = self.tcx.hir().span_if_local(def_id)
689 err.span_label(def_span, "the callable type is defined here");
692 err.span_label(call_expr.span, "call expression requires function");
696 if let Some(span) = self.tcx.hir().res_span(def) {
697 let callee_ty = callee_ty.to_string();
698 let label = match (unit_variant, inner_callee_path) {
699 (Some((_, kind, path)), _) => Some(format!("{kind} `{path}` defined here")),
700 (_, Some(hir::QPath::Resolved(_, path))) => self
704 .span_to_snippet(path.span)
706 .map(|p| format!("`{p}` defined here returns `{callee_ty}`")),
709 // Emit a different diagnostic for local variables, as they are not
710 // type definitions themselves, but rather variables *of* that type.
711 Res::Local(hir_id) => Some(format!(
712 "`{}` has type `{}`",
713 self.tcx.hir().name(hir_id),
716 Res::Def(kind, def_id) if kind.ns() == Some(Namespace::ValueNS) => {
717 Some(format!("`{}` defined here", self.tcx.def_path_str(def_id),))
719 _ => Some(format!("`{callee_ty}` defined here")),
723 if let Some(label) = label {
724 err.span_label(span, label);
730 fn confirm_deferred_closure_call(
732 call_expr: &'tcx hir::Expr<'tcx>,
733 arg_exprs: &'tcx [hir::Expr<'tcx>],
734 expected: Expectation<'tcx>,
735 closure_def_id: LocalDefId,
736 fn_sig: ty::FnSig<'tcx>,
738 // `fn_sig` is the *signature* of the closure being called. We
739 // don't know the full details yet (`Fn` vs `FnMut` etc), but we
740 // do know the types expected for each argument and the return
743 let expected_arg_tys = self.expected_inputs_for_expected_output(
750 self.check_argument_types(
757 TupleArgumentsFlag::TupleArguments,
758 Some(closure_def_id.to_def_id()),
764 fn confirm_overloaded_call(
766 call_expr: &'tcx hir::Expr<'tcx>,
767 arg_exprs: &'tcx [hir::Expr<'tcx>],
768 expected: Expectation<'tcx>,
769 method_callee: MethodCallee<'tcx>,
771 let output_type = self.check_method_argument_types(
776 TupleArgumentsFlag::TupleArguments,
780 self.write_method_call(call_expr.hir_id, method_callee);
786 pub struct DeferredCallResolution<'tcx> {
787 call_expr: &'tcx hir::Expr<'tcx>,
788 callee_expr: &'tcx hir::Expr<'tcx>,
789 adjusted_ty: Ty<'tcx>,
790 adjustments: Vec<Adjustment<'tcx>>,
791 fn_sig: ty::FnSig<'tcx>,
792 closure_substs: SubstsRef<'tcx>,
795 impl<'a, 'tcx> DeferredCallResolution<'tcx> {
796 pub fn resolve(self, fcx: &FnCtxt<'a, 'tcx>) {
797 debug!("DeferredCallResolution::resolve() {:?}", self);
799 // we should not be invoked until the closure kind has been
800 // determined by upvar inference
801 assert!(fcx.closure_kind(self.closure_substs).is_some());
803 // We may now know enough to figure out fn vs fnmut etc.
804 match fcx.try_overloaded_call_traits(self.call_expr, self.adjusted_ty, None) {
805 Some((autoref, method_callee)) => {
806 // One problem is that when we get here, we are going
807 // to have a newly instantiated function signature
808 // from the call trait. This has to be reconciled with
809 // the older function signature we had before. In
810 // principle we *should* be able to fn_sigs(), but we
811 // can't because of the annoying need for a TypeTrace.
812 // (This always bites me, should find a way to
814 let method_sig = method_callee.sig;
816 debug!("attempt_resolution: method_callee={:?}", method_callee);
818 for (method_arg_ty, self_arg_ty) in
819 iter::zip(method_sig.inputs().iter().skip(1), self.fn_sig.inputs())
821 fcx.demand_eqtype(self.call_expr.span, *self_arg_ty, *method_arg_ty);
824 fcx.demand_eqtype(self.call_expr.span, method_sig.output(), self.fn_sig.output());
826 let mut adjustments = self.adjustments;
827 adjustments.extend(autoref);
828 fcx.apply_adjustments(self.callee_expr, adjustments);
830 fcx.write_method_call(self.call_expr.hir_id, method_callee);
833 // This can happen if `#![no_core]` is used and the `fn/fn_mut/fn_once`
834 // lang items are not defined (issue #86238).
835 let mut err = fcx.inh.tcx.sess.struct_span_err(
837 "failed to find an overloaded call trait for closure call",
840 "make sure the `fn`/`fn_mut`/`fn_once` lang items are defined \
841 and have associated `call`/`call_mut`/`call_once` functions",