Skip to content

Commit 428e790

Browse files
committed
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
1 parent 4891c00 commit 428e790

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/librustc_typeck/check/callee.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,17 @@ fn confirm_builtin_call<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
231231
format!("expected function, found `{}`", actual)
232232
}, callee_ty, None);
233233

234+
if let hir::ExprCall(ref expr, _) = call_expr.node {
235+
let tcx = fcx.tcx();
236+
if let Some(pr) = tcx.def_map.borrow().get(&expr.id) {
237+
if pr.depth == 0 {
238+
if let Some(span) = tcx.map.span_if_local(pr.def_id()) {
239+
tcx.sess.span_note(span, "defined here")
240+
}
241+
}
242+
}
243+
}
244+
234245
// This is the "default" function signature, used in case of error.
235246
// In that case, we check each argument against "error" in order to
236247
// set up all the node type bindings.

0 commit comments

Comments
 (0)