about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@gmail>2013-07-19 16:24:22 +0200
committerMichael Woerister <michaelwoerister@gmail>2013-07-22 15:35:29 +0200
commit5aee3e01a02e0b31ad225e70899a671937ab65ee (patch)
tree3c56d4a34e9320acf99efd25d0ef35fe25d43835
parent4bd14246227255843e420c3c691ec9a59cea1a9f (diff)
downloadrust-5aee3e01a02e0b31ad225e70899a671937ab65ee.tar.gz
rust-5aee3e01a02e0b31ad225e70899a671937ab65ee.zip
De-spanned<T> and renamed ast::field (now ast::Field)
-rw-r--r--src/librustc/middle/cfg/construct.rs2
-rw-r--r--src/librustc/middle/const_eval.rs2
-rw-r--r--src/librustc/middle/dataflow.rs2
-rw-r--r--src/librustc/middle/liveness.rs2
-rw-r--r--src/librustc/middle/moves.rs4
-rw-r--r--src/librustc/middle/privacy.rs17
-rw-r--r--src/librustc/middle/trans/consts.rs4
-rw-r--r--src/librustc/middle/trans/expr.rs6
-rw-r--r--src/librustc/middle/typeck/check/mod.rs16
-rw-r--r--src/librustc/util/common.rs6
-rw-r--r--src/libsyntax/ast.rs7
-rw-r--r--src/libsyntax/ext/build.rs14
-rw-r--r--src/libsyntax/fold.rs10
-rw-r--r--src/libsyntax/parse/parser.rs11
-rw-r--r--src/libsyntax/print/pprust.rs8
-rw-r--r--src/libsyntax/visit.rs2
16 files changed, 52 insertions, 61 deletions
diff --git a/src/librustc/middle/cfg/construct.rs b/src/librustc/middle/cfg/construct.rs
index e250a223157..aee8ae32178 100644
--- a/src/librustc/middle/cfg/construct.rs
+++ b/src/librustc/middle/cfg/construct.rs
@@ -374,7 +374,7 @@ impl CFGBuilder {
             ast::expr_struct(_, ref fields, base) => {
                 let base_exit = self.opt_expr(base, pred);
                 let field_exprs: ~[@ast::expr] =
-                    fields.iter().transform(|f| f.node.expr).collect();
+                    fields.iter().transform(|f| f.expr).collect();
                 self.straightline(expr, base_exit, field_exprs)
             }
 
diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs
index 01350869fc1..59dbc7251da 100644
--- a/src/librustc/middle/const_eval.rs
+++ b/src/librustc/middle/const_eval.rs
@@ -117,7 +117,7 @@ pub fn classify(e: &expr,
 
               ast::expr_struct(_, ref fs, None) => {
                 let cs = do fs.iter().transform |f| {
-                    classify(f.node.expr, tcx)
+                    classify(f.expr, tcx)
                 };
                 join_all(cs)
               }
diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs
index 53622b667ff..2cdae04478c 100644
--- a/src/librustc/middle/dataflow.rs
+++ b/src/librustc/middle/dataflow.rs
@@ -705,7 +705,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
 
             ast::expr_struct(_, ref fields, with_expr) => {
                 for fields.iter().advance |field| {
-                    self.walk_expr(field.node.expr, in_out, loop_scopes);
+                    self.walk_expr(field.expr, in_out, loop_scopes);
                 }
                 self.walk_opt_expr(with_expr, in_out, loop_scopes);
             }
diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs
index 20497755e17..f9b42d593c2 100644
--- a/src/librustc/middle/liveness.rs
+++ b/src/librustc/middle/liveness.rs
@@ -1161,7 +1161,7 @@ impl Liveness {
           expr_struct(_, ref fields, with_expr) => {
             let succ = self.propagate_through_opt_expr(with_expr, succ);
             do fields.rev_iter().fold(succ) |succ, field| {
-                self.propagate_through_expr(field.node.expr, succ)
+                self.propagate_through_expr(field.expr, succ)
             }
           }
 
diff --git a/src/librustc/middle/moves.rs b/src/librustc/middle/moves.rs
index 2e2178df66e..d8ce0a96636 100644
--- a/src/librustc/middle/moves.rs
+++ b/src/librustc/middle/moves.rs
@@ -394,7 +394,7 @@ impl VisitContext {
 
             expr_struct(_, ref fields, opt_with) => {
                 for fields.iter().advance |field| {
-                    self.consume_expr(field.node.expr, visitor);
+                    self.consume_expr(field.expr, visitor);
                 }
 
                 for opt_with.iter().advance |with_expr| {
@@ -417,7 +417,7 @@ impl VisitContext {
                     // specified and (2) have a type that
                     // moves-by-default:
                     let consume_with = with_fields.iter().any(|tf| {
-                        !fields.iter().any(|f| f.node.ident == tf.ident) &&
+                        !fields.iter().any(|f| f.ident == tf.ident) &&
                             ty::type_moves_by_default(self.tcx, tf.mt.ty)
                     });
 
diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs
index 0b747caea81..1ea32b3f404 100644
--- a/src/librustc/middle/privacy.rs
+++ b/src/librustc/middle/privacy.rs
@@ -413,9 +413,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
                                 Some(ref entry) => {
                                     debug!("(privacy checking) checking \
                                             impl method");
-                                    check_method(expr.span,
-                                                 &entry.origin,
-                                                 ident);
+                                    check_method(expr.span, &entry.origin, ident);
                                 }
                             }
                         }
@@ -433,8 +431,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
                                 for (*fields).iter().advance |field| {
                                         debug!("(privacy checking) checking \
                                                 field in struct literal");
-                                    check_field(expr.span, id,
-                                                field.node.ident);
+                                    check_field(expr.span, id, field.ident);
                                 }
                             }
                         }
@@ -448,8 +445,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
                                                         checking field in \
                                                         struct variant \
                                                         literal");
-                                            check_field(expr.span, variant_id,
-                                                        field.node.ident);
+                                            check_field(expr.span, variant_id, field.ident);
                                         }
                                     }
                                     _ => {
@@ -499,8 +495,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
                                 for fields.iter().advance |field| {
                                         debug!("(privacy checking) checking \
                                                 struct pattern");
-                                    check_field(pattern.span, id,
-                                                field.ident);
+                                    check_field(pattern.span, id, field.ident);
                                 }
                             }
                         }
@@ -513,9 +508,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
                                             debug!("(privacy checking) \
                                                     checking field in \
                                                     struct variant pattern");
-                                            check_field(pattern.span,
-                                                        variant_id,
-                                                        field.ident);
+                                            check_field(pattern.span, variant_id, field.ident);
                                         }
                                     }
                                     _ => {
diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs
index 69c8331bc9f..9246ca1f641 100644
--- a/src/librustc/middle/trans/consts.rs
+++ b/src/librustc/middle/trans/consts.rs
@@ -488,8 +488,8 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef {
               do expr::with_field_tys(tcx, ety, Some(e.id))
                   |discr, field_tys| {
                   let cs = field_tys.map(|field_ty| {
-                      match fs.iter().find_(|f| field_ty.ident == f.node.ident) {
-                          Some(f) => const_expr(cx, (*f).node.expr),
+                      match fs.iter().find_(|f| field_ty.ident == f.ident) {
+                          Some(f) => const_expr(cx, (*f).expr),
                           None => {
                               cx.tcx.sess.span_bug(e.span, "missing struct field");
                           }
diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs
index adfc0b58485..d9fdf8d52c7 100644
--- a/src/librustc/middle/trans/expr.rs
+++ b/src/librustc/middle/trans/expr.rs
@@ -1124,7 +1124,7 @@ pub fn with_field_tys<R>(tcx: ty::ctxt,
 }
 
 fn trans_rec_or_struct(bcx: block,
-                       fields: &[ast::field],
+                       fields: &[ast::Field],
                        base: Option<@ast::expr>,
                        expr_span: codemap::span,
                        id: ast::node_id,
@@ -1139,11 +1139,11 @@ fn trans_rec_or_struct(bcx: block,
         let mut need_base = vec::from_elem(field_tys.len(), true);
 
         let numbered_fields = do fields.map |field| {
-            let opt_pos = field_tys.iter().position(|field_ty| field_ty.ident == field.node.ident);
+            let opt_pos = field_tys.iter().position(|field_ty| field_ty.ident == field.ident);
             match opt_pos {
                 Some(i) => {
                     need_base[i] = false;
-                    (i, field.node.expr)
+                    (i, field.expr)
                 }
                 None => {
                     tcx.sess.span_bug(field.span,
diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs
index d4066767ab8..c04e1c2515c 100644
--- a/src/librustc/middle/typeck/check/mod.rs
+++ b/src/librustc/middle/typeck/check/mod.rs
@@ -1872,7 +1872,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
                                       node_id: ast::node_id,
                                       substitutions: ty::substs,
                                       field_types: &[ty::field_ty],
-                                      ast_fields: &[ast::field],
+                                      ast_fields: &[ast::Field],
                                       check_completeness: bool)  {
         let tcx = fcx.ccx.tcx;
 
@@ -1888,21 +1888,21 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
         for ast_fields.iter().advance |field| {
             let mut expected_field_type = ty::mk_err();
 
-            let pair = class_field_map.find(&field.node.ident).
+            let pair = class_field_map.find(&field.ident).
                                        map_consume(|x| *x);
             match pair {
                 None => {
                     tcx.sess.span_err(
                         field.span,
                         fmt!("structure has no field named `%s`",
-                             tcx.sess.str_of(field.node.ident)));
+                             tcx.sess.str_of(field.ident)));
                     error_happened = true;
                 }
                 Some((_, true)) => {
                     tcx.sess.span_err(
                         field.span,
                         fmt!("field `%s` specified more than once",
-                             tcx.sess.str_of(field.node.ident)));
+                             tcx.sess.str_of(field.ident)));
                     error_happened = true;
                 }
                 Some((field_id, false)) => {
@@ -1910,7 +1910,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
                         ty::lookup_field_type(
                             tcx, class_id, field_id, &substitutions);
                     class_field_map.insert(
-                        field.node.ident, (field_id, true));
+                        field.ident, (field_id, true));
                     fields_found += 1;
                 }
             }
@@ -1918,7 +1918,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
             // an error, so we can continue typechecking
             check_expr_coercable_to_type(
                     fcx,
-                    field.node.expr,
+                    field.expr,
                     expected_field_type);
         }
 
@@ -1961,7 +1961,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
                                 id: ast::node_id,
                                 span: codemap::span,
                                 class_id: ast::def_id,
-                                fields: &[ast::field],
+                                fields: &[ast::Field],
                                 base_expr: Option<@ast::expr>) {
         let tcx = fcx.ccx.tcx;
 
@@ -2051,7 +2051,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
                                  span: codemap::span,
                                  enum_id: ast::def_id,
                                  variant_id: ast::def_id,
-                                 fields: &[ast::field]) {
+                                 fields: &[ast::Field]) {
         let tcx = fcx.ccx.tcx;
 
         // Look up the number of type parameters and the raw type, and
diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs
index d15e47e61b5..733e8093a9d 100644
--- a/src/librustc/util/common.rs
+++ b/src/librustc/util/common.rs
@@ -54,10 +54,10 @@ pub fn indenter() -> _indenter {
     _indenter(())
 }
 
-pub fn field_expr(f: ast::field) -> @ast::expr { return f.node.expr; }
+pub fn field_expr(f: ast::Field) -> @ast::expr { return f.expr; }
 
-pub fn field_exprs(fields: ~[ast::field]) -> ~[@ast::expr] {
-    fields.map(|f| f.node.expr)
+pub fn field_exprs(fields: ~[ast::Field]) -> ~[@ast::expr] {
+    fields.map(|f| f.expr)
 }
 
 // Takes a predicate p, returns true iff p is true for any subexpressions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 0874163118a..95691c334b1 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -409,13 +409,12 @@ pub struct arm {
 }
 
 #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
-pub struct field_ {
+pub struct Field {
     ident: ident,
     expr: @expr,
+    span: span,
 }
 
-pub type field = spanned<field_>;
-
 #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
 pub enum blk_check_mode {
     default_blk,
@@ -495,7 +494,7 @@ pub enum expr_ {
     expr_mac(mac),
 
     // A struct literal expression.
-    expr_struct(Path, ~[field], Option<@expr>),
+    expr_struct(Path, ~[Field], Option<@expr>),
 
     // A vector literal constructed from one repeated element.
     expr_repeat(@expr /* element */, @expr /* count */, mutability),
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs
index 3b32173dfb5..b3d65dfa9e2 100644
--- a/src/libsyntax/ext/build.rs
+++ b/src/libsyntax/ext/build.rs
@@ -107,9 +107,9 @@ pub trait AstBuilder {
                         args: ~[@ast::expr]) -> @ast::expr;
     fn expr_blk(&self, b: ast::Block) -> @ast::expr;
 
-    fn field_imm(&self, span: span, name: ident, e: @ast::expr) -> ast::field;
-    fn expr_struct(&self, span: span, path: ast::Path, fields: ~[ast::field]) -> @ast::expr;
-    fn expr_struct_ident(&self, span: span, id: ast::ident, fields: ~[ast::field]) -> @ast::expr;
+    fn field_imm(&self, span: span, name: ident, e: @ast::expr) -> ast::Field;
+    fn expr_struct(&self, span: span, path: ast::Path, fields: ~[ast::Field]) -> @ast::expr;
+    fn expr_struct_ident(&self, span: span, id: ast::ident, fields: ~[ast::Field]) -> @ast::expr;
 
     fn expr_lit(&self, sp: span, lit: ast::lit_) -> @ast::expr;
 
@@ -477,14 +477,14 @@ impl AstBuilder for @ExtCtxt {
     fn expr_blk(&self, b: ast::Block) -> @ast::expr {
         self.expr(b.span, ast::expr_block(b))
     }
-    fn field_imm(&self, span: span, name: ident, e: @ast::expr) -> ast::field {
-        respan(span, ast::field_ { ident: name, expr: e })
+    fn field_imm(&self, span: span, name: ident, e: @ast::expr) -> ast::Field {
+        ast::Field { ident: name, expr: e, span: span }
     }
-    fn expr_struct(&self, span: span, path: ast::Path, fields: ~[ast::field]) -> @ast::expr {
+    fn expr_struct(&self, span: span, path: ast::Path, fields: ~[ast::Field]) -> @ast::expr {
         self.expr(span, ast::expr_struct(path, fields, None))
     }
     fn expr_struct_ident(&self, span: span,
-                         id: ast::ident, fields: ~[ast::field]) -> @ast::expr {
+                         id: ast::ident, fields: ~[ast::Field]) -> @ast::expr {
         self.expr_struct(span, self.path_ident(span, id), fields)
     }
 
diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs
index 6af08d0a8d5..f27e68641e3 100644
--- a/src/libsyntax/fold.rs
+++ b/src/libsyntax/fold.rs
@@ -488,12 +488,10 @@ pub fn wrap<T>(f: @fn(&T, @ast_fold) -> T)
 }
 
 pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ {
-    fn fold_field_(field: field, fld: @ast_fold) -> field {
-        spanned {
-            node: ast::field_ {
-                ident: fld.fold_ident(field.node.ident),
-                expr: fld.fold_expr(field.node.expr),
-            },
+    fn fold_field_(field: Field, fld: @ast_fold) -> Field {
+        ast::Field {
+            ident: fld.fold_ident(field.ident),
+            expr: fld.fold_expr(field.expr),
             span: fld.new_span(field.span),
         }
     }
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 2e8e69561e8..a4fd4929400 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -29,7 +29,7 @@ use ast::{expr_method_call, expr_paren, expr_path, expr_repeat};
 use ast::{expr_ret, expr_self, expr_struct, expr_tup, expr_unary};
 use ast::{expr_vec, expr_vstore, expr_vstore_mut_box};
 use ast::{expr_vstore_slice, expr_vstore_box};
-use ast::{expr_vstore_mut_slice, expr_while, extern_fn, field, fn_decl};
+use ast::{expr_vstore_mut_slice, expr_while, extern_fn, Field, fn_decl};
 use ast::{expr_vstore_uniq, Onceness, Once, Many};
 use ast::{foreign_item, foreign_item_static, foreign_item_fn, foreign_mod};
 use ast::{ident, impure_fn, inherited, item, item_, item_static};
@@ -1498,15 +1498,16 @@ impl Parser {
     }
 
     // parse ident COLON expr
-    pub fn parse_field(&self) -> field {
+    pub fn parse_field(&self) -> Field {
         let lo = self.span.lo;
         let i = self.parse_ident();
         self.expect(&token::COLON);
         let e = self.parse_expr();
-        spanned(lo, e.span.hi, ast::field_ {
+        ast::Field {
             ident: i,
-            expr: e
-        })
+            expr: e,
+            span: mk_sp(lo, e.span.hi),
+        }
     }
 
     pub fn mk_expr(&self, lo: BytePos, hi: BytePos, node: expr_) -> @expr {
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 7918e503957..8e2c24cacfe 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -1103,14 +1103,14 @@ pub fn print_call_post(s: @ps,
 }
 
 pub fn print_expr(s: @ps, expr: &ast::expr) {
-    fn print_field(s: @ps, field: &ast::field) {
+    fn print_field(s: @ps, field: &ast::Field) {
         ibox(s, indent_unit);
-        print_ident(s, field.node.ident);
+        print_ident(s, field.ident);
         word_space(s, ":");
-        print_expr(s, field.node.expr);
+        print_expr(s, field.expr);
         end(s);
     }
-    fn get_span(field: &ast::field) -> codemap::span { return field.span; }
+    fn get_span(field: &ast::Field) -> codemap::span { return field.span; }
 
     maybe_print_comment(s, expr.span.lo);
     ibox(s, indent_unit);
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs
index ce707979c06..7e86adfcb63 100644
--- a/src/libsyntax/visit.rs
+++ b/src/libsyntax/visit.rs
@@ -474,7 +474,7 @@ pub fn visit_expr<E:Clone>(ex: @expr, (e, v): (E, vt<E>)) {
         expr_struct(ref p, ref flds, base) => {
             visit_path(p, (e.clone(), v));
             for flds.iter().advance |f| {
-                (v.visit_expr)(f.node.expr, (e.clone(), v));
+                (v.visit_expr)(f.expr, (e.clone(), v));
             }
             visit_expr_opt(base, (e.clone(), v));
         }