Fix code review actions in PR #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.
This commit is contained in:
parent
2dd5776b11
commit
5e3b36c100
@ -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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user