Skip to content

Trailing blank line removal in doc comments is not idempotent #6168

Open
@overhacked

Description

@overhacked

Description

Only one trailing, blank line in a comment is removed each time rustfmt is run, so formatting is not idempotent if multiple trailing, blank lines are present. Blank line removal is enabled by any of the normalize_comments, wrap_comments, or format_code_in_doc_comments (for doc comments only) configuration options. All these features are unstable, so this affects nightly only (as of 2024-05-21 / d5f1200)

This issue is fixed by PR #6163.

Reproduction

Given

rustfmt.toml

wrap_comments = true

code.rs

//! I am a humble module doc comment with many trailing lines
//!
//!

Run

# rustfmt code.rs

Expected

code.rs

//! I am a humble module doc comment with many trailing lines

Actual

code.rs

//! I am a humble module doc comment with many trailing lines
//!

Metadata

Metadata

Assignees

No one assigned

    Labels

    a-commentsbugPanic, non-idempotency, invalid code, etc.only-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