Skip to content

buggy formatting on expression attributes with comments #5871

@meetmangukiya

Description

@meetmangukiya

Example code:

#![feature(stmt_expr_attributes)]
fn main() {
    let some_function_call = || {};

    let filter = || {
        (
            // comment
            #[allow(clippy::disallowed_methods)]
            some_function_call()
        )
    };
}

Everytime you format it it replicates the attribute and doubles it:

#![feature(stmt_expr_attributes)]
fn main() {
    let some_function_call = || {};

    let filter = || {
        (
            // comment
            #[allow(clippy::disallowed_methods)]
            #[allow(clippy::disallowed_methods)]
            some_function_call()
        )
    };
}

Version: rustfmt 1.6.0-nightly (39f42ad9 2023-07-19)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-commentsArea: commentsC-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICE

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions