Skip to content

Commit e791e80

Browse files
paulstansiferbrson
authored andcommitted
---
yaml --- r: 3194 b: refs/heads/master c: 391348e h: refs/heads/master v: v3
1 parent 58d0d6e commit e791e80

File tree

13 files changed

+76
-71
lines changed

13 files changed

+76
-71
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: d47101703e94fcce76c05d2713d44d0ecb65b16e
2+
refs/heads/master: 391348ec86ba40cfc05eb7a23d3dd1e58013f250

trunk/src/comp/front/ast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@ type local_ =
205205
def_id id,
206206
ann ann);
207207
208-
type local = spanned[@local_];
208+
type local = spanned[local_];
209209
210210
type decl = spanned[decl_];
211211
212-
tag decl_ { decl_local(@local_); decl_item(@item); }
212+
tag decl_ { decl_local(@local); decl_item(@item); }
213213
214214
type arm = rec(@pat pat, block block);
215215

trunk/src/comp/front/parser.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,11 +1265,11 @@ fn parse_else_expr(&parser p) -> @ast::expr {
12651265

12661266
fn parse_head_local(&parser p) -> @ast::local {
12671267
auto lo = p.get_lo_pos();
1268-
let @ast::local_ l =
1269-
if (is_word(p, "auto")) {
1270-
parse_auto_local(p)
1271-
} else { parse_typed_local(p) };
1272-
ret @spanned(lo, p.get_hi_pos(), l);
1268+
if (is_word(p, "auto")) {
1269+
ret parse_auto_local(p);
1270+
} else {
1271+
ret parse_typed_local(p);
1272+
}
12731273
}
12741274

12751275
fn parse_for_expr(&parser p) -> @ast::expr {
@@ -1444,23 +1444,27 @@ fn parse_pat(&parser p) -> @ast::pat {
14441444
ret @spanned(lo, hi, pat);
14451445
}
14461446

1447-
fn parse_local_full(&option::t[@ast::ty] tyopt, &parser p) -> @ast::local_ {
1447+
fn parse_local_full(&option::t[@ast::ty] tyopt, &parser p)
1448+
-> @ast::local {
1449+
auto lo = p.get_lo_pos();
14481450
auto ident = parse_value_ident(p);
14491451
auto init = parse_initializer(p);
1450-
ret @rec(ty=tyopt,
1451-
infer=false,
1452-
ident=ident,
1453-
init=init,
1454-
id=p.next_def_id(),
1455-
ann=p.get_ann());
1452+
ret @spanned(lo, p.get_hi_pos(),
1453+
rec(ty=tyopt,
1454+
infer=false,
1455+
ident=ident,
1456+
init=init,
1457+
id=p.next_def_id(),
1458+
ann=p.get_ann()));
1459+
14561460
}
14571461

1458-
fn parse_typed_local(&parser p) -> @ast::local_ {
1462+
fn parse_typed_local(&parser p) -> @ast::local {
14591463
auto ty = parse_ty(p);
14601464
ret parse_local_full(some(ty), p);
14611465
}
14621466

1463-
fn parse_auto_local(&parser p) -> @ast::local_ {
1467+
fn parse_auto_local(&parser p) -> @ast::local {
14641468
ret parse_local_full(none, p);
14651469
}
14661470

trunk/src/comp/middle/resolve.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ tag scope {
4141
scope_item(@ast::item);
4242
scope_fn(ast::fn_decl, vec[ast::ty_param]);
4343
scope_native_item(@ast::native_item);
44-
scope_loop(@ast::local_); // there's only 1 decl per loop.
45-
44+
scope_loop(@ast::local); // there's only 1 decl per loop.
4645
scope_block(ast::block);
4746
scope_arm(ast::arm);
4847
}
@@ -356,10 +355,10 @@ fn visit_expr_with_scope(&@ast::expr x, &scopes sc, &vt[scopes] v) {
356355
auto new_sc =
357356
alt (x.node) {
358357
case (ast::expr_for(?d, _, _, _)) {
359-
cons[scope](scope_loop(d.node), @sc)
358+
cons[scope](scope_loop(d), @sc)
360359
}
361360
case (ast::expr_for_each(?d, _, _, _)) {
362-
cons[scope](scope_loop(d.node), @sc)
361+
cons[scope](scope_loop(d), @sc)
363362
}
364363
case (ast::expr_fn(?f, _)) { cons(scope_fn(f.decl, []), @sc) }
365364
case (_) { sc }
@@ -575,8 +574,8 @@ fn lookup_in_scope(&env e, scopes sc, &span sp, &ident id, namespace ns) ->
575574
}
576575
case (scope_loop(?local)) {
577576
if (ns == ns_value) {
578-
if (str::eq(local.ident, id)) {
579-
ret some(ast::def_local(local.id));
577+
if (str::eq(local.node.ident, id)) {
578+
ret some(ast::def_local(local.node.id));
580579
}
581580
}
582581
}
@@ -680,8 +679,8 @@ fn lookup_in_block(&ident id, &ast::block_ b, namespace ns) ->
680679
case (ast::stmt_decl(?d, _)) {
681680
alt (d.node) {
682681
case (ast::decl_local(?loc)) {
683-
if (ns == ns_value && str::eq(id, loc.ident)) {
684-
ret some(ast::def_local(loc.id));
682+
if (ns == ns_value && str::eq(id, loc.node.ident)) {
683+
ret some(ast::def_local(loc.node.id));
685684
}
686685
}
687686
case (ast::decl_item(?it)) {
@@ -1169,7 +1168,7 @@ fn check_block(@env e, &ast::block b, &() x, &vt[()] v) {
11691168
case (ast::stmt_decl(?d, _)) {
11701169
alt (d.node) {
11711170
case (ast::decl_local(?loc)) {
1172-
add_name(values, d.span, loc.ident);
1171+
add_name(values, d.span, loc.node.ident);
11731172
}
11741173
case (ast::decl_item(?it)) {
11751174
alt (it.node) {

trunk/src/comp/middle/trans.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4026,7 +4026,7 @@ fn trans_if(&@block_ctxt cx, &@ast::expr cond, &ast::block thn,
40264026

40274027
fn trans_for(&@block_ctxt cx, &@ast::local local, &@ast::expr seq,
40284028
&ast::block body) -> result {
4029-
fn inner(&@block_ctxt cx, @ast::local_ local, ValueRef curr, ty::t t,
4029+
fn inner(&@block_ctxt cx, @ast::local local, ValueRef curr, ty::t t,
40304030
ast::block body, @block_ctxt outer_next_cx) -> result {
40314031
auto next_cx = new_sub_block_ctxt(cx, "next");
40324032
auto scope_cx =
@@ -4045,7 +4045,7 @@ fn trans_for(&@block_ctxt cx, &@ast::local local, &@ast::expr seq,
40454045
auto seq_res = trans_expr(cx, seq);
40464046
auto it =
40474047
iter_sequence(seq_res.bcx, seq_res.val, seq_ty,
4048-
bind inner(_, local.node, _, _, body, next_cx));
4048+
bind inner(_, local, _, _, body, next_cx));
40494049
it.bcx.build.Br(next_cx.llbb);
40504050
ret res(next_cx, it.val);
40514051
}
@@ -6440,15 +6440,15 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
64406440
ret res(bcx, pair);
64416441
}
64426442

6443-
fn init_local(&@block_ctxt cx, &@ast::local_ local) -> result {
6443+
fn init_local(&@block_ctxt cx, &@ast::local local) -> result {
64446444
// Make a note to drop this slot on the way out.
64456445

6446-
assert (cx.fcx.lllocals.contains_key(local.id));
6447-
auto llptr = cx.fcx.lllocals.get(local.id);
6448-
auto ty = node_ann_type(cx.fcx.lcx.ccx, local.ann);
6446+
assert (cx.fcx.lllocals.contains_key(local.node.id));
6447+
auto llptr = cx.fcx.lllocals.get(local.node.id);
6448+
auto ty = node_ann_type(cx.fcx.lcx.ccx, local.node.ann);
64496449
auto bcx = cx;
64506450
find_scope_cx(cx).cleanups += [clean(bind drop_slot(_, llptr, ty))];
6451-
alt (local.init) {
6451+
alt (local.node.init) {
64526452
case (some(?init)) {
64536453
alt (init.op) {
64546454
case (ast::init_assign) {
@@ -6595,8 +6595,7 @@ fn trans_block_cleanups(&@block_ctxt cx, &@block_ctxt cleanup_cx) ->
65956595
ret bcx;
65966596
}
65976597

6598-
iter block_locals(&ast::block b) -> @ast::local_ {
6599-
6598+
iter block_locals(&ast::block b) -> @ast::local {
66006599
// FIXME: putting from inside an iter block doesn't work, so we can't
66016600
// use the index here.
66026601
for (@ast::stmt s in b.node.stmts) {
@@ -6645,18 +6644,17 @@ fn alloc_ty(&@block_ctxt cx, &ty::t t) -> result {
66456644
ret res(cx, val);
66466645
}
66476646

6648-
fn alloc_local(&@block_ctxt cx, &@ast::local_ local) -> result {
6649-
auto t = node_ann_type(cx.fcx.lcx.ccx, local.ann);
6647+
fn alloc_local(&@block_ctxt cx, &@ast::local local) -> result {
6648+
auto t = node_ann_type(cx.fcx.lcx.ccx, local.node.ann);
66506649
auto r = alloc_ty(cx, t);
6651-
r.bcx.fcx.lllocals.insert(local.id, r.val);
6650+
r.bcx.fcx.lllocals.insert(local.node.id, r.val);
66526651
ret r;
66536652
}
66546653

66556654
fn trans_block(&@block_ctxt cx, &ast::block b, &out_method output) -> result {
66566655
auto bcx = cx;
6657-
for each (@ast::local_ local in block_locals(b)) {
6656+
for each (@ast::local local in block_locals(b)) {
66586657
// FIXME Update bcx.sp
6659-
66606658
bcx = alloc_local(bcx, local).bcx;
66616659
}
66626660
auto r = res(bcx, C_nil());

trunk/src/comp/middle/tstate/pre_post_conditions.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,20 +550,23 @@ fn find_pre_post_stmt(&fn_ctxt fcx, &stmt s) {
550550
case (stmt_decl(?adecl, ?a)) {
551551
alt (adecl.node) {
552552
case (decl_local(?alocal)) {
553-
alt (alocal.init) {
553+
alt (alocal.node.init) {
554554
case (some(?an_init)) {
555555
find_pre_post_expr(fcx, an_init.expr);
556-
copy_pre_post(fcx.ccx, alocal.ann, an_init.expr);
556+
copy_pre_post(fcx.ccx, alocal.node.ann,
557+
an_init.expr);
557558
/* Inherit ann from initializer, and add var being
558559
initialized to the postcondition */
559560

560561
copy_pre_post(fcx.ccx, a, an_init.expr);
561562
gen(fcx, a,
562-
rec(id=alocal.id, c=ninit(alocal.ident)));
563+
rec(id=alocal.node.id,
564+
c=ninit(alocal.node.ident)));
563565
}
564566
case (none) {
565567
clear_pp(ann_to_ts_ann(fcx.ccx,
566-
alocal.ann).conditions);
568+
alocal.node.ann)
569+
.conditions);
567570
clear_pp(ann_to_ts_ann(fcx.ccx, a).conditions);
568571
}
569572
}

trunk/src/comp/middle/tstate/states.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -663,25 +663,25 @@ fn find_pre_post_state_stmt(&fn_ctxt fcx, &prestate pres, @stmt s) -> bool {
663663
case (stmt_decl(?adecl, ?a)) {
664664
alt (adecl.node) {
665665
case (decl_local(?alocal)) {
666-
alt (alocal.init) {
666+
alt (alocal.node.init) {
667667
case (some(?an_init)) {
668668
changed =
669669
extend_prestate(stmt_ann.states.prestate,
670670
pres) || changed;
671671
changed =
672672
find_pre_post_state_expr(fcx, pres,
673-
an_init.expr) ||
674-
changed;
673+
an_init.expr)
674+
|| changed;
675675
changed =
676676
extend_poststate(stmt_ann.states.poststate,
677677
expr_poststate(fcx.ccx,
678678
an_init.expr))
679679
|| changed;
680680
changed =
681681
gen_poststate(fcx, a,
682-
rec(id=alocal.id,
683-
c=ninit(alocal.ident))) ||
684-
changed;
682+
rec(id=alocal.node.id,
683+
c=ninit(alocal.node.ident)))
684+
|| changed;
685685
log "Summary: stmt = ";
686686
log_stmt(*s);
687687
log "prestate = ";

trunk/src/comp/middle/ty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,8 +1577,8 @@ fn expr_has_ty_params(&ctxt cx, &@ast::expr expr) -> bool {
15771577
ret ann_has_type_params(cx, expr_ann(expr));
15781578
}
15791579

1580-
fn decl_local_ty(&ctxt cx, &@ast::local_ l) -> t {
1581-
ret ann_to_type(cx, l.ann);
1580+
fn decl_local_ty(&ctxt cx, &@ast::local l) -> t {
1581+
ret ann_to_type(cx, l.node.ann);
15821582
}
15831583

15841584
fn stmt_ann(&@ast::stmt s) -> ast::ann {

trunk/src/comp/middle/typeck.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,12 +1443,11 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
14431443
fn check_for_or_for_each(&@fn_ctxt fcx, &@ast::local local,
14441444
&ty::t element_ty, &ast::block body,
14451445
uint node_id) {
1446-
check_decl_local(fcx, local.node);
1446+
check_decl_local(fcx, local);
14471447
check_block(fcx, body);
14481448
// Unify type of decl with element type of the seq
1449-
14501449
demand::simple(fcx, local.span,
1451-
ty::decl_local_ty(fcx.ccx.tcx, local.node),
1450+
ty::decl_local_ty(fcx.ccx.tcx, local),
14521451
element_ty);
14531452
auto typ = ty::mk_nil(fcx.ccx.tcx);
14541453
write::ty_only_fixup(fcx, node_id, typ);
@@ -2239,24 +2238,26 @@ fn check_decl_initializer(&@fn_ctxt fcx, &ast::def_id lid,
22392238
}
22402239
}
22412240

2242-
fn check_decl_local(&@fn_ctxt fcx, &@ast::local_ local) -> @ast::local_ {
2243-
auto a_res = local.ann;
2244-
alt (fcx.locals.find(local.id)) {
2241+
fn check_decl_local(&@fn_ctxt fcx, &@ast::local local) -> @ast::local {
2242+
auto a_res = local.node.ann;
2243+
alt (fcx.locals.find(local.node.id)) {
22452244
case (none) {
2245+
22462246
fcx.ccx.tcx.sess.bug("check_decl_local: local id not found " +
2247-
local.ident);
2247+
local.node.ident);
22482248
}
22492249
case (some(?i)) {
22502250
auto t = ty::mk_var(fcx.ccx.tcx, i);
22512251
write::ty_only_fixup(fcx, a_res.id, t);
2252-
auto initopt = local.init;
2253-
alt (local.init) {
2252+
auto initopt = local.node.init;
2253+
alt (initopt) {
22542254
case (some(?init)) {
2255-
check_decl_initializer(fcx, local.id, init);
2255+
check_decl_initializer(fcx, local.node.id, init);
22562256
}
22572257
case (_) {/* fall through */ }
22582258
}
2259-
ret @rec(init=initopt, ann=a_res with *local);
2259+
auto newlocal = rec(init=initopt, ann=a_res with local.node);
2260+
ret @rec(node=newlocal, span=local.span);
22602261
}
22612262
}
22622263
}

trunk/src/comp/middle/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ fn visit_stmt[E](&@stmt s, &E e, &vt[E] v) {
236236
fn visit_decl[E](&@decl d, &E e, &vt[E] v) {
237237
alt (d.node) {
238238
case (decl_local(?loc)) {
239-
vt(v).visit_local(@respan(d.span, loc), e, v);
239+
vt(v).visit_local(loc, e, v);
240240
}
241241
case (decl_item(?it)) { vt(v).visit_item(it, e, v); }
242242
}

trunk/src/comp/middle/walk.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ fn walk_decl(&ast_visitor v, @ast::decl d) {
256256
if (!v.keep_going()) { ret; }
257257
v.visit_decl_pre(d);
258258
alt (d.node) {
259-
case (ast::decl_local(?loc)) { walk_local(v, @respan(d.span, loc)); }
259+
case (ast::decl_local(?loc)) { walk_local(v, loc); }
260260
case (ast::decl_item(?it)) { walk_item(v, it); }
261261
}
262262
v.visit_decl_post(d);

trunk/src/comp/pretty/pprust.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ fn print_decl(&ps s, &@ast::decl decl) {
864864
case (ast::decl_local(?loc)) {
865865
space(s.s);
866866
ibox(s, indent_unit);
867-
alt (loc.ty) {
867+
alt (loc.node.ty) {
868868
case (some(?ty)) {
869869
word_nbsp(s, "let");
870870
print_type(s, *ty);
@@ -877,15 +877,15 @@ fn print_decl(&ps s, &@ast::decl decl) {
877877
alt (s.mode) {
878878
case (mo_untyped) {/* no-op */ }
879879
case (mo_typed(?tcx)) {
880-
auto lty = ty::ann_to_type(tcx, loc.ann);
880+
auto lty = ty::ann_to_type(tcx, loc.node.ann);
881881
word_space(s, ppaux::ty_to_str(tcx, lty));
882882
}
883883
case (mo_identified) {/* no-op */ }
884884
}
885885
}
886886
}
887-
word(s.s, loc.ident);
888-
alt (loc.init) {
887+
word(s.s, loc.node.ident);
888+
alt (loc.node.init) {
889889
case (some(?init)) {
890890
space(s.s);
891891
alt (init.op) {

trunk/src/comp/util/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ fn has_nonlocal_exits(&ast::block b) -> bool {
164164
ret *has_exits;
165165
}
166166

167-
fn local_rhs_span(&@ast::local_ l, &span def) -> span {
168-
alt (l.init) {
167+
fn local_rhs_span(&@ast::local l, &span def) -> span {
168+
alt (l.node.init) {
169169
case (some(?i)) { ret i.expr.span; }
170170
case (_) { ret def; }
171171
}

0 commit comments

Comments
 (0)