Skip to content

Commit 6a3a281

Browse files
Daniel J RollinsManishearth
Daniel J Rollins
authored andcommitted
---
yaml --- r: 273366 b: refs/heads/beta c: 5e3b36c h: refs/heads/master
1 parent 06a5060 commit 6a3a281

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
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: 2dd5776b1110a24d9ceb1d1f89dd684d0e63fbf7
26+
refs/heads/beta: 5e3b36c100c298f64bb947ea8771f3f38f94fad8
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: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,18 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
130130
}
131131

132132
if is_fn_ty(&rcvr_ty, &fcx, span) {
133-
let expr_string = match rcvr_expr {
134-
Some(expr) => match cx.sess.codemap().span_to_snippet(expr.span) {
135-
Ok(expr_string) => expr_string,
136-
_ => "s".into()
137-
},
138-
_ => "s".into()
139-
};
140-
err.fileline_note(
141-
span,
142-
&format!("method invoked on function type. did you \
143-
mean `{}().{}(...)`?",
144-
expr_string, item_name));
133+
if let Some(expr) = rcvr_expr {
134+
if let Ok (expr_string) = cx.sess.codemap().span_to_snippet(expr.span) {
135+
err.fileline_note(
136+
expr.span,
137+
&format!("{} is a function, perhaps you wish to call it?",
138+
expr_string));
139+
err.span_suggestion(expr.span,
140+
"try calling the base function:",
141+
format!("{}()",
142+
expr_string));
143+
}
144+
}
145145
}
146146

147147
if !static_sources.is_empty() {

0 commit comments

Comments
 (0)