Skip to content

Commit 80922e5

Browse files
committed
---
yaml --- r: 5898 b: refs/heads/master c: fd5a083 h: refs/heads/master v: v3
1 parent 6081da8 commit 80922e5

File tree

8 files changed

+42
-51
lines changed

8 files changed

+42
-51
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: 6bcb4a426c80a3ee19e7b32f25942a54c43e4387
2+
refs/heads/master: fd5a08384d8ff297a50220df836f31610b23cf31

trunk/src/comp/middle/ast_map.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ fn map_fn(cx: ctx, f: _fn, _tp: [ty_param], _sp: codemap::span,
4646
}
4747

4848
fn map_local(cx: ctx, loc: @local) {
49-
for each p in ast_util::pat_bindings(loc.node.pat) {
49+
ast_util::pat_bindings(loc.node.pat) {|p|
5050
cx.map.insert(p.id, node_local(cx.local_id));
5151
cx.local_id += 1u;
52-
}
52+
};
5353
}
5454

5555
fn map_arm(cx: ctx, arm: arm) {
56-
for each p in ast_util::pat_bindings(arm.pats[0]) {
56+
ast_util::pat_bindings(arm.pats[0]) {|p|
5757
cx.map.insert(p.id, node_local(cx.local_id));
5858
cx.local_id += 1u;
59-
}
59+
};
6060
}
6161

6262
fn map_item(cx: ctx, i: @item) {

trunk/src/comp/middle/resolve.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -744,10 +744,10 @@ fn lookup_in_ty_params(name: ident, ty_params: [ast::ty_param]) ->
744744

745745
fn lookup_in_pat(name: ident, pat: @ast::pat) -> option::t<def_id> {
746746
let found = none;
747-
for each bound in ast_util::pat_bindings(pat) {
747+
ast_util::pat_bindings(pat) {|bound|
748748
let p_name = alt bound.node { ast::pat_bind(n) { n } };
749749
if str::eq(p_name, name) { found = some(local_def(bound.id)); }
750-
}
750+
};
751751
ret found;
752752
}
753753

@@ -1269,10 +1269,10 @@ fn check_item(e: @env, i: @ast::item, &&x: (), v: vt<()>) {
12691269
}
12701270

12711271
fn check_pat(ch: checker, p: @ast::pat) {
1272-
for each p in ast_util::pat_bindings(p) {
1272+
ast_util::pat_bindings(p) {|p|
12731273
let ident = alt p.node { pat_bind(n) { n } };
12741274
add_name(ch, p.span, ident);
1275-
}
1275+
};
12761276
}
12771277

12781278
fn check_arm(e: @env, a: ast::arm, &&x: (), v: vt<()>) {
@@ -1317,11 +1317,11 @@ fn check_block(e: @env, b: ast::blk, &&x: (), v: vt<()>) {
13171317
ast::decl_local(locs) {
13181318
let local_values = checker(*e, "value");
13191319
for (_, loc) in locs {
1320-
for each p in ast_util::pat_bindings(loc.node.pat) {
1320+
ast_util::pat_bindings(loc.node.pat) {|p|
13211321
let ident = alt p.node { pat_bind(n) { n } };
13221322
add_name(local_values, p.span, ident);
13231323
check_name(values, p.span, ident);
1324-
}
1324+
};
13251325
}
13261326
}
13271327
ast::decl_item(it) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,10 +1055,10 @@ type binding = {lhs: [inst], rhs: option::t<initializer>};
10551055

10561056
fn local_to_bindings(loc: @local) -> binding {
10571057
let lhs = [];
1058-
for each p: @pat in pat_bindings(loc.node.pat) {
1058+
pat_bindings(loc.node.pat) {|p|
10591059
let ident = alt p.node { pat_bind(name) { name } };
10601060
lhs += [{ident: ident, node: p.id}];
1061-
}
1061+
};
10621062
{lhs: lhs, rhs: loc.node.init}
10631063
}
10641064

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import syntax::ast_util::respan;
1313
type ctxt = {cs: @mutable [sp_constr], tcx: ty::ctxt};
1414

1515
fn collect_local(loc: @local, cx: ctxt, v: visit::vt<ctxt>) {
16-
for each p: @pat in pat_bindings(loc.node.pat) {
16+
pat_bindings(loc.node.pat) {|p|
1717
let ident = alt p.node { pat_bind(id) { id } };
1818
log "collect_local: pushing " + ident;;
1919
*cx.cs += [respan(loc.span, ninit(p.id, ident))];
20-
}
20+
};
2121
visit::visit_local(loc, cx, v);
2222
}
2323

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

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ fn find_pre_post_loop(fcx: fn_ctxt, l: @local, index: @expr, body: blk,
109109
id: node_id) {
110110
find_pre_post_expr(fcx, index);
111111
find_pre_post_block(fcx, body);
112-
for each p: @pat in pat_bindings(l.node.pat) {
112+
pat_bindings(l.node.pat) {|p|
113113
let ident = alt p.node { pat_bind(id) { id } };
114114
let v_init = ninit(p.id, ident);
115115
relax_precond_block(fcx, bit_num(fcx, v_init) as node_id, body);
116116
// Hack: for-loop index variables are frequently ignored,
117117
// so we pretend they're used
118118
use_var(fcx, p.id);
119-
}
119+
};
120120

121121
let loop_precond =
122122
seq_preconds(fcx, [expr_pp(fcx.ccx, index), block_pp(fcx.ccx, body)]);
@@ -577,9 +577,9 @@ fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) {
577577
/* LHS always becomes initialized,
578578
whether or not this is a move */
579579
find_pre_post_expr(fcx, an_init.expr);
580-
for each p: @pat in pat_bindings(alocal.node.pat) {
580+
pat_bindings(alocal.node.pat) {|p|
581581
copy_pre_post(fcx.ccx, p.id, an_init.expr);
582-
}
582+
};
583583
/* Inherit ann from initializer, and add var being
584584
initialized to the postcondition */
585585
copy_pre_post(fcx.ccx, id, an_init.expr);
@@ -590,18 +590,15 @@ fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) {
590590
_ { }
591591
}
592592

593-
for each pat: @pat in pat_bindings(alocal.node.pat) {
593+
pat_bindings(alocal.node.pat) {|pat|
594594
/* FIXME: This won't be necessary when typestate
595595
works well enough for pat_bindings to return a
596596
refinement-typed thing. */
597-
let ident =
598-
alt pat.node {
599-
pat_bind(n) { n }
600-
_ {
601-
fcx.ccx.tcx.sess.span_bug(pat.span,
602-
"Impossible LHS");
603-
}
604-
};
597+
let ident = alt pat.node {
598+
pat_bind(n) { n }
599+
_ { fcx.ccx.tcx.sess.span_bug(pat.span,
600+
"Impossible LHS"); }
601+
};
605602
alt p {
606603
some(p) {
607604
copy_in_postcond(fcx, id,
@@ -615,7 +612,7 @@ fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) {
615612
none. { }
616613
}
617614
gen(fcx, id, ninit(pat.id, ident));
618-
}
615+
};
619616

620617
if an_init.op == init_move && is_path(an_init.expr) {
621618
forget_in_postcond(fcx, id, an_init.expr.id);
@@ -628,7 +625,7 @@ fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) {
628625
seq_preconds(fcx, [prev_pp, e_pp]));
629626
/* Include the LHSs too, since those aren't in the
630627
postconds of the RHSs themselves */
631-
for each pat: @pat in pat_bindings(alocal.node.pat) {
628+
pat_bindings(alocal.node.pat) {|pat|
632629
alt pat.node {
633630
pat_bind(n) {
634631
set_in_postcond(bit_num(fcx, ninit(pat.id, n)),
@@ -639,14 +636,14 @@ fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) {
639636
"Impossible LHS");
640637
}
641638
}
642-
}
639+
};
643640
copy_pre_post_(fcx.ccx, id, prev_pp.precondition,
644641
prev_pp.postcondition);
645642
}
646643
none. {
647-
for each p: @pat in pat_bindings(alocal.node.pat) {
644+
pat_bindings(alocal.node.pat) {|p|
648645
clear_pp(node_id_to_ts_ann(fcx.ccx, p.id).conditions);
649-
}
646+
};
650647
clear_pp(node_id_to_ts_ann(fcx.ccx, id).conditions);
651648
}
652649
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,10 @@ fn find_pre_post_state_loop(fcx: fn_ctxt, pres: prestate, l: @local,
209209
// Make sure the index vars are considered initialized
210210
// in the body
211211
let index_post = tritv_clone(expr_poststate(fcx.ccx, index));
212-
for each p: @pat in pat_bindings(l.node.pat) {
212+
pat_bindings(l.node.pat) {|p|
213213
let ident = alt p.node { pat_bind(name) { name } };
214214
set_in_poststate_ident(fcx, p.id, ident, index_post);
215-
}
215+
};
216216

217217
changed |= find_pre_post_state_block(fcx, index_post, body);
218218

trunk/src/comp/syntax/ast_util.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,35 +48,29 @@ type pat_id_map = std::map::hashmap<str, node_id>;
4848
// use the node_id of their namesake in the first pattern.
4949
fn pat_id_map(pat: @pat) -> pat_id_map {
5050
let map = std::map::new_str_hash::<node_id>();
51-
for each bound in pat_bindings(pat) {
51+
pat_bindings(pat) {|bound|
5252
let name = alt bound.node { pat_bind(n) { n } };
5353
map.insert(name, bound.id);
54-
}
54+
};
5555
ret map;
5656
}
5757

5858
// FIXME: could return a constrained type
59-
iter pat_bindings(pat: @pat) -> @pat {
59+
fn pat_bindings(pat: @pat, it: block(@pat)) {
6060
alt pat.node {
61-
pat_bind(_) { put pat; }
62-
pat_tag(_, sub) {
63-
for p in sub { for each b in pat_bindings(p) { put b; } }
64-
}
65-
pat_rec(fields, _) {
66-
for f in fields { for each b in pat_bindings(f.pat) { put b; } }
67-
}
68-
pat_tup(elts) {
69-
for elt in elts { for each b in pat_bindings(elt) { put b; } }
70-
}
71-
pat_box(sub) { for each b in pat_bindings(sub) { put b; } }
72-
pat_uniq(sub) { for each b in pat_bindings(sub) { put b; } }
61+
pat_bind(_) { it(pat); }
62+
pat_tag(_, sub) { for p in sub { pat_bindings(p, it); } }
63+
pat_rec(fields, _) { for f in fields { pat_bindings(f.pat, it); } }
64+
pat_tup(elts) { for elt in elts { pat_bindings(elt, it); } }
65+
pat_box(sub) { pat_bindings(sub, it); }
66+
pat_uniq(sub) { pat_bindings(sub, it); }
7367
pat_wild. | pat_lit(_) | pat_range(_, _) { }
7468
}
7569
}
7670

7771
fn pat_binding_ids(pat: @pat) -> [node_id] {
7872
let found = [];
79-
for each b in pat_bindings(pat) { found += [b.id]; }
73+
pat_bindings(pat) {|b| found += [b.id]; };
8074
ret found;
8175
}
8276

0 commit comments

Comments
 (0)