rustfmt gives legal length comments a ragged edge in argument lists

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

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

@matthewhughes934 がすでに取り組んでいます。

2026年10月9日 から。

評価

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

調査の方向性

Start by reproducing the reported output with the nested Rust argument-list example and the shown rustfmt configuration (wrap_comments = true, comment_width = 100). Read rustfmt's comment-wrapping implementation and its tests for comments in argument lists; the issue does not name specific files. Done means formatting preserves the reported legal-length comment without producing the ragged reflow shown.

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

説明

A-comments C-bug UO-comment_width UO-wrap_comments

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

fn main() {
    if true {
        if true {
            if true {
                if true {
                    if true {
                        if true {
                            foo(
                                // Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
                                // eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
                                // enim ad minim veniam, quis nostrud exercitation ullamco laboris
                                // nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
                                // reprehenderit in voluptate velit esse cillum dolore eu fugiat
                                // nulla pariatur.
                                1,
                            );
                        }
                    }
                }
            }
        }
    }
}

The comment shouldn't be changed by rustfmt, but it does change it, giving it a very ragged edge:

> cat config.toml
wrap_comments = true
comment_width = 100

> rustfmt +nightly --version
rustfmt 1.11.0-nightly (1d81eb4ad9 2026-10-07)

> rustfmt +nightly --emit=stdout --config-path config.toml foo.rs
fn main() {
    if true {
        if true {
            if true {
                if true {
                    if true {
                        if true {
                            foo(
                                // Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
                                // eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
                                // enim ad minim veniam, quis nostrud exercitation ullamco laboris
                                // nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
                                // in reprehenderit in voluptate
                                // velit esse cillum dolore eu fugiat
                                // nulla pariatur.
                                1,
                            );
                        }
                    }
                }
            }
        }
    }
}
主要言語
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 を短くまとめたダイジェスト。