Formatter takes two runs to fully format comment after match arm
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Input
fn main() {
match 1 {
_ => {},
// hello!
}
}
Output
fn main() {
match 1 {
_ => {}
// hello!
}
}
Expected output
fn main() {
match 1 {
_ => {} // hello!
}
}
You get the expected output if you run it a second time. This means that the formatter needs multiple runs to fully finish formatting the code. That does not seem right. I want to be able to trust the formatter in that it will do it all in one run so that I never get into the habit of running it twice each time just to be 100% sure. Therefore I report this as a bug.
Meta
- rustfmt version: rustfmt 1.4.30-stable (8c6769d 2021-01-18)
- From where did you install rustfmt?: rustup
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 match-arm example with the listed rustfmt version, then trace the formatter's handling of comments after match arms. Done means one formatting run produces the expected output and a regression test covers the example.
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
- Clearly specified
- Newbie friendliness
- 35/100