From 00b27bf7becf26f3be918f2558e56f617fd716ec Mon Sep 17 00:00:00 2001 From: mcarton Date: Mon, 15 Feb 2016 17:43:16 +0100 Subject: [PATCH] Fix suggestion in `COLLAPSIBLE_IF` lint --- src/collapsible_if.rs | 4 +--- tests/compile-fail/collapsible_if.rs | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/collapsible_if.rs b/src/collapsible_if.rs index 03c43ef5dc8..e5ad94fc639 100644 --- a/src/collapsible_if.rs +++ b/src/collapsible_if.rs @@ -66,9 +66,7 @@ fn check_if(cx: &LateContext, e: &Expr) { COLLAPSIBLE_IF, block.span, "this `else { if .. }` block can be collapsed", |db| { - db.span_suggestion(block.span, "try", - format!("else {}", - snippet_block(cx, else_.span, ".."))); + db.span_suggestion(block.span, "try", snippet_block(cx, else_.span, "..").into_owned()); }); }} } else if let Some(&Expr{ node: ExprIf(ref check_inner, ref content, None), span: sp, ..}) = diff --git a/tests/compile-fail/collapsible_if.rs b/tests/compile-fail/collapsible_if.rs index 85eac28dc38..3bf4128347a 100644 --- a/tests/compile-fail/collapsible_if.rs +++ b/tests/compile-fail/collapsible_if.rs @@ -22,7 +22,7 @@ fn main() { print!("Hello "); } else { //~ERROR: this `else { if .. }` //~| HELP try - //~| SUGGESTION else if y == "world" + //~| SUGGESTION } else if y == "world" if y == "world" { println!("world!") } @@ -32,7 +32,7 @@ fn main() { print!("Hello "); } else { //~ERROR this `else { if .. }` //~| HELP try - //~| SUGGESTION else if y == "world" + //~| SUGGESTION } else if y == "world" if y == "world" { println!("world") }