1
Fork 0

libsyntax: forbid visibility modifiers for enum variants

fixes #28433
This commit is contained in:
Aleksey Kladov 2015-09-16 19:35:33 +03:00 committed by Simonas Kazlauskas
parent 8dfb89067a
commit e3be84c6c8
3 changed files with 7 additions and 15 deletions

View file

@ -5200,13 +5200,10 @@ impl<'a> Parser<'a> {
let variant_attrs = self.parse_outer_attributes(); let variant_attrs = self.parse_outer_attributes();
let vlo = self.span.lo; let vlo = self.span.lo;
let vis = try!(self.parse_visibility());
let ident;
let kind; let kind;
let mut args = Vec::new(); let mut args = Vec::new();
let mut disr_expr = None; let mut disr_expr = None;
ident = try!(self.parse_ident()); let ident = try!(self.parse_ident());
if try!(self.eat(&token::OpenDelim(token::Brace)) ){ if try!(self.eat(&token::OpenDelim(token::Brace)) ){
// Parse a struct variant. // Parse a struct variant.
all_nullary = false; all_nullary = false;
@ -5248,7 +5245,7 @@ impl<'a> Parser<'a> {
kind: kind, kind: kind,
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
disr_expr: disr_expr, disr_expr: disr_expr,
vis: vis, vis: Inherited,
}; };
variants.push(P(spanned(vlo, self.last_span.hi, vr))); variants.push(P(spanned(vlo, self.last_span.hi, vr)));

View file

@ -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 // file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT. // http://rust-lang.org/COPYRIGHT.
// //
@ -8,16 +8,12 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use zoo::bird::{duck, goose}; enum bird {
pub duck, //~ ERROR: expected identifier, found keyword `pub`
mod zoo { goose
pub enum bird {
pub duck, //~ ERROR: unnecessary `pub` visibility
goose
}
} }
fn main() { fn main() {
let y = goose; let y = bird::goose;
} }

View file

@ -9,7 +9,6 @@
// except according to those terms. // except according to those terms.
struct A { pub i: isize } struct A { pub i: isize }
pub enum C { pub Variant } //~ ERROR: unnecessary `pub`
pub trait E { pub trait E {
fn foo(&self); fn foo(&self);