rust-clippy icon indicating copy to clipboard operation
rust-clippy copied to clipboard

Move `collapsible_else_if` to `pedantic`

Open Alexendoo opened this issue 3 weeks ago • 4 comments

Looks like a good number of people disagree with this lint so it shouldn't be on by default

Fixes https://github.com/rust-lang/rust-clippy/issues/16209

changelog: [collapsible_else_if]: move to pedantic

Alexendoo avatar Dec 10 '25 15:12 Alexendoo

r? @Jarcho

rustbot has assigned @Jarcho. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

rustbot avatar Dec 10 '25 15:12 rustbot

Lintcheck changes for 69db81658ef2f4c54e85c3b5510bbcdb92961b5a

Lint Added Removed Changed
clippy::collapsible_else_if 0 0 10

This comment will be updated if you push new changes

github-actions[bot] avatar Dec 10 '25 15:12 github-actions[bot]

cc @rust-lang/clippy if anyone has something to add. I personally have no objection.

Jarcho avatar Dec 10 '25 20:12 Jarcho

As someone who doesn't like this lint, 👍

But also, to try to be constructive about it, I think there are also ways it could be made warn-by-default again. For example, suppose the situation is just

if cond1 {
    ... body with no blocks
} else {
    if cond2 {
        ... body with no blocks ...
    }
}

then that one I could agree with linting on more aggressively.

More abstractly, I dislike this lint when doing what it suggests loses consistency between the blocks, but if they're both simple there's no consistency to lose and it'd be better to reduce the indentation. (That gives me another possible phrasing, which I haven't thought through but might work: this lint is good when it reduces total indentation, but if the if is already more or just-as indented, then unindenting the else doesn't really make a material difference.)

scottmcm avatar Dec 11 '25 18:12 scottmcm