`#[rustfmt::skip]` attribute skips extra lines

オープン
#7,076 コメント 4 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
75/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust
領域
tooling

調査の方向性

src/visitor.rs の、リンクされているスキップ範囲の計算から始め、報告にある rustfmt コマンドと Rust スニペットで問題を再現します。折り返された行が formatter の訪問済み行数にどのように影響するかを追跡します。スキップされていない長い行では引き続きエラーが発生し、#[rustfmt::skip] 行では発生しなければ完了です。

索引モデルが issue の本文から書いたものです。

説明

A-rustfmt::skip A-whitespace C-bug E-hard E-medium

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
  1. The very long method chain is split up
  2. There is an error because the first println line exceeds the line length limit
  3. There's no error for the second println line, 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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

rust-lang/rustfmt のほかの issue

rust-lang/rustfmt の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。