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

visibility modifiers are accepted for enum variants #28433

Closed
matklad opened this issue Sep 16, 2015 · 2 comments
Closed

visibility modifiers are accepted for enum variants #28433

matklad opened this issue Sep 16, 2015 · 2 comments

Comments

@matklad
Copy link
Member

matklad commented Sep 16, 2015

The following code compiles without warnings:

#[allow(dead_code)]
enum Foo {
    pub Spam,
    Eggs
}

fn main() {

}

I guess that this should be forbidden, because enum vairants inherit visibility of the enum itself. At minimum, this should produce a warning.

This is the relevant line from parser: https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/parser.rs#L5203

This is the discussion on Rust forum: https://users.rust-lang.org/t/confused-about-enum-variants-visibility/2873

@matklad
Copy link
Member Author

matklad commented Sep 16, 2015

The following tests fail (due to different error message), if variants visibility modifiers are forbidden:

test [compile-fail] compile-fail/issue-3993-2.rs ... FAILED
test [compile-fail] compile-fail/useless-priv.rs ... FAILED

@nagisa
Copy link
Member

nagisa commented Sep 16, 2015

I’m fine with making this change without an RFC, but we should still run a crater run with change applied.

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.

2 participants