-
Notifications
You must be signed in to change notification settings - Fork 1.7k
autofix for redundant_else
lint
#13936
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
Conversation
e395c27
to
8ade7a6
Compare
What if the For example, the PR fails with this code: fn with_drop(t: bool) -> u32 {
let a = 42;
if t {
return 0;
} else {
let a = "foobar";
println!("this a = {a}");
}
a + 1
} because Maybe the suggestion should apply only when no bindings are introduced inside the |
Another (very minor) issue is that if the fix belongs to a macro, the indentation shown will be the one of the macro call, not the proper one, e.g., macro_rules! mac {
($t:expr) => {{
if $t {
return 0;
} else {
return 42;
}
}}
}
fn call_macro() -> u32 {
mac!(true)
} will suggest using macro_rules! mac {
($t:expr) => {{
if $t {
return 0;
}
return 42;
}}
} |
f397659
to
edf3828
Compare
r? clippy |
2bd7c1d
to
9e8ffc8
Compare
Commits are now squashed. |
note: I'd like to hear what the reviewers think about this issue, i.e., since I think this is usually a (very) minor issue, I'd like a decision on whether to merge this with this issue remaining (but clearly stated as a doc comment) or take some other action. |
This is so niche that I don't think it can block the patch (unless there is a very easy solution to fix this aesthetic issue). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good patch, it will be very useful. Thanks for the contribution!
9e8ffc8
to
7aae4f4
Compare
redundant_else
lintredundant_else
lint
@blyxyas Would you review again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a single nit and this can be merged! Sorry for the long wait, I've been kinda busy.
This comment has been minimized.
This comment has been minimized.
I'll fix this, I didn't think pushing the "Update branch" button would do such a thing. If anyone else with merge rights sees this comment do not merge |
b907ed9
to
7aae4f4
Compare
changelog: [
redundant_else
]: autofix for some casesredundant_else
can be fixed automatically.