diff options
| author | Antti Keränen <detegr@gmail.com> | 2015-11-23 16:48:55 +0200 |
|---|---|---|
| committer | Antti Keränen <detegr@gmail.com> | 2015-11-23 16:57:09 +0200 |
| commit | 428e790d8cc83b4bbffaf037acccfd29c6ff4777 (patch) | |
| tree | a6c3ca048bc6219c9d11ce3cca5f809c5833e0de | |
| parent | 4891c00634f209bcc66d7f00bc507eb35a0fe6a8 (diff) | |
| download | rust-428e790d8cc83b4bbffaf037acccfd29c6ff4777.tar.gz rust-428e790d8cc83b4bbffaf037acccfd29c6ff4777.zip | |
Add a note when trying to call a non-function
The note added tells the definition location of the non-function that is being called. Fixes #10969
| -rw-r--r-- | src/librustc_typeck/check/callee.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index dcecec7007d..988d5537e5d 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -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. |
