Skip to content

Commit

Permalink
libsyntax: forbid visibility modifiers for enum variants
Browse files Browse the repository at this point in the history
fixes #28433
  • Loading branch information
matklad authored and nagisa committed Sep 17, 2015
1 parent 8dfb890 commit e3be84c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
7 changes: 2 additions & 5 deletions src/libsyntax/parse/parser.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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)));

Expand Down
@@ -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.
//
Expand All @@ -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;
}
Expand Up @@ -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);
Expand Down

0 comments on commit e3be84c

Please sign in to comment.