Fix suggestion in COLLAPSIBLE_IF lint

This commit is contained in:
mcarton 2016-02-15 17:43:16 +01:00
parent 7843f3f863
commit 00b27bf7be
2 changed files with 3 additions and 5 deletions

View File

@ -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, ..}) =

View File

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