rust-lang / rust-lang/rust-analyzer
Let "sort variants alphabetically" assist apply to `match` statements
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
I have an enum with an increasingly large number of variants that I'd like to sort alphabetically so that they don't get entirely out of hand.
Rust-analyzer already supports doing this for the enum declaration. However, I also have multiple match statements that operate on that enum, and I'd like to sort them in the same order as enum variants.
I can do it with a shell script in simple cases but anything even slightly more complex requires parsing Rust code, so I'd really prefer for rust-analyzer to handle it.
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 rust-analyzer’s existing assist for sorting enum variants and trace how it identifies their order. Then inspect how match statements and complex patterns are represented; done means the assist can sort match arms consistently with the enum declaration without relying on a separate Rust parser.
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