Skip to content

struct_field_attributes disappear when running rustfmt #1535

Closed
@rbtying

Description

@rbtying

rust-lang/rust#38814 added struct_field_attributes to Rust, however,

the file:

#![feature(struct_field_attributes)]

struct Foo {
    bar: u64,

    #[cfg(test)]
    qux: u64,
}

fn do_something() -> Foo {
    Foo {
        bar: 0,

        #[cfg(test)]
        qux: 1
    }
}

fn main() {
    do_something();
}

gets formatted to

#![feature(struct_field_attributes)]

struct Foo {
    bar: u64,

    #[cfg(test)]
    qux: u64,
}

fn do_something() -> Foo {
    Foo { bar: 0, qux: 1 }
}

fn main() {
    do_something();
}

which does not compile (it's lost the #[cfg(test)] in do_something)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPanic, non-idempotency, invalid code, etc.good first issueIssues up for grabs, also good candidates for new rustfmt contributors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions