rustfmt requires two runs to converge on contrived input
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
fn test(input: Foo) {
match input {
Foo::Bar => {
;
Baz {
field: 0
}
}
}
}
Given this admittedly contrived input, running rustfmt once removes the semicolon. Running it a second time removes the braces for the match body.
I don't know if rustfmt has a rule about being idempotent, but it certainly would surprise me to regularly encounter situations where I have to manually run it to a fixed point.
Tested in the playground, 1.8.0-stable (2024-11-26 90b35a6239).
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 reproducing the supplied Rust input with rustfmt and comparing the first and second outputs. Trace the formatter handling for match arms, semicolon removal, and brace removal; done means formatting reaches the same result in one run while preserving valid Rust formatting behavior.
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
- 45/100