Skip to content

Commit

Permalink
Add a note when trying to call a non-function
Browse files Browse the repository at this point in the history
The note added tells the definition location of the non-function
that is being called. Fixes #10969
  • Loading branch information
Detegr committed Nov 23, 2015
1 parent 4891c00 commit 428e790
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/librustc_typeck/check/callee.rs
Expand Up @@ -231,6 +231,17 @@ fn confirm_builtin_call<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
format!("expected function, found `{}`", actual)
}, callee_ty, None);

if let hir::ExprCall(ref expr, _) = call_expr.node {
let tcx = fcx.tcx();
if let Some(pr) = tcx.def_map.borrow().get(&expr.id) {
if pr.depth == 0 {
if let Some(span) = tcx.map.span_if_local(pr.def_id()) {
tcx.sess.span_note(span, "defined here")
}
}
}
}

// This is the "default" function signature, used in case of error.
// In that case, we check each argument against "error" in order to
// set up all the node type bindings.
Expand Down

0 comments on commit 428e790

Please sign in to comment.