fcx.write_method_call(self.call_expr.hir_id, method_callee);
}
None => {
- span_bug!(
+ // 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"
+ "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 an associated `call`/`call_mut`/`call_once` function",
+ );
+ err.emit();
}
}
}
--- /dev/null
+// Regression test for the ICE described in issue #86238.
+
+#![feature(lang_items)]
+#![feature(no_core)]
+
+#![no_core]
+fn main() {
+ let one = || {};
+ one()
+ //~^ ERROR: failed to find an overloaded call trait for closure call
+ //~| HELP: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined
+}
+#[lang = "sized"]
+trait Sized {}
+#[lang = "copy"]
+trait Copy {}
--- /dev/null
+error: failed to find an overloaded call trait for closure call
+ --> $DIR/issue-86238.rs:9:5
+ |
+LL | one()
+ | ^^^^^
+ |
+ = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have an associated `call`/`call_mut`/`call_once` function
+
+error: aborting due to previous error
+