Un-feature gate struct variants

Struct variant field visibility is now inherited. Remove `pub` keywords
from declarations.

Closes #18641

[breaking-change]
This commit is contained in:
Steven Fackler 2014-11-15 17:57:54 -08:00
parent 7e43f419cb
commit 579c65da1b
65 changed files with 60 additions and 114 deletions

View file

@ -1292,8 +1292,8 @@ pub type Variant = Spanned<Variant_>;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum PathListItem_ {
PathListIdent { pub name: Ident, pub id: NodeId },
PathListMod { pub id: NodeId }
PathListIdent { name: Ident, id: NodeId },
PathListMod { id: NodeId }
}
impl PathListItem_ {

View file

@ -37,7 +37,7 @@ use std::slice;
static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
("globs", Active),
("macro_rules", Active),
("struct_variant", Active),
("struct_variant", Accepted),
("asm", Active),
("managed_boxes", Removed),
("non_ascii_idents", Active),
@ -184,19 +184,6 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
}
}
match i.node {
ast::ItemEnum(ref def, _) => {
for variant in def.variants.iter() {
match variant.node.kind {
ast::StructVariantKind(..) => {
self.gate_feature("struct_variant", variant.span,
"enum struct variants are \
experimental and possibly buggy");
}
_ => {}
}
}
}
ast::ItemForeignMod(ref foreign_module) => {
if attr::contains_name(i.attrs.as_slice(), "link_args") {
self.gate_feature("link_args", i.span,

View file

@ -4648,7 +4648,7 @@ impl<'a> Parser<'a> {
is_tuple_like = false;
fields = Vec::new();
while self.token != token::CloseDelim(token::Brace) {
fields.push(self.parse_struct_decl_field());
fields.push(self.parse_struct_decl_field(true));
}
if fields.len() == 0 {
self.fatal(format!("unit-like struct definition should be \
@ -4725,12 +4725,16 @@ impl<'a> Parser<'a> {
}
/// Parse an element of a struct definition
fn parse_struct_decl_field(&mut self) -> StructField {
fn parse_struct_decl_field(&mut self, allow_pub: bool) -> StructField {
let attrs = self.parse_outer_attributes();
if self.eat_keyword(keywords::Pub) {
return self.parse_single_struct_field(Public, attrs);
if !allow_pub {
let span = self.last_span;
self.span_err(span, "`pub` is not allowed here");
}
return self.parse_single_struct_field(Public, attrs);
}
return self.parse_single_struct_field(Inherited, attrs);
@ -5178,7 +5182,7 @@ impl<'a> Parser<'a> {
fn parse_struct_def(&mut self) -> P<StructDef> {
let mut fields: Vec<StructField> = Vec::new();
while self.token != token::CloseDelim(token::Brace) {
fields.push(self.parse_struct_decl_field());
fields.push(self.parse_struct_decl_field(false));
}
self.bump();