rustfmt formats different arms of the same match inconsistently
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
The big rustc format made some code I care about much less readable. Here's an example:
- ref mut local @ LocalValue::Live(Operand::Immediate(_)) |
- ref mut local @ LocalValue::Uninitialized => {
- Ok(Ok(local))
- }
+ ref mut local @ LocalValue::Live(Operand::Immediate(_))
+ | ref mut local @ LocalValue::Uninitialized => Ok(Ok(local)),
The actual code running here for this branch got moved onto the same line as the last line of a pattern. That makes it quite hard to visually identify this code -- compared to the old version of the code, the visual separation of pattern and code got lost.
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
Begin by reproducing the match-arm example from the issue and inspect rustfmt's handling of patterns, arms, and inline bodies. Compare the output with the desired formatting shown in the diff; done means the pattern and arm body remain visually distinct without regressing other match formatting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100