Skip to content

Commit 918664d

Browse files
committed
---
yaml --- r: 2469 b: refs/heads/master c: fe29d24 h: refs/heads/master i: 2467: 4fcf3dc v: v3
1 parent e3b5ec2 commit 918664d

File tree

7 files changed

+27
-37
lines changed

7 files changed

+27
-37
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: 5405f45274dc6dce53743092dc0679a5f43482d9
2+
refs/heads/master: fe29d24b6e795b3149e710659d12a8c9972bed96

trunk/src/comp/front/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ tag decl_ {
233233
decl_item(@item);
234234
}
235235
236-
type arm = rec(@pat pat, block block, hashmap[ident,def_id] index);
236+
type arm = rec(@pat pat, block block);
237237
238238
type elt = rec(mutability mut, @expr expr);
239239
type field = rec(mutability mut, ident ident, @expr expr);

trunk/src/comp/front/parser.rs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,9 +1367,8 @@ fn parse_alt_expr(parser p) -> @ast.expr {
13671367
expect(p, token.LPAREN);
13681368
auto pat = parse_pat(p);
13691369
expect(p, token.RPAREN);
1370-
auto index = index_arm(pat);
13711370
auto block = parse_block(p);
1372-
arms += vec(rec(pat=pat, block=block, index=index));
1371+
arms += vec(rec(pat=pat, block=block));
13731372
}
13741373

13751374
// FIXME: this is a vestigial form left over from
@@ -1384,9 +1383,8 @@ fn parse_alt_expr(parser p) -> @ast.expr {
13841383
p.bump();
13851384
auto hi = p.get_hi_pos();
13861385
auto pat = @spanned(lo, hi, ast.pat_wild(p.get_ann()));
1387-
auto index = index_arm(pat);
13881386
auto block = parse_block(p);
1389-
arms += vec(rec(pat=pat, block=block, index=index));
1387+
arms += vec(rec(pat=pat, block=block));
13901388
}
13911389
case (token.RBRACE) { /* empty */ }
13921390
case (?tok) {
@@ -1626,25 +1624,6 @@ fn parse_source_stmt(parser p) -> @ast.stmt {
16261624
fail;
16271625
}
16281626

1629-
fn index_arm(@ast.pat pat) -> hashmap[ast.ident,ast.def_id] {
1630-
fn do_index_arm(&hashmap[ast.ident,ast.def_id] index, @ast.pat pat) {
1631-
alt (pat.node) {
1632-
case (ast.pat_bind(?i, ?def_id, _)) { index.insert(i, def_id); }
1633-
case (ast.pat_wild(_)) { /* empty */ }
1634-
case (ast.pat_lit(_, _)) { /* empty */ }
1635-
case (ast.pat_tag(_, ?pats, _, _)) {
1636-
for (@ast.pat p in pats) {
1637-
do_index_arm(index, p);
1638-
}
1639-
}
1640-
}
1641-
}
1642-
1643-
auto index = new_str_hash[ast.def_id]();
1644-
do_index_arm(index, pat);
1645-
ret index;
1646-
}
1647-
16481627
fn stmt_to_expr(@ast.stmt stmt) -> Option.t[@ast.expr] {
16491628
alt (stmt.node) {
16501629
case (ast.stmt_expr(?e,_)) { ret some[@ast.expr](e); }

trunk/src/comp/middle/fold.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ fn fold_arm[ENV](&ENV env, &ast_fold[ENV] fld, &arm a) -> arm {
892892
let ENV env_ = fld.update_env_for_arm(env, a);
893893
auto ppat = fold_pat(env_, fld, a.pat);
894894
auto bblock = fold_block(env_, fld, a.block);
895-
ret rec(pat=ppat, block=bblock, index=a.index);
895+
ret rec(pat=ppat, block=bblock);
896896
}
897897

898898
fn fold_arg[ENV](&ENV env, &ast_fold[ENV] fld, &arg a) -> arg {

trunk/src/comp/middle/resolve.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -431,12 +431,7 @@ fn lookup_in_scope(&env e, list[scope] sc, ident id, namespace ns)
431431

432432
case (scope_arm(?a)) {
433433
if (ns == ns_value) {
434-
alt (a.index.find(id)) {
435-
case (some[def_id](?did)) {
436-
ret some(ast.def_binding(did));
437-
}
438-
case (_) {}
439-
}
434+
ret lookup_in_pat(id, *a.pat);
440435
}
441436
}
442437
}
@@ -470,6 +465,24 @@ fn lookup_in_ty_params(ident id, &vec[ast.ty_param] ty_params)
470465
ret none[def];
471466
}
472467

468+
fn lookup_in_pat(ident id, &ast.pat pat) -> Option.t[def] {
469+
alt (pat.node) {
470+
case (ast.pat_bind(?name, ?defid, _)) {
471+
if (Str.eq(name, id)) { ret some(ast.def_binding(defid)); }
472+
}
473+
case (ast.pat_wild(_)) {}
474+
case (ast.pat_lit(_, _)) {}
475+
case (ast.pat_tag(_, ?pats, _, _)) {
476+
for (@ast.pat p in pats) {
477+
auto found = lookup_in_pat(id, *p);
478+
if (found != none[def]) { ret found; }
479+
}
480+
}
481+
}
482+
ret none[def];
483+
}
484+
485+
473486
fn lookup_in_fn(ident id, &ast.fn_decl decl,
474487
&vec[ast.ty_param] ty_params, namespace ns) -> Option.t[def] {
475488
if (ns == ns_value) {

trunk/src/comp/middle/typeck.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,8 +1463,7 @@ mod Pushdown {
14631463
auto block_1 = pushdown_block(fcx, expected, arm_0.block);
14641464
t = Demand.simple(fcx, e.span, t,
14651465
block_ty(fcx.ccx.tcx, block_1));
1466-
auto arm_1 = rec(pat=arm_0.pat, block=block_1,
1467-
index=arm_0.index);
1466+
auto arm_1 = rec(pat=arm_0.pat, block=block_1);
14681467
arms_1 += vec(arm_1);
14691468
}
14701469
e_1 = ast.expr_alt(discrim, arms_1, triv_ann(t));
@@ -2266,7 +2265,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
22662265
block_0);
22672266
auto pat_1 = pats_1.(i);
22682267
auto arm = arms.(i);
2269-
auto arm_1 = rec(pat=pat_1, block=block_1, index=arm.index);
2268+
auto arm_1 = rec(pat=pat_1, block=block_1);
22702269
arms_1 += vec(arm_1);
22712270
i += 1u;
22722271
}

trunk/src/comp/middle/typestate_check.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,8 +2184,7 @@ fn annotate_decl(&fn_info_map fm, &@decl d) -> @decl {
21842184
fn annotate_alts(&fn_info_map fm, &vec[arm] alts) -> vec[arm] {
21852185
fn one(fn_info_map fm, &arm a) -> arm {
21862186
ret rec(pat=a.pat,
2187-
block=annotate_block(fm, a.block),
2188-
index=a.index);
2187+
block=annotate_block(fm, a.block));
21892188
}
21902189
auto f = bind one(fm,_);
21912190
ret Vec.map[arm, arm](f, alts);

0 commit comments

Comments
 (0)