-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Gate collapsible_if let_chains lints on edition 2024 and MSRV #14723
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
Gate collapsible_if let_chains lints on edition 2024 and MSRV #14723
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
I'll take it, I'm back online on Monday. |
Oops, forgot about that. Thanks! |
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 like it. I made two nitpicking comments.
clippy_lints_internal/Cargo.toml
Outdated
edition = "2021" | ||
edition = "2024" |
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.
Is it really part of this PR? Maybe at least a separate commit would be clearer.
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.
It was leftover from another change
fn eligible_condition(&self, cx: &LateContext<'_>, cond: &Expr<'_>) -> bool { | ||
!matches!(cond.kind, ExprKind::Let(..)) | ||
|| (cx.tcx.sess.edition().at_least_rust_2024() && self.msrv.meets(cx, msrvs::LET_CHAINS)) |
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.
Any reason to prefer passing an extra argument every time (cx
) and doing an edition comparison, while the edition being ≥2024 could instead be checked once from tcx
at CollapsibleIf::new()
time? The performance hit should be unnoticeable, but I wonder why you made this choice.
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.
cx
is required for the MSRV check so doing so doesn't remove the extra arg
It could've been done once in new
, it's not really something I actively considered. Perf wise it's an extra pointer dereference or two, doesn't seem worth splitting up the condition
6e7f20c
to
8c93668
Compare
The MSRV being for crates targeting 1.85-1.87 on edition 2024
This enables the lint for regular nightly users without the feature gate enabled
r? @samueltardieu
Fixes #14678
changelog: none