max_width not obeyed in match arm tuple
@AsthaMishra is already working on this.
Since Sep 2, 2026.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Summary
rustfmt reformats a multi-line tuple pattern in a match arm into a single
line that exceeds max_width = 80.
I tried to format this code:
#[derive(Clone, Copy)]
enum ExampleTypeX {
VariantAlphaSampleXYZ,
VariantBetaXYZ,
}
fn demo(lhs: ExampleTypeX, rhs: ExampleTypeX) {
match (lhs, rhs) {
(
ExampleTypeX::VariantAlphaSampleXYZ,
ExampleTypeX::VariantBetaXYZ,
) => unsafe {
}
_ => {}
}
}
fn main() {}
Expected behavior
rustfmt should preserve the multi-line tuple pattern, or otherwise format the
arm so that it does not exceed max_width = 80.
Actual behavior
rustfmt rewrites it to:
fn demo(lhs: ExampleTypeX, rhs: ExampleTypeX) {
match (lhs, rhs) {
(ExampleTypeX::VariantAlphaSampleXYZ, ExampleTypeX::VariantBetaXYZ) => unsafe {
},
_ => {}
}
}
The formatted match arm is 87 columns wide, exceeding max_width = 80.
Configuration
rustfmt.toml:
max_width = 80
Reproduction Steps
-
Create a Rust file with the example above.
-
Create a
rustfmt.tomlcontaining:max_width = 80 -
Run
cargo fmt(orrustfmton the file). -
Observe that the tuple pattern in the match arm is collapsed to one line.
-
Observe that the resulting line exceeds
max_width.
Meta
rustfmt 1.8.0-stable (ed61e7d7e2 2025-11-07)
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.
Assessment
This issue has not been assessed yet.