`#[rustfmt::skip]` attribute skips extra lines
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
src/visitor.rs の、リンクされているスキップ範囲の計算から始め、報告にある rustfmt コマンドと Rust スニペットで問題を再現します。折り返された行が formatter の訪問済み行数にどのように影響するかを追跡します。スキップされていない長い行では引き続きエラーが発生し、#[rustfmt::skip] 行では発生しなければ完了です。
索引モデルが issue の本文から書いたものです。
説明
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)
- 主要言語
- Rust
- スター
- 7.1k
- フォーク
- 1.2k
- 平均マージ
- 1日 4時間
- マージ済み PR(30日)
- 20
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rust-lang/rustfmt のほかの issue
-
A-config C-bug SO-print-config
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
-
A-Unicode C-bug P-low
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
rust-lang/rustfmt#7210 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
-
A-imports C-bug E-hard I-non-idempotency X-impacts-stable-default-format
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
rust-lang/rustfmt#7173 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
A-comments C-bug only-with-option UO-indent_style
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Fix `first_line_width` to be tab-aware再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンA-tabs A-whitespace C-bug SO-hard_tabs
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
rust-lang/rustfmt の issue をすべて見る
似ている issue
-
bug P2
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
bug core-lang
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Windows microphone listing treats words in a device name as DirectShow labels対応中かも @Sujal-chaudhary が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
clipy-recorder/clipy#447 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
nightly-cleanup
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
max-sixty/worktrunk#4939 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信