diff options
| author | Jakub Wieczorek <jakub@jakub.cc> | 2014-10-11 19:24:58 +0200 |
|---|---|---|
| committer | Jakub Wieczorek <jakub@jakub.cc> | 2014-10-11 19:42:26 +0200 |
| commit | 403cd40e6a29cc0f897e4b3d80e1e2bcf38f8875 (patch) | |
| tree | df9a8e78271637c38f85af47a25461f91952424c /src/libsyntax | |
| parent | 9b9833299245cc1eac68b52169e9152d0f412d6b (diff) | |
| download | rust-403cd40e6a29cc0f897e4b3d80e1e2bcf38f8875.tar.gz rust-403cd40e6a29cc0f897e4b3d80e1e2bcf38f8875.zip | |
Remove `virtual` structs from the language
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/config.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 13 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 30 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 4 |
7 files changed, 10 insertions, 59 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 274bb2e39e0..44b327745ed 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1286,10 +1286,6 @@ pub struct StructDef { /// ID of the constructor. This is only used for tuple- or enum-like /// structs. pub ctor_id: Option<NodeId>, - /// Super struct, if specified. - pub super_struct: Option<P<Ty>>, - /// True iff the struct may be inherited from. - pub is_virtual: bool, } /* diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 9b4748f88ab..a53be6097fd 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -158,14 +158,12 @@ fn fold_item_underscore(cx: &mut Context, item: ast::Item_) -> ast::Item_ { } fn fold_struct(cx: &mut Context, def: P<ast::StructDef>) -> P<ast::StructDef> { - def.map(|ast::StructDef {fields, ctor_id, super_struct, is_virtual}| { + def.map(|ast::StructDef { fields, ctor_id }| { ast::StructDef { fields: fields.into_iter().filter(|m| { (cx.in_cfg)(m.node.attrs.as_slice()) }).collect(), ctor_id: ctor_id, - super_struct: super_struct, - is_virtual: is_virtual, } }) } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index c3c36d04442..590157d677d 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -218,22 +218,11 @@ impl<'a, 'v> Visitor<'v> for Context<'a> { } } - ast::ItemStruct(ref struct_definition, _) => { + ast::ItemStruct(..) => { if attr::contains_name(i.attrs.as_slice(), "simd") { self.gate_feature("simd", i.span, "SIMD types are experimental and possibly buggy"); } - match struct_definition.super_struct { - Some(ref path) => self.gate_feature("struct_inherit", path.span, - "struct inheritance is experimental \ - and possibly buggy"), - None => {} - } - if struct_definition.is_virtual { - self.gate_feature("struct_inherit", i.span, - "struct inheritance (`virtual` keyword) is \ - experimental and possibly buggy"); - } } ast::ItemImpl(_, _, _, ref items) => { diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 32e226361e9..3e16bca72ef 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -801,11 +801,9 @@ pub fn noop_fold_associated_type<T>(at: AssociatedType, folder: &mut T) } pub fn noop_fold_struct_def<T: Folder>(struct_def: P<StructDef>, fld: &mut T) -> P<StructDef> { - struct_def.map(|StructDef {fields, ctor_id, super_struct, is_virtual}| StructDef { + struct_def.map(|StructDef { fields, ctor_id }| StructDef { fields: fields.move_map(|f| fld.fold_struct_field(f)), ctor_id: ctor_id.map(|cid| fld.new_id(cid)), - super_struct: super_struct.map(|t| fld.fold_ty(t)), - is_virtual: is_virtual }) } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index e7f40cf0722..daaf6744d9d 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4540,24 +4540,14 @@ impl<'a> Parser<'a> { } /// Parse struct Foo { ... } - fn parse_item_struct(&mut self, is_virtual: bool) -> ItemInfo { + fn parse_item_struct(&mut self) -> ItemInfo { let class_name = self.parse_ident(); let mut generics = self.parse_generics(); - let super_struct = if self.eat(&token::COLON) { + if self.eat(&token::COLON) { let ty = self.parse_ty(true); - match ty.node { - TyPath(_, None, _) => { - Some(ty) - } - _ => { - self.span_err(ty.span, "not a struct"); - None - } - } - } else { - None - }; + self.span_err(ty.span, "`virtual` structs have been removed from the language"); + } self.parse_where_clause(&mut generics); @@ -4618,8 +4608,6 @@ impl<'a> Parser<'a> { ItemStruct(P(ast::StructDef { fields: fields, ctor_id: if is_tuple_like { Some(new_id) } else { None }, - super_struct: super_struct, - is_virtual: is_virtual, }), generics), None) } @@ -5090,8 +5078,6 @@ impl<'a> Parser<'a> { P(StructDef { fields: fields, ctor_id: None, - super_struct: None, - is_virtual: false, }) } @@ -5288,11 +5274,9 @@ impl<'a> Parser<'a> { token_str).as_slice()); } - let is_virtual = self.eat_keyword(keywords::Virtual); - if is_virtual && !self.is_keyword(keywords::Struct) { + if self.eat_keyword(keywords::Virtual) { let span = self.span; - self.span_err(span, - "`virtual` keyword may only be used with `struct`"); + self.span_err(span, "`virtual` structs have been removed from the language"); } // the rest are all guaranteed to be items: @@ -5427,7 +5411,7 @@ impl<'a> Parser<'a> { } if self.eat_keyword(keywords::Struct) { // STRUCT ITEM - let (ident, item_, extra_attrs) = self.parse_item_struct(is_virtual); + let (ident, item_, extra_attrs) = self.parse_item_struct(); let last_span = self.last_span; let item = self.mk_item(lo, last_span.hi, diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index e1a2b2aeefe..c9a6354bf97 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -826,9 +826,6 @@ impl<'a> State<'a> { )); } ast::ItemStruct(ref struct_def, ref generics) => { - if struct_def.is_virtual { - try!(self.word_space("virtual")); - } try!(self.head(visibility_qualified(item.vis,"struct").as_slice())); try!(self.print_struct(&**struct_def, generics, item.ident, item.span)); } @@ -968,13 +965,6 @@ impl<'a> State<'a> { span: codemap::Span) -> IoResult<()> { try!(self.print_ident(ident)); try!(self.print_generics(generics)); - match struct_def.super_struct { - Some(ref t) => { - try!(self.word_space(":")); - try!(self.print_type(&**t)); - }, - None => {}, - } if ast_util::struct_def_is_tuple_like(struct_def) { if !struct_def.fields.is_empty() { try!(self.popen()); diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 5c7b144f4ab..c98c3bffcb6 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -603,10 +603,6 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_method: &'v Tr pub fn walk_struct_def<'v, V: Visitor<'v>>(visitor: &mut V, struct_definition: &'v StructDef) { - match struct_definition.super_struct { - Some(ref t) => visitor.visit_ty(&**t), - None => {}, - } for field in struct_definition.fields.iter() { visitor.visit_struct_field(field) } |
