Skip to content

rustfmt removes empty lines between block and doc comments #1196

Closed
@nokaa

Description

@nokaa

With normalize_comments set to false, running rustfmt can lead to empty lines between a block comment and a doc comment being removed.

Here is some example code:

/// Doc comment for func1
/*fn func1() {
    let a = 5;
}*/

/// Doc comment for func2
fn func2() {
    let b = 5;
}

When rustfmt is run, the fifth line will be deleted. This line is only deleted if line 6 is a doc comment; normal and block comments work properly.
It seems that an arbitrary number of empty lines can be between the block comment and the doc comment, they will all be deleted.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions