Trailing whitespace of match arm not stripped when the body expression is very long and follows in the second line
Open
Nobody has claimed this yet.
A-comments
A-matches
I-trailing-whitespace
P-low
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Minimal reproducer:
fn this_is_a_very_long_name_to_lengthen_the_expression_so_that_rustfmt_does_not_join_the_lines() {}
fn main() {
match () {
_ => /* (whitespace here) => */
this_is_a_very_long_name_to_lengthen_the_expression_so_that_rustfmt_does_not_join_the_lines(),
}
}
Output:
error[internal]: left behind trailing whitespace
--> stdin:5:5:40
|
5 | _ => /* (whitespace here) => */
| ^
|
warning: rustfmt has failed to format. See previous 1 errors.
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 running the minimal Rust reproducer through rustfmt and confirm the trailing-whitespace diagnostic at stdin:5. Trace the match-arm formatting path responsible for the second-line body expression, then verify that formatting no longer leaves whitespace after the comment marker and that the reproducer completes without the internal error.
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
- Clearly specified
- Newbie friendliness
- 48/100