`/* ... */` comments at the end of a block can be rewritten to `/* ... //` with no terminating `*/`
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start from the separate comment handling path in close_block, which the report says was not covered by PR 7217, and reproduce with the snippet using wrap_comments=true and normalize_comments=true. Check how a trailing /* ... */ block comment is rewritten to // lines and make sure the closing */ is never dropped. Done when the snippet formats to the expected output and the output compiles.
索引モデルが issue の本文から書いたものです。
説明
With wrap_comments or normalize_comments, a /* ... */ trailing block comment at the end of a block can be rewritten to /* ... // without a closing */, resulting in invalid code that doesn't compile. This is the same issue as https://github.com/rust-lang/rustfmt/issues/6339, but there's a separate comment handling path in close_block that didn't get fixed in https://github.com/rust-lang/rustfmt/pull/7217.
Note that this only occurs on SE 2024 and later. The issue won't happen on SE 2015.
Summary
I tried to format this code:
fn block_comment() {
let x = 1; /* first
* second
*/
}
I tried to format with wrap_comments: true and normalize_comments: true.
Expected behavior
fn block_comment() {
let x = 1; // first
// second
}
Actual behavior
fn block_comment() {
let x = 1; /* first
// second
}
Configuration
Tested against main commit 0acb4720feb76e209e7c61f0133efbe628a4641b.
rustfmt cli options used (if applicable):
cargo run --bin rustfmt -- --style-edition 2024 --config wrap_comments=true test.rs
cargo run --bin rustfmt -- --style-edition 2024 --config normalize_comments=true test.rs
- 主要言語
- 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 日以内に返信