Skip to content

Comments

Fix not applicable on ambiguous ident pat for merge_match_arms#21411

Open
A4-Tacks wants to merge 1 commit intorust-lang:masterfrom
A4-Tacks:merge-ambig-ident-pat
Open

Fix not applicable on ambiguous ident pat for merge_match_arms#21411
A4-Tacks wants to merge 1 commit intorust-lang:masterfrom
A4-Tacks:merge-ambig-ident-pat

Conversation

@A4-Tacks
Copy link
Member

@A4-Tacks A4-Tacks commented Jan 6, 2026

Example

enum X {
    A,
    B,
    C,
}
use X::*;
fn main() {
    match A {
        $0A => todo!(),
        B => todo!(),
        C => todo!(),
    }
}

Before this PR

Assist not applicable

After this PR

enum X {
    A,
    B,
    C,
}
use X::*;
fn main() {
    match A {
        A | B => todo!(),
        C => todo!(),
    }
}

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 6, 2026
Example
---
```rust
enum X {
    A,
    B,
    C,
}
use X::*;
fn main() {
    match A {
        $0A => todo!(),
        B => todo!(),
        C => todo!(),
    }
}
```

**Before this PR**

Assist not applicable

**After this PR**

```rust
enum X {
    A,
    B,
    C,
}
use X::*;
fn main() {
    match A {
        A | B => todo!(),
        C => todo!(),
    }
}
```
@A4-Tacks A4-Tacks force-pushed the merge-ambig-ident-pat branch from 7fff6d9 to 8072f1a Compare January 6, 2026 10:20
@A4-Tacks A4-Tacks changed the title Fix not applicable on ambigious ident pat for merge_match_arms Fix not applicable on ambiguous ident pat for merge_match_arms Jan 9, 2026
}
}
ast::Pat::IdentPat(ident_pat) => {
let has_type = ctx.sema.type_of_pat(local_pat).is_some();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a pattern without a type? This is weird. Every pattern has a type, even binding patterns. Are you sure this code is treating the other way around, that is binding patterns, correctly?

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you sure this code is treating the other way around, that is binding patterns, correctly?

There are behavioral differences in patterns and bindings:

pattern type_of_pat type_of_binding_in_pat
None Some(Ty) None
x Some(Ty) Some(Ty)

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.

3 participants