Skip to content

#[cfg] does not filter struct fields or enum variants #11085

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

Closed
huonw opened this issue Dec 20, 2013 · 0 comments · Fixed by #11093
Closed

#[cfg] does not filter struct fields or enum variants #11085

huonw opened this issue Dec 20, 2013 · 0 comments · Fixed by #11093

Comments

@huonw
Copy link
Member

huonw commented Dec 20, 2013

struct Foo {
    #[cfg(foo)]
    a: int,
    #[cfg(not(foo))]
    a: uint
}

/*
enum Bar {
    #[cfg(bar)]
    Baz(int),
    #[cfg(not(bar))]
    Baz(uint)
}
*/

fn main() {}
$ rustc cfg-variant-fields.rs
cfg-variant-fields.rs:5:4: 5:11 error: field `a` is already declared
cfg-variant-fields.rs:5     a: uint
                            ^~~~~~~
cfg-variant-fields.rs:3:4: 3:10 note: Previously declared here
cfg-variant-fields.rs:3     a: int,
                            ^~~~~~

Uncommenting the enum gives a similar error.

flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 31, 2023
…ogiq

Rewrite [`tuple_array_conversions`]

Fixes rust-lang#11100
Fixes rust-lang#11144
Fixes rust-lang#11124

rust-lang#11082 still needs discussion and rust-lang#11085 likely can't be fixed.

changelog: [`tuple_array_conversions`]: Move to `pedantic`
changelog: [`tuple_array_conversions`]: Don't lint if mutability of references changes
changelog: [`tuple_array_conversions`]: Don't lint if bindings don't come from the exact same pattern
changelog: [`tuple_array_conversions`]: Don't lint if bindings are used for more than just the conversion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant