Skip to content

Commit 2a0a35c

Browse files
committed
Merge pull request #674 from mcarton/fix-collapsible_if
Fix suggestion in `COLLAPSIBLE_IF` lint
2 parents 7843f3f + 00b27bf commit 2a0a35c

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/collapsible_if.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ fn check_if(cx: &LateContext, e: &Expr) {
6666
COLLAPSIBLE_IF,
6767
block.span,
6868
"this `else { if .. }` block can be collapsed", |db| {
69-
db.span_suggestion(block.span, "try",
70-
format!("else {}",
71-
snippet_block(cx, else_.span, "..")));
69+
db.span_suggestion(block.span, "try", snippet_block(cx, else_.span, "..").into_owned());
7270
});
7371
}}
7472
} else if let Some(&Expr{ node: ExprIf(ref check_inner, ref content, None), span: sp, ..}) =

tests/compile-fail/collapsible_if.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn main() {
2222
print!("Hello ");
2323
} else { //~ERROR: this `else { if .. }`
2424
//~| HELP try
25-
//~| SUGGESTION else if y == "world"
25+
//~| SUGGESTION } else if y == "world"
2626
if y == "world" {
2727
println!("world!")
2828
}
@@ -32,7 +32,7 @@ fn main() {
3232
print!("Hello ");
3333
} else { //~ERROR this `else { if .. }`
3434
//~| HELP try
35-
//~| SUGGESTION else if y == "world"
35+
//~| SUGGESTION } else if y == "world"
3636
if y == "world" {
3737
println!("world")
3838
}

0 commit comments

Comments
 (0)