Skip to content

Rustfmt duplicates attributes on expressions #3509

New issue

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

By clicking “No 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? No Sign in to your account

Closed
omerbenamram opened this issue Apr 14, 2019 · 0 comments · Fixed by #3510
Closed

Rustfmt duplicates attributes on expressions #3509

omerbenamram opened this issue Apr 14, 2019 · 0 comments · Fixed by #3510
Labels
bug Panic, non-idempotency, invalid code, etc.

Comments

@omerbenamram
Copy link

omerbenamram commented Apr 14, 2019

Hello!
I'm experiencing this behavior:

using rustfmt on:

pub enum MyEnum {
    Option1,
}

fn main() {
    match MyEnum {
        MyEnum::Option1 if cfg!(target_os = "windows") =>
            #[cfg(target_os = "windows")]{
                1
        }
    }

    ()
}

yields:

pub enum MyEnum {
    Option1,
}

fn main() {
    match MyEnum {
        MyEnum::Option1 if cfg!(target_os = "windows") =>
        #[cfg(target_os = "windows")]
        #[cfg(target_os = "windows")]
        {
            1
        }
    }

    ()
}

I have seen #3410 and #3313, but I'm not sure it's the same problem, since I'm running the latest nightly (rustfmt 1.2.0-nightly (09940a70 2019-03-27)) and it seems to still exist.
I'm also aware that this syntax is considered experimental, so mileage may vary, but still seems like a bug in rustfmt.

Thanks again for the awesome work :)

@omerbenamram omerbenamram changed the title Rustfmt duplicates attributes n expressions Rustfmt duplicates attributes on expressions Apr 14, 2019
@topecongiro topecongiro added the bug Panic, non-idempotency, invalid code, etc. label Apr 14, 2019
topecongiro added a commit to topecongiro/rustfmt that referenced this issue Apr 14, 2019
No Sign up for free to join this conversation on GitHub. Already have an account? No 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