-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Description
collapsible_else_if is currently in the style lint group, which is included as part of the all lint group which is run when a default cargo clippy invocation is used.
However, I keep finding myself wanting to disable collapsible_else_if because in most cases, I find that the suggested collapsed else-if form is a pessimization on readability. Taking the typical example from #general > Experience with `clippy::collapsible_else_if`:
if something_completely_different {
// something completely different than the other branches
} else {
if left {
turn(Left);
} else {
turn(Right);
}
}The lint would recommend
if something_completely_different {
// something completely different than the other branches
} else if left {
turn(Left);
} else {
turn(Right);
}However, I find that the recommended form is less clear, because it loses the "structural" grouping information that the former form has.
I realize this is very much subjective, but just wanted to open this issue in case moving collapsible_else_if out of the set of enabled-by-default lints is something that other people would also want, and if this is something the clippy team might consider.
Version
rustc 1.91.1 (ed61e7d7e 2025-11-07)
binary: rustc
commit-hash: ed61e7d7e242494fb7057f2657300d9e77bb4fcb
commit-date: 2025-11-07
host: aarch64-apple-darwin
release: 1.91.1
LLVM version: 21.1.2
Additional Labels
@rustbot label: +C-question