From 5e3b36c100c298f64bb947ea8771f3f38f94fad8 Mon Sep 17 00:00:00 2001 From: Daniel J Rollins Date: Sat, 5 Mar 2016 17:17:36 +0000 Subject: [PATCH] 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. --- src/librustc_typeck/check/method/suggest.rs | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index fa55da8b6cadc..3585f1e9c8805 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() {