Skip to content

rustfmt removes attributes on parameters of fn types #6607

@ChayimFriedman2

Description

@ChayimFriedman2

I formatted this code:

struct Foo {
    v: fn(#[cfg(false)] i32),
}

Playground.

I expected to see this happen: rustfmt keeps the attribute, it shouldn't change the meaning of the program.

Instead, this happened: rustfmt turns this into:

struct Foo {
    v: fn(i32),
}

@rustbot label +A-rustfmt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions