-
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
Add needless_if
lint
#10921
Add needless_if
lint
#10921
Conversation
r? @Manishearth (rustbot has picked a reviewer for you, use r? to override) |
1d90048
to
0fc3b31
Compare
Yep, Will review it! |
add description
don't lint on `if let`
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 minor nitpick and I think this is done. Thanks! ❤️
cc @xFrednet
Some cases to check: if true {
#[cfg(any())]
foo;
} macro_rules! m {
($($t:tt)*) => {
if true {
$($t)*
}
}
}
m!(); |
@bors r=blyxyas,Manishearth looks great, you can ignore the comment i left or make a followup PR if you agree with me |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Sorry I didn't get to this 😅 I'll do this as a followup, though I'm pretty sure it'll lint on both currently. |
Opened #10935 for that + a few other cases I thought of/ran into |
Don't lint non-statement/faux empty `needless_if`s Also has a basic fall-back for `if` statements that have attributes applied to them and incorporates #10921 (review) while I was there r? `@Manishearth` changelog: none
first off: Sorry about the large diff. Seems a ton of tests do this (understandably so).
this is basically everything I wanted in #10868, while it doesn't lint all unnecessary empty blocks, it lints needless if statements; which are basically the crux of the issue (for me) anyway. I've committed code that includes this far too many times 😅 hopefully clippy can help me out soon
closes #10868
changelog: New lint [
needless_if
]