`#[rustfmt::skip]` attribute skips extra lines
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Summary
Kind of the opposite to https://github.com/rust-lang/rustfmt/issues/6954 (but I think they need to be addressed together).
The cause is, when calculating the skip range we use:
- The line after the attributes (the start)
- The count of lines the formatter saw (the end)
But when the formatter splits one line into several, the count of lines visited increases, so the skip range extends much further.
I tried to format this code:
fn foo() {
some.very().very().very().very().very().very().long().method().call().chain().that().will().wrap();
println!("This is a very long line, it will easily go past max_width. PADDING ");
#[rustfmt::skip]
println!("This is a very long line, it will easily go past max_width. PADDING ");
}
Expected behavior
- The very long method chain is split up
- There is an error because the first
printlnline exceeds the line length limit - There's no error for the second
printlnline, it exceeds the length limit but is skipped
Actual behavior
The second point above does not hold, there is no error about the extra long line
Configuration
N/A: run with any empty config
rustfmt cli options used (if applicable):
$ rustfmt --config max_width=70 --config error_on_unformatted=true --config error_on_line_overflow=true
Reproduction Steps
Run the rustfmt command above on the file contents also above
$ rustfmt --version
rustfmt 1.9.0-nightly (eff8269f79 2026-07-18)
# also reproduced on recent dev build
$ cargo run --quiet --bin rustfmt -- --version
rustfmt 1.10.0-nightly (138684c552 2026-08-25)
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.
Research direction
Start in src/visitor.rs at the linked skip-range calculation and reproduce the issue with the rustfmt command and Rust snippet from the report. Trace how wrapped lines affect the formatter's visited-line count. Done means the unskipped long line still produces an error while the #[rustfmt::skip] line does not.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 75/100