Skip to content

rustfmt::skip attribute gets duplicated if preceded by a comment #3974

Closed
@oli-obk

Description

@oli-obk
fn emulate_foreign_item() {
    match link_name {
        // A comment here will duplicate the attribute
        #[rustfmt::skip]
        | "pthread_mutexattr_init"
        | "pthread_mutexattr_settype"
        | "pthread_mutex_init"
        => {}
    }
}

gets rustformatted to

fn emulate_foreign_item() {
    match link_name {
        // A comment here will duplicate the attribute
        #[rustfmt::skip]
        #[rustfmt::skip]
        | "pthread_mutexattr_init"
        | "pthread_mutexattr_settype"
        | "pthread_mutex_init"
        => {}
    }
}

if you continue rustfmting, the attributes get duplicated all the time, so you have exponential growth of attributes 😆

Metadata

Metadata

Assignees

No one assigned

    Labels

    a-commentsbugPanic, non-idempotency, invalid code, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions