Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report an error if resolution of closure call functions failed #86249

Merged
merged 2 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions compiler/rustc_typeck/src/check/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,17 @@ impl<'a, 'tcx> DeferredCallResolution<'tcx> {
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 associated `call`/`call_mut`/`call_once` functions",
);
err.emit();
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/test/ui/lang-items/issue-86238.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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 {}
10 changes: 10 additions & 0 deletions src/test/ui/lang-items/issue-86238.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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 associated `call`/`call_mut`/`call_once` functions

error: aborting due to previous error