Skip to content

Commit 99f2a68

Browse files
committed
libsyntax: forbid visibility modifiers for enum variants
fixes rust-lang#28433
1 parent 0762f58 commit 99f2a68

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

src/libsyntax/parse/parser.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -5210,13 +5210,10 @@ impl<'a> Parser<'a> {
52105210
let variant_attrs = self.parse_outer_attributes();
52115211
let vlo = self.span.lo;
52125212

5213-
let vis = try!(self.parse_visibility());
5214-
5215-
let ident;
52165213
let kind;
52175214
let mut args = Vec::new();
52185215
let mut disr_expr = None;
5219-
ident = try!(self.parse_ident());
5216+
let ident = try!(self.parse_ident());
52205217
if try!(self.eat(&token::OpenDelim(token::Brace)) ){
52215218
// Parse a struct variant.
52225219
all_nullary = false;
@@ -5258,7 +5255,7 @@ impl<'a> Parser<'a> {
52585255
kind: kind,
52595256
id: ast::DUMMY_NODE_ID,
52605257
disr_expr: disr_expr,
5261-
vis: vis,
5258+
vis: Inherited,
52625259
};
52635260
variants.push(P(spanned(vlo, self.last_span.hi, vr)));
52645261

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,16 +8,12 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use zoo::bird::{duck, goose};
12-
13-
mod zoo {
14-
pub enum bird {
15-
pub duck, //~ ERROR: unnecessary `pub` visibility
16-
goose
17-
}
11+
enum bird {
12+
pub duck, //~ ERROR: expected identifier, found keyword `pub`
13+
goose
1814
}
1915

2016

2117
fn main() {
22-
let y = goose;
18+
let y = bird::goose;
2319
}

src/test/compile-fail/useless-priv.rs renamed to src/test/compile-fail/useless-pub.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
struct A { pub i: isize }
12-
pub enum C { pub Variant } //~ ERROR: unnecessary `pub`
1312

1413
pub trait E {
1514
fn foo(&self);

0 commit comments

Comments
 (0)