Skip to content

Commit 5e3b36c

Browse files
Daniel J RollinsManishearth
Daniel J Rollins
authored andcommitted
Fix code review actions in PR rust-lang#32053
Split `fileline_note` into a `file_line note` and `span_suggestion` as per @Manishearth's suggestions. Change nested `match`es to `if let`s.
1 parent 2dd5776 commit 5e3b36c

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/librustc_typeck/check/method/suggest.rs

+12-12
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)