Skip to content

Commit e3be84c

Browse files
matkladnagisa
authored andcommitted
libsyntax: forbid visibility modifiers for enum variants
fixes #28433
1 parent 8dfb890 commit e3be84c

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
@@ -5200,13 +5200,10 @@ impl<'a> Parser<'a> {
52005200
let variant_attrs = self.parse_outer_attributes();
52015201
let vlo = self.span.lo;
52025202

5203-
let vis = try!(self.parse_visibility());
5204-
5205-
let ident;
52065203
let kind;
52075204
let mut args = Vec::new();
52085205
let mut disr_expr = None;
5209-
ident = try!(self.parse_ident());
5206+
let ident = try!(self.parse_ident());
52105207
if try!(self.eat(&token::OpenDelim(token::Brace)) ){
52115208
// Parse a struct variant.
52125209
all_nullary = false;
@@ -5248,7 +5245,7 @@ impl<'a> Parser<'a> {
52485245
kind: kind,
52495246
id: ast::DUMMY_NODE_ID,
52505247
disr_expr: disr_expr,
5251-
vis: vis,
5248+
vis: Inherited,
52525249
};
52535250
variants.push(P(spanned(vlo, self.last_span.hi, vr)));
52545251

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)