Skip to content

struct_field_attributes disappear when running rustfmt #1535

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
rbtying opened this issue May 12, 2017 · 0 comments
Closed

struct_field_attributes disappear when running rustfmt #1535

rbtying opened this issue May 12, 2017 · 0 comments
Labels
bug Panic, non-idempotency, invalid code, etc. good first issue Issues up for grabs, also good candidates for new rustfmt contributors

Comments

@rbtying
Copy link

rbtying commented May 12, 2017

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)

@topecongiro topecongiro added the bug Panic, non-idempotency, invalid code, etc. label May 12, 2017
@nrc nrc added the good first issue Issues up for grabs, also good candidates for new rustfmt contributors label May 12, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Panic, non-idempotency, invalid code, etc. good first issue Issues up for grabs, also good candidates for new rustfmt contributors
Projects
None yet
Development

No branches or pull requests

3 participants