Skip to content

Commit 5aee3e0

Browse files
De-spanned<T> and renamed ast::field (now ast::Field)
1 parent 4bd1424 commit 5aee3e0

File tree

16 files changed

+52
-61
lines changed

16 files changed

+52
-61
lines changed

src/librustc/middle/cfg/construct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ impl CFGBuilder {
374374
ast::expr_struct(_, ref fields, base) => {
375375
let base_exit = self.opt_expr(base, pred);
376376
let field_exprs: ~[@ast::expr] =
377-
fields.iter().transform(|f| f.node.expr).collect();
377+
fields.iter().transform(|f| f.expr).collect();
378378
self.straightline(expr, base_exit, field_exprs)
379379
}
380380

src/librustc/middle/const_eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub fn classify(e: &expr,
117117

118118
ast::expr_struct(_, ref fs, None) => {
119119
let cs = do fs.iter().transform |f| {
120-
classify(f.node.expr, tcx)
120+
classify(f.expr, tcx)
121121
};
122122
join_all(cs)
123123
}

src/librustc/middle/dataflow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
705705

706706
ast::expr_struct(_, ref fields, with_expr) => {
707707
for fields.iter().advance |field| {
708-
self.walk_expr(field.node.expr, in_out, loop_scopes);
708+
self.walk_expr(field.expr, in_out, loop_scopes);
709709
}
710710
self.walk_opt_expr(with_expr, in_out, loop_scopes);
711711
}

src/librustc/middle/liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ impl Liveness {
11611161
expr_struct(_, ref fields, with_expr) => {
11621162
let succ = self.propagate_through_opt_expr(with_expr, succ);
11631163
do fields.rev_iter().fold(succ) |succ, field| {
1164-
self.propagate_through_expr(field.node.expr, succ)
1164+
self.propagate_through_expr(field.expr, succ)
11651165
}
11661166
}
11671167

src/librustc/middle/moves.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ impl VisitContext {
394394

395395
expr_struct(_, ref fields, opt_with) => {
396396
for fields.iter().advance |field| {
397-
self.consume_expr(field.node.expr, visitor);
397+
self.consume_expr(field.expr, visitor);
398398
}
399399

400400
for opt_with.iter().advance |with_expr| {
@@ -417,7 +417,7 @@ impl VisitContext {
417417
// specified and (2) have a type that
418418
// moves-by-default:
419419
let consume_with = with_fields.iter().any(|tf| {
420-
!fields.iter().any(|f| f.node.ident == tf.ident) &&
420+
!fields.iter().any(|f| f.ident == tf.ident) &&
421421
ty::type_moves_by_default(self.tcx, tf.mt.ty)
422422
});
423423

src/librustc/middle/privacy.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
413413
Some(ref entry) => {
414414
debug!("(privacy checking) checking \
415415
impl method");
416-
check_method(expr.span,
417-
&entry.origin,
418-
ident);
416+
check_method(expr.span, &entry.origin, ident);
419417
}
420418
}
421419
}
@@ -433,8 +431,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
433431
for (*fields).iter().advance |field| {
434432
debug!("(privacy checking) checking \
435433
field in struct literal");
436-
check_field(expr.span, id,
437-
field.node.ident);
434+
check_field(expr.span, id, field.ident);
438435
}
439436
}
440437
}
@@ -448,8 +445,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
448445
checking field in \
449446
struct variant \
450447
literal");
451-
check_field(expr.span, variant_id,
452-
field.node.ident);
448+
check_field(expr.span, variant_id, field.ident);
453449
}
454450
}
455451
_ => {
@@ -499,8 +495,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
499495
for fields.iter().advance |field| {
500496
debug!("(privacy checking) checking \
501497
struct pattern");
502-
check_field(pattern.span, id,
503-
field.ident);
498+
check_field(pattern.span, id, field.ident);
504499
}
505500
}
506501
}
@@ -513,9 +508,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
513508
debug!("(privacy checking) \
514509
checking field in \
515510
struct variant pattern");
516-
check_field(pattern.span,
517-
variant_id,
518-
field.ident);
511+
check_field(pattern.span, variant_id, field.ident);
519512
}
520513
}
521514
_ => {

src/librustc/middle/trans/consts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,8 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef {
488488
do expr::with_field_tys(tcx, ety, Some(e.id))
489489
|discr, field_tys| {
490490
let cs = field_tys.map(|field_ty| {
491-
match fs.iter().find_(|f| field_ty.ident == f.node.ident) {
492-
Some(f) => const_expr(cx, (*f).node.expr),
491+
match fs.iter().find_(|f| field_ty.ident == f.ident) {
492+
Some(f) => const_expr(cx, (*f).expr),
493493
None => {
494494
cx.tcx.sess.span_bug(e.span, "missing struct field");
495495
}

src/librustc/middle/trans/expr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ pub fn with_field_tys<R>(tcx: ty::ctxt,
11241124
}
11251125

11261126
fn trans_rec_or_struct(bcx: block,
1127-
fields: &[ast::field],
1127+
fields: &[ast::Field],
11281128
base: Option<@ast::expr>,
11291129
expr_span: codemap::span,
11301130
id: ast::node_id,
@@ -1139,11 +1139,11 @@ fn trans_rec_or_struct(bcx: block,
11391139
let mut need_base = vec::from_elem(field_tys.len(), true);
11401140

11411141
let numbered_fields = do fields.map |field| {
1142-
let opt_pos = field_tys.iter().position(|field_ty| field_ty.ident == field.node.ident);
1142+
let opt_pos = field_tys.iter().position(|field_ty| field_ty.ident == field.ident);
11431143
match opt_pos {
11441144
Some(i) => {
11451145
need_base[i] = false;
1146-
(i, field.node.expr)
1146+
(i, field.expr)
11471147
}
11481148
None => {
11491149
tcx.sess.span_bug(field.span,

src/librustc/middle/typeck/check/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,7 +1872,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
18721872
node_id: ast::node_id,
18731873
substitutions: ty::substs,
18741874
field_types: &[ty::field_ty],
1875-
ast_fields: &[ast::field],
1875+
ast_fields: &[ast::Field],
18761876
check_completeness: bool) {
18771877
let tcx = fcx.ccx.tcx;
18781878

@@ -1888,37 +1888,37 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
18881888
for ast_fields.iter().advance |field| {
18891889
let mut expected_field_type = ty::mk_err();
18901890

1891-
let pair = class_field_map.find(&field.node.ident).
1891+
let pair = class_field_map.find(&field.ident).
18921892
map_consume(|x| *x);
18931893
match pair {
18941894
None => {
18951895
tcx.sess.span_err(
18961896
field.span,
18971897
fmt!("structure has no field named `%s`",
1898-
tcx.sess.str_of(field.node.ident)));
1898+
tcx.sess.str_of(field.ident)));
18991899
error_happened = true;
19001900
}
19011901
Some((_, true)) => {
19021902
tcx.sess.span_err(
19031903
field.span,
19041904
fmt!("field `%s` specified more than once",
1905-
tcx.sess.str_of(field.node.ident)));
1905+
tcx.sess.str_of(field.ident)));
19061906
error_happened = true;
19071907
}
19081908
Some((field_id, false)) => {
19091909
expected_field_type =
19101910
ty::lookup_field_type(
19111911
tcx, class_id, field_id, &substitutions);
19121912
class_field_map.insert(
1913-
field.node.ident, (field_id, true));
1913+
field.ident, (field_id, true));
19141914
fields_found += 1;
19151915
}
19161916
}
19171917
// Make sure to give a type to the field even if there's
19181918
// an error, so we can continue typechecking
19191919
check_expr_coercable_to_type(
19201920
fcx,
1921-
field.node.expr,
1921+
field.expr,
19221922
expected_field_type);
19231923
}
19241924

@@ -1961,7 +1961,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
19611961
id: ast::node_id,
19621962
span: codemap::span,
19631963
class_id: ast::def_id,
1964-
fields: &[ast::field],
1964+
fields: &[ast::Field],
19651965
base_expr: Option<@ast::expr>) {
19661966
let tcx = fcx.ccx.tcx;
19671967

@@ -2051,7 +2051,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
20512051
span: codemap::span,
20522052
enum_id: ast::def_id,
20532053
variant_id: ast::def_id,
2054-
fields: &[ast::field]) {
2054+
fields: &[ast::Field]) {
20552055
let tcx = fcx.ccx.tcx;
20562056

20572057
// Look up the number of type parameters and the raw type, and

src/librustc/util/common.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ pub fn indenter() -> _indenter {
5454
_indenter(())
5555
}
5656

57-
pub fn field_expr(f: ast::field) -> @ast::expr { return f.node.expr; }
57+
pub fn field_expr(f: ast::Field) -> @ast::expr { return f.expr; }
5858

59-
pub fn field_exprs(fields: ~[ast::field]) -> ~[@ast::expr] {
60-
fields.map(|f| f.node.expr)
59+
pub fn field_exprs(fields: ~[ast::Field]) -> ~[@ast::expr] {
60+
fields.map(|f| f.expr)
6161
}
6262

6363
// Takes a predicate p, returns true iff p is true for any subexpressions

src/libsyntax/ast.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,13 +409,12 @@ pub struct arm {
409409
}
410410

411411
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
412-
pub struct field_ {
412+
pub struct Field {
413413
ident: ident,
414414
expr: @expr,
415+
span: span,
415416
}
416417

417-
pub type field = spanned<field_>;
418-
419418
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
420419
pub enum blk_check_mode {
421420
default_blk,
@@ -495,7 +494,7 @@ pub enum expr_ {
495494
expr_mac(mac),
496495

497496
// A struct literal expression.
498-
expr_struct(Path, ~[field], Option<@expr>),
497+
expr_struct(Path, ~[Field], Option<@expr>),
499498

500499
// A vector literal constructed from one repeated element.
501500
expr_repeat(@expr /* element */, @expr /* count */, mutability),

src/libsyntax/ext/build.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ pub trait AstBuilder {
107107
args: ~[@ast::expr]) -> @ast::expr;
108108
fn expr_blk(&self, b: ast::Block) -> @ast::expr;
109109

110-
fn field_imm(&self, span: span, name: ident, e: @ast::expr) -> ast::field;
111-
fn expr_struct(&self, span: span, path: ast::Path, fields: ~[ast::field]) -> @ast::expr;
112-
fn expr_struct_ident(&self, span: span, id: ast::ident, fields: ~[ast::field]) -> @ast::expr;
110+
fn field_imm(&self, span: span, name: ident, e: @ast::expr) -> ast::Field;
111+
fn expr_struct(&self, span: span, path: ast::Path, fields: ~[ast::Field]) -> @ast::expr;
112+
fn expr_struct_ident(&self, span: span, id: ast::ident, fields: ~[ast::Field]) -> @ast::expr;
113113

114114
fn expr_lit(&self, sp: span, lit: ast::lit_) -> @ast::expr;
115115

@@ -477,14 +477,14 @@ impl AstBuilder for @ExtCtxt {
477477
fn expr_blk(&self, b: ast::Block) -> @ast::expr {
478478
self.expr(b.span, ast::expr_block(b))
479479
}
480-
fn field_imm(&self, span: span, name: ident, e: @ast::expr) -> ast::field {
481-
respan(span, ast::field_ { ident: name, expr: e })
480+
fn field_imm(&self, span: span, name: ident, e: @ast::expr) -> ast::Field {
481+
ast::Field { ident: name, expr: e, span: span }
482482
}
483-
fn expr_struct(&self, span: span, path: ast::Path, fields: ~[ast::field]) -> @ast::expr {
483+
fn expr_struct(&self, span: span, path: ast::Path, fields: ~[ast::Field]) -> @ast::expr {
484484
self.expr(span, ast::expr_struct(path, fields, None))
485485
}
486486
fn expr_struct_ident(&self, span: span,
487-
id: ast::ident, fields: ~[ast::field]) -> @ast::expr {
487+
id: ast::ident, fields: ~[ast::Field]) -> @ast::expr {
488488
self.expr_struct(span, self.path_ident(span, id), fields)
489489
}
490490

src/libsyntax/fold.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -488,12 +488,10 @@ pub fn wrap<T>(f: @fn(&T, @ast_fold) -> T)
488488
}
489489

490490
pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ {
491-
fn fold_field_(field: field, fld: @ast_fold) -> field {
492-
spanned {
493-
node: ast::field_ {
494-
ident: fld.fold_ident(field.node.ident),
495-
expr: fld.fold_expr(field.node.expr),
496-
},
491+
fn fold_field_(field: Field, fld: @ast_fold) -> Field {
492+
ast::Field {
493+
ident: fld.fold_ident(field.ident),
494+
expr: fld.fold_expr(field.expr),
497495
span: fld.new_span(field.span),
498496
}
499497
}

src/libsyntax/parse/parser.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use ast::{expr_method_call, expr_paren, expr_path, expr_repeat};
2929
use ast::{expr_ret, expr_self, expr_struct, expr_tup, expr_unary};
3030
use ast::{expr_vec, expr_vstore, expr_vstore_mut_box};
3131
use ast::{expr_vstore_slice, expr_vstore_box};
32-
use ast::{expr_vstore_mut_slice, expr_while, extern_fn, field, fn_decl};
32+
use ast::{expr_vstore_mut_slice, expr_while, extern_fn, Field, fn_decl};
3333
use ast::{expr_vstore_uniq, Onceness, Once, Many};
3434
use ast::{foreign_item, foreign_item_static, foreign_item_fn, foreign_mod};
3535
use ast::{ident, impure_fn, inherited, item, item_, item_static};
@@ -1498,15 +1498,16 @@ impl Parser {
14981498
}
14991499

15001500
// parse ident COLON expr
1501-
pub fn parse_field(&self) -> field {
1501+
pub fn parse_field(&self) -> Field {
15021502
let lo = self.span.lo;
15031503
let i = self.parse_ident();
15041504
self.expect(&token::COLON);
15051505
let e = self.parse_expr();
1506-
spanned(lo, e.span.hi, ast::field_ {
1506+
ast::Field {
15071507
ident: i,
1508-
expr: e
1509-
})
1508+
expr: e,
1509+
span: mk_sp(lo, e.span.hi),
1510+
}
15101511
}
15111512

15121513
pub fn mk_expr(&self, lo: BytePos, hi: BytePos, node: expr_) -> @expr {

src/libsyntax/print/pprust.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,14 +1103,14 @@ pub fn print_call_post(s: @ps,
11031103
}
11041104

11051105
pub fn print_expr(s: @ps, expr: &ast::expr) {
1106-
fn print_field(s: @ps, field: &ast::field) {
1106+
fn print_field(s: @ps, field: &ast::Field) {
11071107
ibox(s, indent_unit);
1108-
print_ident(s, field.node.ident);
1108+
print_ident(s, field.ident);
11091109
word_space(s, ":");
1110-
print_expr(s, field.node.expr);
1110+
print_expr(s, field.expr);
11111111
end(s);
11121112
}
1113-
fn get_span(field: &ast::field) -> codemap::span { return field.span; }
1113+
fn get_span(field: &ast::Field) -> codemap::span { return field.span; }
11141114

11151115
maybe_print_comment(s, expr.span.lo);
11161116
ibox(s, indent_unit);

src/libsyntax/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ pub fn visit_expr<E:Clone>(ex: @expr, (e, v): (E, vt<E>)) {
474474
expr_struct(ref p, ref flds, base) => {
475475
visit_path(p, (e.clone(), v));
476476
for flds.iter().advance |f| {
477-
(v.visit_expr)(f.node.expr, (e.clone(), v));
477+
(v.visit_expr)(f.expr, (e.clone(), v));
478478
}
479479
visit_expr_opt(base, (e.clone(), v));
480480
}

0 commit comments

Comments
 (0)