`control_brace_style` and `match_arm_blocks` incompatability
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Coming from #3373.
There seems to be an issue which sometimes occurs whenever these two options are present at the same time in a rustfmt configuration:
control_brace_style = 'AlwaysNextLine'
match_arm_blocks = false
For example, take the following snippet from a cargo new main.rs file:
fn main() {
let fooooooo = "100000000000000000000000";
let _bar = match fooooooo {
"100000000000000000000000" => fooooooo.len() == 1 && fooooooo.contains("222222222222222222"),
_ => unreachable!("Should not happen"),
};
}
Running cargo fmt on this code results in the following error:
error[internal]: left behind trailing whitespace
--> /home/iron-e/Programming/ACTIVE/rustfmt-error-example/src/main.rs:6:6:1
|
6 |
| ^^^^^^^^
|
warning: rustfmt has failed to format. See previous 1 errors.
It seems that line 4 of the snippet being >=95 characters long has something to do with it. The rest of the code is just filler to get it to compile.
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
Reproduce the issue using the provided main.rs snippet and the rustfmt configuration with control_brace_style = 'AlwaysNextLine' and match_arm_blocks = false; start by running cargo fmt. Compare behavior with shorter match-arm lines and identify the interaction that leaves trailing whitespace. Done means cargo fmt formats the example without the internal trailing-whitespace 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
- Mostly clear
- Newbie friendliness
- 38/100