-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add collapse-let-chains
option to collapsible_if
lint
#14455
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
Conversation
cfb1562
to
bec2183
Compare
This PR enables the new ability to collapse `if` statements containing comments (without losing them) in Clippy sources, excluding tests and lintcheck, where the default behaviour (no collapsing in presence of comments) is preserved. To be applied after #14231. When it is applied, #14455 will be marked as ready for review, then #14228 afterwards. changelog: none r? ghost
Since `collapsible_if` is an early lint, it is not possible to automatically check whether the `let_chains` unstable rustc feature is enabled or not, as features are not available in the `EarlyContext` object. For this reason, the `collapse-let-chains` needs to be enabled explicitly. This can be reexamined later when the `let_chains` feature is stabilized.
bec2183
to
dbfe15e
Compare
How difficult would it be to turn this into a late lint pass? |
I'll check when I get a chance. Originally, the lint used @rustbot author |
Until `if let` chains are stabilized, we do not collapse them together or with other `if` expressions unless the `let_chains` feature is enabled. This is the case for example in Clippy sources. This was made possible by converting the `collapsible_if` to a late lint to get access to the set of enabled features. This allows this PR to supersede #14455 and no longer require an additional configuration option. The three commits are, in order: - a conversion of the existing early lint to a late lint, with no new feature or tests changes - the addition of the `let_chains` feature detection and action, and tests - the application of the enhanced lint to Clippy sources (136 files modified) changelog: [`collapsible_if`]: recognize the rust compiler `let_chains` feature r? @flip1995
Since
collapsible_if
is an early lint, it is not possible to automatically check whether thelet_chains
unstable rustc feature is enabled or not, as features are not available in theEarlyContext
object.For this reason, the
collapse-let-chains
needs to be enabled explicitly. This can be reexamined later when thelet_chains
feature is stabilized.changelog: [
collapsible_if
]: addcollapse-let-chains
optionr? ghost