Skip to content

More specific error when calling bottom #34897

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

Closed
wants to merge 1 commit into from
Closed
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: 10 additions & 1 deletion src/librustc_typeck/check/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,17 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
adjusted_ty,
autoderefs);

let ty = self.resolve_type_vars_with_obligations(adjusted_ty);
if ty.is_ty_var() {
if !self.is_tainted_by_errors() {
self.tcx.sess.span_err(callee_expr.span,
"cannot determine the type of this callee");
}
return None;
}

// If the callee is a bare function or a closure, then we're all set.
match self.structurally_resolved_type(callee_expr.span, adjusted_ty).sty {
match ty.sty {
ty::TyFnDef(..) | ty::TyFnPtr(_) => {
self.write_autoderef_adjustment(callee_expr.id, autoderefs);
return Some(CallStep::Builtin);
Expand Down
7 changes: 2 additions & 5 deletions src/test/compile-fail/issue-15965.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
// except according to those terms.

fn main() {
return
{ return () }
//~^ ERROR the type of this value must be known in this context
()
;
(return) //~ ERROR cannot determine the type of this callee
();
}
4 changes: 2 additions & 2 deletions src/test/compile-fail/issue-18532.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
#![feature(unboxed_closures)]

fn main() {
(return)((),());
//~^ ERROR the type of this value must be known
(return) //~ ERROR cannot determine the type of this callee
((), ());
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn a() {
match closure0.take() {
Some(c) => {
return c();
//~^ ERROR the type of this value must be known in this context
//~^ ERROR cannot determine the type of this callee
}
None => { }
}
Expand Down