Skip to content

rustfmt::skip sometimes ignored when using error_on_line_overflow and error_on_unformatted #6954

Description

@ilyvion

Summary

I tried to format this code:

impl Blah {
    #[rustfmt::skip]
    fn foo() {
        {
            {
                select! {
                    _ = bar() => {
                        info!(
                            "WebAuthn challenge cache cleanup: __ registration, __ login, __ 2FA, __ email-change entries remaining",
                        );
                    },
                }
            }
        }
    }
}

(I tried to make it as small as possible without making the error go away)

Expected behavior

I expected to see this happen: Since I have rustfmt::skip, rustfmt should not concern itself with this function.

Actual behavior

Instead, this happened:

❯ rustup run nightly -- rustfmt foo.rs 
error[internal]: line formatted, but exceeded maximum width (maximum: 100 (see `max_width` option), found: 133)
 --> /home/alex/Documents/Projects/foo.rs:9:9:101
  |
9 | ...                   "WebAuthn challenge cache cleanup: __ registration, __ login, __ 2FA, __ email-change entries remaining",
  |                                                                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: set `error_on_unformatted = false` to suppress the warning against comments or string literals

Configuration

rustfmt configuration file (e.g. rustfmt.toml, if applicable):

edition = "2024"
error_on_line_overflow = true
error_on_unformatted = true

Reproduction Steps

Run rustfmt on the code above with the configuration above.

Meta

rustfmt --version:

rustfmt 1.9.0-nightly (bd08c9e718 2026-06-25)

Metadata

Metadata

Labels

C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEneeds-triageThis issue or PR needs triaging to determine its status. Remove label once sufficiently triaged.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions