rust-lang / rust-lang/rust-analyzer
fill match arms for struct-like enum variant patterns introduce unused variables
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Given an enum like:
enum Foo {
A(X)
B{y:Y,z:Z}
}
Fill match arms seems to
match foo {
A(_) => todo!(),
B{y, z} => todo!(),
}
The y's and z's, in my experience tend to produce a lot of unused variable warnings.
the alternative B{y:_y, z:_z} => todo!(), is very verbose and seems like adding stuff that will only need to be removed.
One option which seems like it might be viable is filling with B{..} => todo!(),
Eventually there could be an assist for "Fill structure fields for .."
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 by locating the match-arm fill assist entry point and its existing tests for enum patterns. Compare generated arms for tuple-like and struct-like variants, then make the result avoid unnecessary bindings while preserving complete pattern coverage; done means the relevant assist tests cover the proposed .. form without unused-variable warnings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100