Skip to content

Match arm pattern formatting exceeds the maximum line length #6697

@Jarcho

Description

@Jarcho

Formatting the following code

impl Foo {
    fn foo() {
        loop {
            match (pat, self.next_token.kind) {
                (_, TokenKind::Whitespace)
                | (Pat::AnyComment, TokenKind::BlockComment { terminated: true, .. } | TokenKind::LineComment { .. }) => {
                    self.step()
                },
            }
        }
    }
}

Results in:

error[internal]: line formatted, but exceeded maximum width (maximum: 120 (see `max_width` option), found: 122)
   --> \\?\F:\rust-clippy-jj\clippy_dev\src\parse\cursor.rs:104:104:121
    |
104 |                 | (Pat::AnyComment, TokenKind::BlockComment { terminated: true, .. } | TokenKind::LineComment { .. }) => {
    |                                                                                                                         ^^
    |

Config is:

max_width = 120
error_on_line_overflow = true

Making the offending line one character longer causes it to be correctly formatted across multiple lines.

Version:

rustfmt 1.8.0-nightly (4645a79881 2025-09-17)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-matchesArea: match arms, patterns, blocks, etcI-max-widthIssue: internal error; line formatted, but exceeded maximum widthSO-max_widthStable option: max_width

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions