Skip to content

Commit

Permalink
Fix code review actions in PR #32053
Browse files Browse the repository at this point in the history
Split `fileline_note` into a `file_line note` and `span_suggestion` as per
@Manishearth's suggestions.

Change nested `match`es to `if let`s.
  • Loading branch information
Daniel J Rollins authored and Manishearth committed Mar 19, 2016
1 parent 2dd5776 commit 5e3b36c
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/librustc_typeck/check/method/suggest.rs
Expand Up @@ -130,18 +130,18 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
}

if is_fn_ty(&rcvr_ty, &fcx, span) {
let expr_string = match rcvr_expr {
Some(expr) => match cx.sess.codemap().span_to_snippet(expr.span) {
Ok(expr_string) => expr_string,
_ => "s".into()
},
_ => "s".into()
};
err.fileline_note(
span,
&format!("method invoked on function type. did you \
mean `{}().{}(...)`?",
expr_string, item_name));
if let Some(expr) = rcvr_expr {
if let Ok (expr_string) = cx.sess.codemap().span_to_snippet(expr.span) {
err.fileline_note(
expr.span,
&format!("{} is a function, perhaps you wish to call it?",
expr_string));
err.span_suggestion(expr.span,
"try calling the base function:",
format!("{}()",
expr_string));
}
}
}

if !static_sources.is_empty() {
Expand Down

0 comments on commit 5e3b36c

Please sign in to comment.