rust-lang / rust-lang/rust-analyzer
missing-match-arm's fix duplicates existing variant when matching on a reference
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
rust-analyzer version: rust-analyzer 1.95.0 (5980761 2026-04-14)
rustc version: rustc 1.95.0 (59807616e 2026-04-14)
editor or extension: VSCode, extension version 0.3.2878
relevant settings: none
repository link (if public, optional): none
code snippet to reproduce:
enum Enum {
Old {},
New,
}
fn foo(e: &Enum) {
match e {
&Enum::Old {} => {}
};
}
This should be suggesting:
match e {
&Enum::Old {} => {}
Enum::New => todo!(),
};
but it suggests:
match e {
&Enum::Old {} => {}
Enum::Old { } => todo!(),
Enum::New => todo!(),
};
whose second arm (Enum::Old { }) is unreachable.
The same happens if Enum::Old is a tuple variant, and if it has fields -- this is just a minimization.
@rustbot claim
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with rust-analyzer's missing-match-arm assist and reproduce the issue with the Rust snippet in the report, focusing on matching through a reference. Done means the assist suggests only the missing Enum::New arm, without duplicating the existing Enum::Old arm; add or update coverage for the shown case and run the relevant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100