rust-lang / rustfmt

Format Rust code
https://rust-lang.github.io/rustfmt/
Apache License 2.0
6.05k stars 888 forks source link

Doc comment whitespace is incrementally removed #6370

Closed johnbchron closed 1 month ago

johnbchron commented 1 month ago

When module doc comments have more than 1 extra line of trailing whitespace, it isn't removed fully in 1 run; it takes 2 runs.

echo '//! Foo\n//!\n//!' | rustfmt           # yields "//! Foo\n//!"
echo '//! Foo\n//!\n//!' | rustfmt | rustfmt # yields "//! Foo"
$ rustfmt --version
rustfmt 1.7.1-nightly (9c01301c 2024-09-05)

Please note that I have taken no steps to determine the extent of this issue, or related affected areas. I'm also not certain that this is not the intended behavior - I'm just guessing.

ytmimi commented 1 month ago

Thanks for the report. This is a duplicate of https://github.com/rust-lang/rustfmt/issues/6168