Skip to content

rustfmt removes comment between doc comment and generic params #5320

Closed
@ytmimi

Description

@ytmimi

This was an issue discovered when implementing a fix for #5122 in PR #5124 (comment). The issue is reproducible on rustfmt 1.4.38-nightly (8572b343 2022-04-24) and uses the rustfmt.toml defined in the rustfmt repo.

# rustfmt.toml
error_on_line_overflow = true
error_on_unformatted = true
version = "Two"

This input:

// Non-doc pre-comment of Foo
/// doc of Foo
// Non-doc post-comment of Foo
struct Foo<
    // Non-doc pre-comment of 'a
    /// doc of 'a
    // Non-doc post-comment of 'a
    'a,
    // Non-doc pre-comment of T
    /// doc of T
    // Non-doc post-comment of T
    T,
    // Non-doc pre-comment of N
    /// doc of N
    // Non-doc post-comment of N
    const N: item,
>;

Gets formatted as follows:

// Non-doc pre-comment of Foo
/// doc of Foo
// Non-doc post-comment of Foo
struct Foo<
    // Non-doc pre-comment of 'a
    /// doc of 'a
    'a,
    // Non-doc pre-comment of T
    /// doc of T
    T,
    // Non-doc pre-comment of N
    /// doc of N
    const N: item,
>;

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