about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2015-10-08 23:45:46 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2015-10-13 15:19:25 +0300
commit40aa09e4c9f4c3f0fa2b088895c8f5125325eaa4 (patch)
tree0ea29987683fbd21b30e2bc23769517a7984a116 /src/libsyntax/parse
parent30af54dede8b9f03a83dd5ad588bb430a5a76270 (diff)
downloadrust-40aa09e4c9f4c3f0fa2b088895c8f5125325eaa4.tar.gz
rust-40aa09e4c9f4c3f0fa2b088895c8f5125325eaa4.zip
Merge struct fields and struct kind
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs37
1 files changed, 15 insertions, 22 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index f944c93073a..2431c8cbe88 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -45,7 +45,7 @@ use ast::{PatRegion, PatStruct, PatTup, PatVec, PatWild, PatWildMulti};
 use ast::PatWildSingle;
 use ast::{PolyTraitRef, QSelf};
 use ast::{Return, BiShl, BiShr, Stmt, StmtDecl};
-use ast::{StmtExpr, StmtSemi, StmtMac, VariantData, StructField, VariantKind};
+use ast::{StmtExpr, StmtSemi, StmtMac, VariantData, StructField, VariantData_};
 use ast::{BiSub, StrStyle};
 use ast::{SelfExplicit, SelfRegion, SelfStatic, SelfValue};
 use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef};
@@ -4640,26 +4640,24 @@ impl<'a> Parser<'a> {
         // Otherwise if we look ahead and see a paren we parse a tuple-style
         // struct.
 
-        let (fields, kind) = if self.token.is_keyword(keywords::Where) {
+        let data_ = if self.token.is_keyword(keywords::Where) {
             generics.where_clause = try!(self.parse_where_clause());
             if try!(self.eat(&token::Semi)) {
                 // If we see a: `struct Foo<T> where T: Copy;` style decl.
-                (Vec::new(), VariantKind::Unit)
+                VariantData_::Unit
             } else {
                 // If we see: `struct Foo<T> where T: Copy { ... }`
-                (try!(self.parse_record_struct_body()), VariantKind::Struct)
+                VariantData_::Struct(try!(self.parse_record_struct_body()))
             }
         // No `where` so: `struct Foo<T>;`
         } else if try!(self.eat(&token::Semi) ){
-            (Vec::new(), VariantKind::Unit)
+            VariantData_::Unit
         // Record-style struct definition
         } else if self.token == token::OpenDelim(token::Brace) {
-            let fields = try!(self.parse_record_struct_body());
-            (fields, VariantKind::Struct)
+            VariantData_::Struct(try!(self.parse_record_struct_body()))
         // Tuple-style struct definition with optional where-clause.
         } else if self.token == token::OpenDelim(token::Paren) {
-            let fields = try!(self.parse_tuple_struct_body(&mut generics));
-            (fields, VariantKind::Tuple)
+            VariantData_::Tuple(try!(self.parse_tuple_struct_body(&mut generics)))
         } else {
             let token_str = self.this_token_to_string();
             return Err(self.fatal(&format!("expected `where`, `{{`, `(`, or `;` after struct \
@@ -4668,9 +4666,8 @@ impl<'a> Parser<'a> {
 
         Ok((class_name,
          ItemStruct(P(ast::VariantData {
-             fields: fields,
+             data_: data_,
              id: ast::DUMMY_NODE_ID,
-             kind: kind,
          }), generics),
          None))
     }
@@ -5111,9 +5108,8 @@ impl<'a> Parser<'a> {
         try!(self.bump());
 
         Ok(P(VariantData {
-            fields: fields,
+            data_: VariantData_::Struct(fields),
             id: ast::DUMMY_NODE_ID,
-            kind: VariantKind::Struct,
         }))
     }
 
@@ -5150,19 +5146,16 @@ impl<'a> Parser<'a> {
                         id: ast::DUMMY_NODE_ID,
                     }});
                 }
-                struct_def = P(VariantData { fields: fields,
-                                           id: ast::DUMMY_NODE_ID,
-                                           kind: ast::VariantKind::Tuple });
+                struct_def = P(VariantData { data_: ast::VariantData_::Tuple(fields),
+                                           id: ast::DUMMY_NODE_ID});
             } else if try!(self.eat(&token::Eq) ){
                 disr_expr = Some(try!(self.parse_expr_nopanic()));
                 any_disr = disr_expr.as_ref().map(|expr| expr.span);
-                struct_def = P(VariantData { fields: Vec::new(),
-                                           id: ast::DUMMY_NODE_ID,
-                                           kind: ast::VariantKind::Unit });
+                struct_def = P(VariantData { data_: ast::VariantData_::Unit,
+                                           id: ast::DUMMY_NODE_ID});
             } else {
-                struct_def = P(VariantData { fields: Vec::new(),
-                                           id: ast::DUMMY_NODE_ID,
-                                           kind: ast::VariantKind::Unit });
+                struct_def = P(VariantData { data_: ast::VariantData_::Unit,
+                                           id: ast::DUMMY_NODE_ID});
             }
 
             let vr = ast::Variant_ {