Error formatting with block comment after match scrutinee
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
I am getting error[internal]: left behind trailing whitespace on the latest stable 1.90 and nightly rustc 1.92.0-nightly (4645a7988 2025-09-17)
Minimum example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=67d8495779f0d47760dff7bea024ad75
fn main() {
match () /*x*/ {
_ => {}
}
}
The issue is caused by the comment after the scrutinee. If you remove the x (but keep the /**/), it will format, or if you replace x with any number of spaces, it formats fine.
Also fails if scrutinee is a variable name.
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
Run the linked Rust Playground example with rustfmt and confirm the trailing-whitespace error for a block comment after the match scrutinee. Compare it with the reported variants using /**/ or spaces, then trace the formatting path for match scrutinees and comments. Done means the example formats successfully without the internal error while preserving the comment.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100