diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index dcecec7007d52..988d5537e5db7 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. diff --git a/src/test/compile-fail/issue-10969.rs b/src/test/compile-fail/issue-10969.rs new file mode 100644 index 0000000000000..0851020b1f1d8 --- /dev/null +++ b/src/test/compile-fail/issue-10969.rs @@ -0,0 +1,17 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn func(i: i32) { //~NOTE defined here + i(); //~ERROR expected function, found `i32` +} +fn main() { + let i = 0i32; //~NOTE defined here + i(); //~ERROR expected function, found `i32` +}