rustfmt is off by two for comment length in vertical list pre comments

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

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

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

評価

難易度
3/5
見積もり時間
半日
初心者へのやさしさ
62/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
rust
領域
tooling

調査の方向性

Reproduce with the supplied config.toml and foo.rs, confirming that the 99-column comment is wrapped even though comment_width = 100. Then trace where rustfmt applies wrap_comments and comment_width in its comment-formatting path, paying attention to indentation and the vertical-list pre-comment case. Done means the 99-column comment stays on one line and the formatter test suite still passes.

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

説明

C-bug UO-comment_width UO-wrap_comments

Here is a Rust file with no line longer than 99 bytes, and one line equal to 99 bytes:

enum E {
    // This comment line is 99 columns long, yet rustfmt wraps it onto a second line: aaaaaaaaaaaaa
    A,
}

The comment shouldn't be changed by rustfmt, but it does change it:

> cat config.toml
wrap_comments = true
comment_width = 100

> rustfmt +nightly --version
rustfmt 1.12.0-nightly (bdf712ee87 2026-11-21)

> rustfmt +nightly --emit=stdout --config-path config.toml foo.rs
enum E {
    // This comment line is 99 columns long, yet rustfmt wraps it onto a second line:
    // aaaaaaaaaaaaa
    A,
}

(This is similar to #7258, but I've filed it separately because I suspect it has a different root cause.)

主要言語
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 を短くまとめたダイジェスト。