Skip to content

format_code_in_doc_comments adds trailing whitespace on the leading empty line #6015

@stepancheg

Description

@stepancheg

Input (no trailing whitespaces anywhere):

/// Hi
///
/// ```text
///
/// rrr
///
/// xxx
/// ```
fn foo() {
}
rustfmt +nightly --config format_code_in_doc_comments=true

outputs:

/// Hi
///
/// ```text
///<WHITESPACE>
/// rrr
///
/// xxx
/// ```
fn foo() {}
image

Note whitespace is inserted only on the first empty line.

rustfmt 1.7.0-nightly (ca663b06 2024-01-08)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-commentsArea: commentsI-trailing-whitespaceIssue: internal error; left behind trailing whitespaceonly-with-optionRequires a non-default option value to reproduce

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions