rust-lang / rust-lang/rustfmt

`rustfmt::skip` sometimes ignored when using `error_on_line_overflow` and `error_on_unformatted`

Open
#6,954 11 comments 0 reactions 1 assignee View on GitHub

@matthewhughes934 is already working on this.

Since Aug 14, 2026.

C-feature-request UO-error_on_line_overflow UO-error_on_unformatted
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.