diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 419fe98f3d5..778b915190b 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -286,8 +286,7 @@ fn encode_enum_variant_info(ecx: @EncodeContext, ebml_w: writer::Encoder, if args.len() > 0 && generics.ty_params.len() == 0 => { encode_symbol(ecx, ebml_w, variant.node.id); } - ast::tuple_variant_kind(_) | ast::struct_variant_kind(_) | - ast::enum_variant_kind(_) => {} + ast::tuple_variant_kind(_) | ast::struct_variant_kind(_) => {} } encode_discriminant(ecx, ebml_w, variant.node.id); if vi[i].disr_val != disr_val { diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 0c9c7a73902..10d3de6b131 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -37,7 +37,7 @@ use syntax::ast::{expr_fn_block, expr_index, expr_method_call, expr_path}; use syntax::ast::{def_prim_ty, def_region, def_self, def_ty, def_ty_param}; use syntax::ast::{def_upvar, def_use, def_variant, div, eq}; -use syntax::ast::{enum_variant_kind, expr, expr_again, expr_assign_op}; +use syntax::ast::{expr, expr_again, expr_assign_op}; use syntax::ast::{expr_index, expr_loop}; use syntax::ast::{expr_path, expr_struct, expr_unary, fn_decl}; use syntax::ast::{foreign_item, foreign_item_const, foreign_item_fn, ge}; @@ -1383,16 +1383,6 @@ fn build_reduced_graph_for_variant(@mut self, variant.span); self.structs.insert(local_def(variant.node.id)); } - enum_variant_kind(ref enum_definition) => { - child.define_type(privacy, - def_ty(local_def(variant.node.id)), - variant.span); - for (*enum_definition).variants.each |variant| { - self.build_reduced_graph_for_variant(*variant, item_id, - parent_privacy, - parent, visitor); - } - } } } diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index cfbd59073fe..9e83552a600 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -2051,14 +2051,6 @@ pub fn trans_enum_def(ccx: @CrateContext, enum_definition: ast::enum_def, trans_struct_def(ccx, struct_def, path, variant.node.id); } - ast::enum_variant_kind(ref enum_definition) => { - trans_enum_def(ccx, - *enum_definition, - id, - path, - vi, - &mut *i); - } } } } @@ -2513,9 +2505,6 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef { ast::struct_variant_kind(_) => { fail!(~"struct variant kind unexpected in get_item_val") } - ast::enum_variant_kind(_) => { - fail!(~"enum variant kind unexpected in get_item_val") - } } set_inline_hint(llfn); llfn diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs index 0a7024b161e..ed07b7e9f7f 100644 --- a/src/librustc/middle/trans/monomorphize.rs +++ b/src/librustc/middle/trans/monomorphize.rs @@ -204,8 +204,6 @@ pub fn monomorphic_fn(ccx: @CrateContext, } ast::struct_variant_kind(_) => ccx.tcx.sess.bug(~"can't monomorphize struct variants"), - ast::enum_variant_kind(_) => - ccx.tcx.sess.bug(~"can't monomorphize enum variants") } d } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 58db934160b..d7f71bae85b 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -3873,9 +3873,6 @@ pub fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[VariantInfo] { ast::struct_variant_kind(_) => { fail!(~"struct variant kinds unimpl in enum_variants") } - ast::enum_variant_kind(_) => { - fail!(~"enum variant kinds unimpl in enum_variants") - } } }) } diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index dcf75955509..28f8a8f50b4 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -3066,16 +3066,6 @@ fn do_check(ccx: @mut CrateCtxt, ccx.tcx, local_def(v.node.id)).map(|cf| ty::node_id_to_type(ccx.tcx, cf.id.node))); } - ast::enum_variant_kind(_) => { - arg_tys = None; - do_check(ccx, - sp, - vs, - id, - &mut *disr_vals, - &mut *disr_val, - &mut *variants); - } } match arg_tys { diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 573285c357e..0f84975c89c 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -202,15 +202,6 @@ pub fn get_enum_variant_types(ccx: &CrateCtxt, |f| ty::node_id_to_type(ccx.tcx, f.node.id)); result_ty = Some(ty::mk_ctor_fn(tcx, input_tys, enum_ty)); } - - ast::enum_variant_kind(ref enum_definition) => { - get_enum_variant_types(ccx, - enum_ty, - enum_definition.variants, - generics, - rp); - result_ty = None; - } }; match result_ty { diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 6b788810a79..7304eb20bca 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1078,7 +1078,6 @@ pub struct variant_arg { pub enum variant_kind { tuple_variant_kind(~[variant_arg]), struct_variant_kind(@struct_def), - enum_variant_kind(enum_def) } #[auto_encode] @@ -1086,7 +1085,6 @@ pub enum variant_kind { #[deriving(Eq)] pub struct enum_def { variants: ~[variant], - common: Option<@struct_def>, } #[auto_encode] diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index 2a112f106a8..d7e0e9aa550 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -990,8 +990,6 @@ fn mk_enum_ser_body( ), ast::struct_variant_kind(*) => fail!(~"struct variants unimplemented"), - ast::enum_variant_kind(*) => - fail!(~"enum variants unimplemented"), } }; @@ -1089,8 +1087,6 @@ fn mk_enum_deser_body( }, ast::struct_variant_kind(*) => fail!(~"struct variants unimplemented"), - ast::enum_variant_kind(*) => - fail!(~"enum variants unimplemented") }; let pat = @ast::pat { diff --git a/src/libsyntax/ext/deriving/clone.rs b/src/libsyntax/ext/deriving/clone.rs index df4dd2735fc..6516bd85270 100644 --- a/src/libsyntax/ext/deriving/clone.rs +++ b/src/libsyntax/ext/deriving/clone.rs @@ -12,7 +12,7 @@ use ast; use ast::{TraitTyParamBound, Ty, and, bind_by_ref, binop, deref, enum_def}; -use ast::{enum_variant_kind, expr, expr_match, ident, impure_fn, item, item_}; +use ast::{expr, expr_match, ident, impure_fn, item, item_}; use ast::{item_enum, item_impl, item_struct, Generics}; use ast::{m_imm, meta_item, method}; use ast::{named_field, or, pat, pat_ident, pat_wild, public, pure_fn}; diff --git a/src/libsyntax/ext/deriving/eq.rs b/src/libsyntax/ext/deriving/eq.rs index 531390035db..a1cb981e3bd 100644 --- a/src/libsyntax/ext/deriving/eq.rs +++ b/src/libsyntax/ext/deriving/eq.rs @@ -12,7 +12,7 @@ use ast; use ast::{TraitTyParamBound, Ty, and, bind_by_ref, binop, deref, enum_def}; -use ast::{enum_variant_kind, expr, expr_match, ident, impure_fn, item, item_}; +use ast::{expr, expr_match, ident, impure_fn, item, item_}; use ast::{item_enum, item_impl, item_struct, Generics}; use ast::{m_imm, meta_item, method}; use ast::{named_field, or, pat, pat_ident, pat_wild, public, pure_fn}; diff --git a/src/libsyntax/ext/deriving/iter_bytes.rs b/src/libsyntax/ext/deriving/iter_bytes.rs index 528db0d1072..3be8bf6efb5 100644 --- a/src/libsyntax/ext/deriving/iter_bytes.rs +++ b/src/libsyntax/ext/deriving/iter_bytes.rs @@ -12,7 +12,7 @@ use ast; use ast::{TraitTyParamBound, Ty, and, bind_by_ref, binop, deref, enum_def}; -use ast::{enum_variant_kind, expr, expr_match, ident, impure_fn, item, item_}; +use ast::{expr, expr_match, ident, impure_fn, item, item_}; use ast::{item_enum, item_impl, item_struct, Generics}; use ast::{m_imm, meta_item, method}; use ast::{named_field, or, pat, pat_ident, pat_wild, public, pure_fn}; diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs index 21477d6e067..1b81380ec9b 100644 --- a/src/libsyntax/ext/deriving/mod.rs +++ b/src/libsyntax/ext/deriving/mod.rs @@ -15,7 +15,7 @@ use ast; use ast::{TraitTyParamBound, Ty, and, bind_by_ref, binop, deref, enum_def}; -use ast::{enum_variant_kind, expr, expr_match, ident, impure_fn, item, item_}; +use ast::{expr, expr_match, ident, impure_fn, item, item_}; use ast::{item_enum, item_impl, item_struct, Generics}; use ast::{m_imm, meta_item, method}; use ast::{named_field, or, pat, pat_ident, pat_wild, public, pure_fn}; @@ -283,9 +283,6 @@ pub fn create_enum_variant_pattern(cx: @ext_ctxt, build::mk_pat_struct(cx, span, matching_path, field_pats) } - enum_variant_kind(*) => { - cx.span_unimpl(span, ~"enum variants for `deriving`"); - } } } @@ -293,9 +290,6 @@ pub fn variant_arg_count(cx: @ext_ctxt, span: span, variant: &variant) -> uint { match variant.node.kind { tuple_variant_kind(ref args) => args.len(), struct_variant_kind(ref struct_def) => struct_def.fields.len(), - enum_variant_kind(*) => { - cx.span_bug(span, ~"variant_arg_count: enum variants deprecated") - } } } diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index a7725eab695..99033b3b3cc 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -238,7 +238,7 @@ fn to_type_decls(&self, cx: @ext_ctxt) -> ~[@ast::item] { cx.item_enum_poly( name, self.span, - ast::enum_def { variants: items_msg, common: None }, + ast::enum_def { variants: items_msg }, cx.strip_bounds(&self.generics) ) ] diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 279d57a291e..f0885afa580 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -257,9 +257,6 @@ pub fn noop_fold_item_underscore(i: &item_, fld: @ast_fold) -> item_ { variants: do enum_definition.variants.map |x| { fld.fold_variant(x) }, - common: do enum_definition.common.map |x| { - fold_struct_def(*x, fld) - } }, fold_generics(generics, fld)) } @@ -682,17 +679,6 @@ fn fold_variant_arg_(va: variant_arg, fld: @ast_fold) -> variant_arg { ctor_id: struct_def.ctor_id.map(|c| fld.new_id(*c)) }) } - enum_variant_kind(ref enum_definition) => { - let variants = do (*enum_definition).variants.map |x| { - fld.fold_variant(x) - }; - let common = do (*enum_definition).common.map |x| { - fold_struct_def(*x, fld) - }; - kind = enum_variant_kind( - ast::enum_def { variants: variants, common: common } - ); - } } let fold_attribute = |x| fold_attribute_(x, fld); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6fe003b2eba..51a7f7fbd1c 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -19,7 +19,7 @@ use ast::{bind_by_copy, bitand, bitor, bitxor, blk}; use ast::{blk_check_mode, box, by_copy, by_ref}; use ast::{crate, crate_cfg, decl, decl_item}; -use ast::{decl_local, default_blk, deref, div, enum_def, enum_variant_kind}; +use ast::{decl_local, default_blk, deref, div, enum_def}; use ast::{expl, expr, expr_, expr_addr_of, expr_match, expr_again}; use ast::{expr_assign, expr_assign_op, expr_binary, expr_block}; use ast::{expr_break, expr_call, expr_cast, expr_copy, expr_do_body}; @@ -3788,63 +3788,42 @@ fn parse_struct_def(&self) -> @struct_def { fn parse_enum_def(&self, generics: &ast::Generics) -> enum_def { let mut variants = ~[]; let mut all_nullary = true, have_disr = false; - let mut common_fields = None; - while *self.token != token::RBRACE { let variant_attrs = self.parse_outer_attributes(); let vlo = self.span.lo; - // Is this a common field declaration? - if self.eat_keyword(&~"struct") { - if common_fields.is_some() { - self.fatal(~"duplicate declaration of shared fields"); - } - self.expect(&token::LBRACE); - common_fields = Some(self.parse_struct_def()); - loop; - } - let vis = self.parse_visibility(); - // Is this a nested enum declaration? let ident, needs_comma, kind; let mut args = ~[], disr_expr = None; - if self.eat_keyword(&~"enum") { - ident = self.parse_ident(); - self.expect(&token::LBRACE); - let nested_enum_def = self.parse_enum_def(generics); - kind = enum_variant_kind(nested_enum_def); - needs_comma = false; - } else { - ident = self.parse_ident(); - if self.eat(&token::LBRACE) { - // Parse a struct variant. - all_nullary = false; - kind = struct_variant_kind(self.parse_struct_def()); - } else if *self.token == token::LPAREN { - all_nullary = false; - let arg_tys = self.parse_unspanned_seq( - &token::LPAREN, - &token::RPAREN, - seq_sep_trailing_disallowed(token::COMMA), - |p| p.parse_ty(false) - ); - for arg_tys.each |ty| { - args.push(ast::variant_arg { - ty: *ty, - id: self.get_id(), - }); - } - kind = tuple_variant_kind(args); - } else if self.eat(&token::EQ) { - have_disr = true; - disr_expr = Some(self.parse_expr()); - kind = tuple_variant_kind(args); - } else { - kind = tuple_variant_kind(~[]); + ident = self.parse_ident(); + if self.eat(&token::LBRACE) { + // Parse a struct variant. + all_nullary = false; + kind = struct_variant_kind(self.parse_struct_def()); + } else if *self.token == token::LPAREN { + all_nullary = false; + let arg_tys = self.parse_unspanned_seq( + &token::LPAREN, + &token::RPAREN, + seq_sep_trailing_disallowed(token::COMMA), + |p| p.parse_ty(false) + ); + for arg_tys.each |ty| { + args.push(ast::variant_arg { + ty: *ty, + id: self.get_id(), + }); } - needs_comma = true; + kind = tuple_variant_kind(args); + } else if self.eat(&token::EQ) { + have_disr = true; + disr_expr = Some(self.parse_expr()); + kind = tuple_variant_kind(args); + } else { + kind = tuple_variant_kind(~[]); } + needs_comma = true; let vr = ast::variant_ { name: ident, @@ -3864,7 +3843,7 @@ fn parse_enum_def(&self, generics: &ast::Generics) -> enum_def { enum"); } - ast::enum_def { variants: variants, common: common_fields } + ast::enum_def { variants: variants } } fn parse_item_enum(&self) -> item_info { @@ -3892,7 +3871,7 @@ fn parse_item_enum(&self) -> item_info { return ( id, item_enum( - ast::enum_def { variants: ~[variant], common: None }, + ast::enum_def { variants: ~[variant] }, generics), None ); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index cb142ef3f54..58fbba752f5 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -785,9 +785,6 @@ fn print_variant_arg(s: @ps, arg: ast::variant_arg) { let generics = ast_util::empty_generics(); print_struct(s, struct_def, &generics, v.node.name, v.span); } - ast::enum_variant_kind(ref enum_definition) => { - print_variants(s, (*enum_definition).variants, v.span); - } } match v.node.disr_expr { Some(d) => { diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 2bdf26fba58..33b345e2d11 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -215,9 +215,6 @@ pub fn visit_enum_def(enum_definition: ast::enum_def, (v.visit_struct_def)(struct_def, vr.node.name, tps, vr.node.id, e, v); } - enum_variant_kind(ref enum_definition) => { - visit_enum_def((*enum_definition), tps, e, v); - } } // Visit the disr expr if it exists for vr.node.disr_expr.each |ex| { (v.visit_expr)(*ex, e, v) } diff --git a/src/test/run-pass/common-fields-trivial.rs b/src/test/run-pass/common-fields-trivial.rs deleted file mode 100644 index fd5079b8f54..00000000000 --- a/src/test/run-pass/common-fields-trivial.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum Foo { - struct { - x: int, - y: int, - } - - Bar(int), - Baz(int) -} - -pub fn main() { - let x = Bar(3); -} -