Fix suggestion in COLLAPSIBLE_IF lint
This commit is contained in:
parent
7843f3f863
commit
00b27bf7be
2 changed files with 3 additions and 5 deletions
|
|
@ -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, ..}) =
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue