Skip to content

Commit 2670ea4

Browse files
Daniel J RollinsManishearth
Daniel J Rollins
authored andcommitted
---
yaml --- r: 273368 b: refs/heads/beta c: 2343712 h: refs/heads/master
1 parent fa67a3a commit 2670ea4

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: fa0efa69c5df0164a5abcebfbb2434cc1f27ecb1
26+
refs/heads/beta: 234371216e0eb717ddc9cf00fb222885f4228798
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/librustc_typeck/check/method/suggest.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ use middle::subst::Substs;
2525
use middle::traits::{Obligation, SelectionContext};
2626
use util::nodemap::{FnvHashSet};
2727

28+
2829
use syntax::ast;
2930
use syntax::codemap::Span;
3031
use syntax::errors::DiagnosticBuilder;
3132
use rustc_front::print::pprust;
3233
use rustc_front::hir;
34+
use rustc_front::hir::Expr_;
3335

3436
use std::cell;
3537
use std::cmp::Ordering;
@@ -130,17 +132,28 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
130132
}
131133

132134
if is_fn_ty(&rcvr_ty, &fcx, span) {
133-
if let Some(expr) = rcvr_expr {
134-
if let Ok (expr_string) = cx.sess.codemap().span_to_snippet(expr.span) {
135+
macro_rules! report_function {
136+
($span:expr, $name:expr) => {
135137
err.fileline_note(
136-
expr.span,
138+
$span,
137139
&format!("{} is a function, perhaps you wish to call it",
138-
expr_string));
140+
$name));
141+
}
142+
}
143+
144+
if let Some(expr) = rcvr_expr {
145+
if let Ok (expr_string) = cx.sess.codemap().span_to_snippet(expr.span) {
146+
report_function!(expr.span, expr_string);
139147
err.span_suggestion(expr.span,
140148
"try calling the base function:",
141149
format!("{}()",
142150
expr_string));
143151
}
152+
else if let Expr_::ExprPath(_, path) = expr.node.clone() {
153+
if let Some(segment) = path.segments.last() {
154+
report_function!(expr.span, segment.identifier.name);
155+
}
156+
}
144157
}
145158
}
146159

branches/beta/src/test/compile-fail/issue-29124.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ fn func() -> ret {
2222
}
2323

2424
fn main() {
25-
obj::func.x();
25+
obj::func.x();
2626
//~^ ERROR no method named `x` found for type `fn() -> ret {obj::func}` in the current scope
2727
//~^^ NOTE obj::func is a function, perhaps you wish to call it
28-
func.x();
28+
func.x();
2929
//~^ ERROR no method named `x` found for type `fn() -> ret {func}` in the current scope
3030
//~^^ NOTE func is a function, perhaps you wish to call it
3131
}

0 commit comments

Comments
 (0)