Pattern Migration 2024: suggest nicer patterns by dianne · Pull Request #136496 · rust-lang/rust

@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 3, 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`

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``

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``

workingjubilee added a commit to workingjubilee/rustc that referenced this pull request

Feb 16, 2025
…tion, r=Nadrieril

Pattern Migration 2024: clean up and comment

This follows up on rust-lang#136577 by moving the pattern migration logic to its own module, removing a bit of unnecessary complexity, and adding comments. Since there's quite a bit of pattern migration logic now (and potentially more in rust-lang#136496), I think it makes sense to keep it separate from THIR construction, at least as much as is convenient.

r? `@Nadrieril`

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Feb 17, 2025
…tion, r=Nadrieril

Pattern Migration 2024: clean up and comment

This follows up on rust-lang#136577 by moving the pattern migration logic to its own module, removing a bit of unnecessary complexity, and adding comments. Since there's quite a bit of pattern migration logic now (and potentially more in rust-lang#136496), I think it makes sense to keep it separate from THIR construction, at least as much as is convenient.

r? ``@Nadrieril``

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Feb 17, 2025
Rollup merge of rust-lang#136817 - dianne:clean-and-comment-pat-migration, r=Nadrieril

Pattern Migration 2024: clean up and comment

This follows up on rust-lang#136577 by moving the pattern migration logic to its own module, removing a bit of unnecessary complexity, and adding comments. Since there's quite a bit of pattern migration logic now (and potentially more in rust-lang#136496), I think it makes sense to keep it separate from THIR construction, at least as much as is convenient.

r? ``@Nadrieril``

@dianne

@dianne

…vements

The following commits are the possible future improvements.
This will let us propagate changes to the default binding mode when
suggesting adding `&` patterns.
This lets us revise the suggestion on-the-fly as we discover which
reference patterns and binding modifiers are necessary vs. which may be
omitted.
A slight refactor: we'll always want to pass the mutability in to
`push_deref` to determine the default binding mode when a pattern is
removed, so this eliminates the redundancy of having both that and the
user's dbm as separate arguments.
This doesn't yet respect whether patterns are from macro expansions, so
it may try to suggest changes within an expansion (leading to a test
failure).
This fixes the regression in the previous commit.

@dianne

@dianne

@dianne dianne deleted the beautify-pat-migration-output branch

April 17, 2025 21:53