Skip to content

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

@ahl

Description

@ahl
Contributor
// 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.

Activity

ytmimi

ytmimi commented on Jun 2, 2025

@ytmimi
Contributor

I think this might be related to #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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ahl@ytmimi

        Issue actions

          wrap_comments=true can add a space to already properly formatted comments · Issue #6569 · rust-lang/rustfmt