Skip to content
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

Pattern Migration 2024: try to suggest eliding redundant binding modifiers #136577

Merged
merged 13 commits into from
Feb 7, 2025

Conversation

dianne
Copy link
Contributor

@dianne dianne commented Feb 5, 2025

This is based on #136475. Only the last commit is new.

This is a simpler, more restrictive alternative to #136496, meant to partially address #136047. If a pattern can be migrated to Rust 2024 solely by removing redundant binding modifiers, this will make that suggestion; otherwise, it uses the old suggestion of making the pattern fully explicit.

Relevant tracking issue: #131414

@rustbot label A-diagnostics A-patterns A-edition-2024

r? @Nadrieril

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 5, 2025
@rustbot
Copy link
Collaborator

rustbot commented Feb 5, 2025

Some changes occurred in match checking

cc @Nadrieril

@rustbot rustbot added A-diagnostics Area: Messages for errors, warnings, and lints A-edition-2024 Area: The 2024 edition A-patterns Relating to patterns and pattern matching labels Feb 5, 2025
@dianne dianne force-pushed the simple-pat-migration-simplification branch from 3da87fa to d29804c Compare February 5, 2025 13:52
@dianne dianne force-pushed the simple-pat-migration-simplification branch from d29804c to 8dcdb3e Compare February 5, 2025 17:29
Most of these are meant to test possible future improvements, but since
they cover cases the existing test suite didn't, I figure including them
now may be helpful.
@dianne
Copy link
Contributor Author

dianne commented Feb 6, 2025

I've pulled in the tests from #136496. Most of them are targeting changes made in that PR, but the first two apply here too: the first tests that we do rewrite in a case that we can, and the second that we don't in a case that we shouldn't. I figure having the rest is nice too, just to be sure everything here (and in #136475) is working as intended; the existing tests didn't have much coverage involving both deep nesting and multiple bindings, and none involving bindings with subpatterns.

@apiraino
Copy link
Contributor

apiraino commented Feb 6, 2025

Following the discussion on Zulip I am going to nominate for the team compiler meeting to check the vibe about this

@rustbot label +I-compiler-nominated

@rustbot rustbot added the I-compiler-nominated Nominated for discussion during a compiler team meeting. label Feb 6, 2025
@Nadrieril
Copy link
Member

Amazing work, thanks for your reactivity @dianne. I quite like the result, hopefully we can backport this so this hits stable.

@bors r+

@bors
Copy link
Contributor

bors commented Feb 6, 2025

📌 Commit f1e4d94 has been approved by Nadrieril

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 6, 2025
@Nadrieril Nadrieril added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Feb 6, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 7, 2025
…fication, r=Nadrieril

Pattern Migration 2024: try to suggest eliding redundant binding modifiers

This is based on rust-lang#136475. Only the last commit is new.

This is a simpler, more restrictive alternative to rust-lang#136496, meant to partially address rust-lang#136047. If a pattern can be migrated to Rust 2024 solely by removing redundant binding modifiers, this will make that suggestion; otherwise, it uses the old suggestion of making the pattern fully explicit.

Relevant tracking issue: rust-lang#131414

`@rustbot` label A-diagnostics A-patterns A-edition-2024

r? `@Nadrieril`
@apiraino apiraino removed the I-compiler-nominated Nominated for discussion during a compiler team meeting. label Feb 7, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 7, 2025
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#134367 (Stabilize `feature(trait_upcasting)`)
 - rust-lang#135354 ([Debuginfo] Add MSVC Synthetic and Summary providers to LLDB)
 - rust-lang#135940 (Update toolstate maintainers)
 - rust-lang#135945 (Remove some unnecessary parens in `assert!` conditions)
 - rust-lang#136577 (Pattern Migration 2024: try to suggest eliding redundant binding modifiers)
 - rust-lang#136598 (Fix suggestion for `dependency_on_unit_never_type_fallback` involving closures + format args expansions)
 - rust-lang#136653 (Remove dead code from rustc_codegen_llvm and the LLVM wrapper)
 - rust-lang#136664 (replace one `.map_or(true, ...)` with `.is_none_or(...)`)

Failed merges:

 - rust-lang#136193 (Implement pattern type ffi checks)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 7, 2025
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#134367 (Stabilize `feature(trait_upcasting)`)
 - rust-lang#135940 (Update toolstate maintainers)
 - rust-lang#135945 (Remove some unnecessary parens in `assert!` conditions)
 - rust-lang#136577 (Pattern Migration 2024: try to suggest eliding redundant binding modifiers)
 - rust-lang#136598 (Fix suggestion for `dependency_on_unit_never_type_fallback` involving closures + format args expansions)
 - rust-lang#136653 (Remove dead code from rustc_codegen_llvm and the LLVM wrapper)
 - rust-lang#136664 (replace one `.map_or(true, ...)` with `.is_none_or(...)`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 20f9e97 into rust-lang:master Feb 7, 2025
6 checks passed
@rustbot rustbot added this to the 1.86.0 milestone Feb 7, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 7, 2025
Rollup merge of rust-lang#136577 - dianne:simple-pat-migration-simplification, r=Nadrieril

Pattern Migration 2024: try to suggest eliding redundant binding modifiers

This is based on rust-lang#136475. Only the last commit is new.

This is a simpler, more restrictive alternative to rust-lang#136496, meant to partially address rust-lang#136047. If a pattern can be migrated to Rust 2024 solely by removing redundant binding modifiers, this will make that suggestion; otherwise, it uses the old suggestion of making the pattern fully explicit.

Relevant tracking issue: rust-lang#131414

``@rustbot`` label A-diagnostics A-patterns A-edition-2024

r? ``@Nadrieril``
@eric-seppanen
Copy link

Some field data, for anyone considering the beta backport:

In a workspace with ~4000 source files, the rust-2024-incompatible-pat lint fires in 17 places. Of those, 9 are instances of the form Variant(ref x) that were being "fixed" to &Variant(ref x) but after this change are changed to Variant(x).

I find this a meaningful improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-edition-2024 Area: The 2024 edition A-patterns Relating to patterns and pattern matching beta-nominated Nominated for backporting to the compiler in the beta channel. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants