Skip to content

fix: unnested_or_patterns FP on structs with only shorthand field pats #15343

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ada4a
Copy link
Contributor

@ada4a ada4a commented Jul 25, 2025

changelog: [unnested_or_patterns]: FP on structs with only shorthand field patterns

fixes #15219

@rustbot
Copy link
Collaborator

rustbot commented Jul 25, 2025

r? @Alexendoo

rustbot has assigned @Alexendoo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 25, 2025
@@ -325,7 +325,11 @@ fn extend_with_struct_pat(
if idx_1 == idx {
// In the case of `k`, we merely require identical field names
// so that we will transform into `ident_k: p1_k | p2_k`.
let pos = fps2.iter().position(|fp2| eq_id(fp1.ident, fp2.ident));
let pos = fps2.iter().position(|fp2| {
// Avoid `Foo { bar } | Foo { bar }` => `Foo { bar | bar }`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this comment is demonstrably correct, I think I'm still missing something -- namely, even before this PR, a pattern like this:

Foo { x, y: 1} | Foo { x, y: 2 }

still only got the suggestion to collapse the y part, even though x is technically duplicated as well.

So for some reason, the "deduplication" of x isn't suggested until there aren't any other field patterns to flag (that's also why I called the PR what I did)

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.

unnested-or-patterns union binding no longer usable
3 participants