-
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
needless_else: new lint to check for empty else
clauses
#10810
Conversation
r? @llogiq (rustbot has picked a reviewer for you, use r? to override) |
i wonder how often it is happening :) |
/// ``` | ||
#[clippy::version = "1.71.0"] | ||
pub NEEDLESS_ELSE, | ||
style, |
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.
I wonder how often that happens. Given that it's a style lint (which is warn by default), I worry that it might drown out more important messages if we leave it that way. On the other hand, if it's rare anyway, perhaps it's not a big deal. I'll run lintcheck and report back.
Ok, so lintcheck didn't find any instance. Instances will probably be mostly in half-refactored code. Thank you! @bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Yeah, I should have reported that I ran lintcheck with the 500 most downloaded crates and found no occurrences. |
Ignore `#[cfg]`'d out code in `needless_else` changelog: none (same release as #10810) `#[cfg]` making things fun once more This lead me to think about macro calls that expand to nothing as well, but apparently they produce an empty stmt in the AST so are already handled, added a test for that r? `@llogiq`
Empty
else
clauses are useless. They happen in the wild and are not linted yet: https://github.com/uutils/coreutils/pull/4880/fileselse
clauses containing or preceded by comments are not linted as the comments might be important.changelog: [
needless_else
]: new lint