Skip to content

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

Merged

Conversation

Alexendoo
Copy link
Member

@Alexendoo Alexendoo commented May 1, 2025

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

@rustbot

This comment was marked as resolved.

@rustbot

This comment was marked as resolved.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label May 1, 2025
@samueltardieu
Copy link
Contributor

I'll take it, I'm back online on Monday.

@Alexendoo
Copy link
Member Author

Oops, forgot about that. Thanks!

Copy link
Contributor

@samueltardieu samueltardieu left a 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.

edition = "2021"
edition = "2024"
Copy link
Contributor

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.

Copy link
Member Author

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

Comment on lines +166 to +168
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))
Copy link
Contributor

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.

Copy link
Member Author

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

@Alexendoo Alexendoo force-pushed the collapsible-if-chain-msrv branch from 6e7f20c to 8c93668 Compare May 6, 2025 02:23
@samueltardieu samueltardieu added this pull request to the merge queue May 6, 2025
Merged via the queue into rust-lang:master with commit 50e0bf1 May 6, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suggest using let-chains
4 participants