-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
auto-fix for redundant_else
lint
#13936
base: master
Are you sure you want to change the base?
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). |
changelog: [
redundant_else
]: auto-fix when appropriateredundant_else
can be fixed automatically.