Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Erasing inner attributes in blocks #3592

Closed
bepvte opened this issue May 28, 2019 · 0 comments · Fixed by #3593
Closed

Erasing inner attributes in blocks #3592

bepvte opened this issue May 28, 2019 · 0 comments · Fixed by #3593
Labels
bug Panic, non-idempotency, invalid code, etc.

Comments

@bepvte
Copy link

bepvte commented May 28, 2019

#![allow(unused)]
struct Biz {
    field: usize,
}

fn r() -> (Biz, ()) {
    (
        Biz{
            #![cfg(unix)]
            field: 9,
        },
        Biz{
            #![cfg(not(unix))]
            field: 200,
        },
        ()
    )
}
fn main() {
    println!("Hello, world!");
}

(Playground)

Running rustfmt on this code erases the #![cfgs], and creates an invalid return type. I am not sure if the tuple is necessary but I had one when I first encountered the bug.

This occurs no matter how many fields are in the struct or block.

This seems similar to #2073, but since that issue is so old and marked as solved I felt it would be better to open a new one.

rustfmt 1.2.2-nightly (5274b49 2019-04-24)

@scampi scampi added the bug Panic, non-idempotency, invalid code, etc. label May 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants