rustfmt icon indicating copy to clipboard operation
rustfmt copied to clipboard

wrap_comments=true can add a space to already properly formatted comments

Open ahl opened this issue 6 months ago • 1 comments

// rustfmt-wrap_comments: true

/// ```xxx```
///
/// xxx
pub struct X;
$ rustfmt --check --config=wrap_comments=true <tests/source/issue-xxx.rs
Diff in <stdin>:1:
 // rustfmt-wrap_comments: true

 /// ```xxx```
-///
+///
 /// xxx
 pub struct X;

error[internal]: left behind trailing whitespace
 --> <stdin>:4:4:4
  |
4 | ///
  |    ^
  |
  = note: set `error_on_unformatted = false` to suppress the warning against comments or string literals

warning: rustfmt has failed to format. See previous 1 errors.

ahl avatar May 24 '25 03:05 ahl

I think this might be related to https://github.com/rust-lang/rustfmt/issues/5421 or even a duplicate of that issue. My guess is that ```xxx``` is incorrectly getting interpreted as the start of a markdown code block.

ytmimi avatar Jun 02 '25 18:06 ytmimi