A long string in a match arm breaks formatting for the whole match expression
Open
Nobody has claimed this yet.
1x-backport:pending
A-matches
C-bug
E-help-wanted
I-max-width
P-low
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Describe the bug
If an arm of a match expression contains a string with >= 87 characters, formatting fails on the whole match
To Reproduce
match 0 {
0 => {"hello"} 1 => { ""}
_ => {"veeeeeeeeeeery loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong string"}
};
Expected behavior
match 0 {
0 => "hello",
1 => "",
_ => {
"veeeeeeeeeeery loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong string"
}
};
If the third string is less than 86 characters, formatting works as expected.
Meta
- rustfmt version: rustfmt 1.4.36-stable (7de6968 2021-02-07)
- From where did you install rustfmt?: rustup
- How do you run rustfmt:
rustfmt,cargo-fmt, and rust-analyzer formatting in VSCode.
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 rustfmt on the match-expression reproduction in the issue and inspect the match-arm formatting path that handles long strings. Done means the provided example formats successfully, including the long-string arm, without breaking formatting for the whole match expression; add a regression test if the existing test layout identifies a suitable location.
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
- 38/100