rust-lang / rust-lang/rust-analyzer
Reorder match arms
Open
@so1ve is already working on this.
Since Aug 4, 2026.
A-assists
A-pattern
S-actionable
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
It would be nice if there was an assist to reorder match arms based on the order of variants within the enum definition. I.e. change this:
enum Foo {
A,
B,
C,
}
fn bar(foo: Foo) -> i32 {
match foo {
Foo::C => 3,
Foo::B => 2,
Foo::A => 1,
}
}
to this:
enum Foo {
A,
B,
C,
}
fn bar(foo: Foo) -> i32 {
match foo {
Foo::A => 1,
Foo::B => 2,
Foo::C => 3,
}
}
Alternatively / in addition to this, the "fill match arms" assist could insert new arms into the correct position, rather than always placing them at the end.
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.
Assessment
This issue has not been assessed yet.