Skip to content

Fix suggestion in COLLAPSIBLE_IF lint #674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/collapsible_if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, ..}) =
Expand Down
4 changes: 2 additions & 2 deletions tests/compile-fail/collapsible_if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
}
Expand All @@ -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")
}
Expand Down