Skip to content

Failure to split a line exceeding the maximum width #6202

Open
@Jarcho

Description

@Jarcho

The following code fails to format line formatted, but exceeded maximum width:

impl EarlyLintPass for NeedlessContinue {
    fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
        if let ExprKind::Loop(body, label, ..) | ExprKind::While(_, body, label) | ExprKind::ForLoop { body, label, .. } =
            &expr.kind
            && !in_external_macro(cx.sess, expr.span)
        {
            check_final_block_stmt(cx, body, label, expr.span.ctxt());
        }
    }
}

The line causing the error is the if let pattern (122 characters). Shortening the line by one character causes the same issue. Adding one character to the line causes it to be formatted correctly.

config:

max_width = 120
comment_width = 100
match_block_trailing_comma = true
wrap_comments = true
edition = "2021"
error_on_line_overflow = true
imports_granularity = "Module"
version = "Two"
ignore = ["tests/ui/crashes/ice-10912.rs"]

version: rustfmt 1.7.0-nightly (8337ba91 2024-06-12)

Metadata

Metadata

Assignees

Labels

e-max widtherror[internal]: line formatted, but exceeded maximum widthgood first issueIssues up for grabs, also good candidates for new rustfmt contributors

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions