Skip to content

Commit 77c995b

Browse files
committed
Auto merge of #30001 - Detegr:master, r=Manishearth
r? @Manishearth
2 parents a9d15a6 + 210c435 commit 77c995b

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/librustc_typeck/check/callee.rs

+11
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.

src/test/compile-fail/issue-10969.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn func(i: i32) { //~NOTE defined here
12+
i(); //~ERROR expected function, found `i32`
13+
}
14+
fn main() {
15+
let i = 0i32; //~NOTE defined here
16+
i(); //~ERROR expected function, found `i32`
17+
}

0 commit comments

Comments
 (0)