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") }