From e3be84c6c81c63e11f62105a9befcc39b9a17081 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 16 Sep 2015 19:35:33 +0300 Subject: [PATCH] libsyntax: forbid visibility modifiers for enum variants fixes #28433 --- src/libsyntax/parse/parser.rs | 7 ++----- .../{issue-3993-2.rs => issue-28433.rs} | 14 +++++--------- .../{useless-priv.rs => useless-pub.rs} | 1 - 3 files changed, 7 insertions(+), 15 deletions(-) rename src/test/compile-fail/{issue-3993-2.rs => issue-28433.rs} (65%) rename src/test/compile-fail/{useless-priv.rs => useless-pub.rs} (91%) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index ff622859cf0b1..4c25714093481 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5200,13 +5200,10 @@ impl<'a> Parser<'a> { let variant_attrs = self.parse_outer_attributes(); let vlo = self.span.lo; - let vis = try!(self.parse_visibility()); - - let ident; let kind; let mut args = Vec::new(); let mut disr_expr = None; - ident = try!(self.parse_ident()); + let ident = try!(self.parse_ident()); if try!(self.eat(&token::OpenDelim(token::Brace)) ){ // Parse a struct variant. all_nullary = false; @@ -5248,7 +5245,7 @@ impl<'a> Parser<'a> { kind: kind, id: ast::DUMMY_NODE_ID, disr_expr: disr_expr, - vis: vis, + vis: Inherited, }; variants.push(P(spanned(vlo, self.last_span.hi, vr))); diff --git a/src/test/compile-fail/issue-3993-2.rs b/src/test/compile-fail/issue-28433.rs similarity index 65% rename from src/test/compile-fail/issue-3993-2.rs rename to src/test/compile-fail/issue-28433.rs index 9d9e91a141be3..ab0708c28aef6 100644 --- a/src/test/compile-fail/issue-3993-2.rs +++ b/src/test/compile-fail/issue-28433.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,16 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use zoo::bird::{duck, goose}; - -mod zoo { - pub enum bird { - pub duck, //~ ERROR: unnecessary `pub` visibility - goose - } +enum bird { + pub duck, //~ ERROR: expected identifier, found keyword `pub` + goose } fn main() { - let y = goose; + let y = bird::goose; } diff --git a/src/test/compile-fail/useless-priv.rs b/src/test/compile-fail/useless-pub.rs similarity index 91% rename from src/test/compile-fail/useless-priv.rs rename to src/test/compile-fail/useless-pub.rs index 59964d0df956c..fb6cdf7fa5924 100644 --- a/src/test/compile-fail/useless-priv.rs +++ b/src/test/compile-fail/useless-pub.rs @@ -9,7 +9,6 @@ // except according to those terms. struct A { pub i: isize } -pub enum C { pub Variant } //~ ERROR: unnecessary `pub` pub trait E { fn foo(&self);