diff options
| author | Daniel J Rollins <daniel@djrollins.io> | 2016-03-05 17:17:36 +0000 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2016-03-19 22:06:45 +0530 |
| commit | 5e3b36c100c298f64bb947ea8771f3f38f94fad8 (patch) | |
| tree | 9ff74b4955a0c4b95489d55cc3bcf84443d3ef00 | |
| parent | 2dd5776b1110a24d9ceb1d1f89dd684d0e63fbf7 (diff) | |
| download | rust-5e3b36c100c298f64bb947ea8771f3f38f94fad8.tar.gz rust-5e3b36c100c298f64bb947ea8771f3f38f94fad8.zip | |
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.
| -rw-r--r-- | src/librustc_typeck/check/method/suggest.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index fa55da8b6ca..3585f1e9c88 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -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() { |
