Formatting does not work with match arm having mixed OR clauses and comments
Open
Nobody has claimed this yet.
A-comments
A-matches
P-low
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Related to #6060 and #6044. For the below snippet, rustfmt does nothing at all:
enum Foo {
A,
B,
C,
D,
}
fn main() {
let foo = Foo::A;
match foo {
// Here is a comment
Foo::A |
// And another one
Foo::B |
// Hey look! There's another one
Foo::C |
// That's a lot of comments
Foo::D => {}
}
}
If someone more knowledgeable about rustfmt internals can please confirm that this is a solvable bug, I'd be happy to contribute the fix.
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 with the Rust snippet in the issue and run rustfmt on it to confirm that mixed OR-pattern clauses with comments remain unchanged. Trace the formatting path for match arms and comments, then verify that the example is formatted while preserving its comments and meaning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 64/100