Skip to content

Commit 93ce26b

Browse files
committed
---
yaml --- r: 2556 b: refs/heads/master c: 3760bfa h: refs/heads/master v: v3
1 parent 88f8dd8 commit 93ce26b

File tree

2 files changed

+14
-45
lines changed

2 files changed

+14
-45
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: ca51b49c0a0122b2efd827fa96a656a8b1641efa
2+
refs/heads/master: 3760bfab87498d71f9341ffac1aa027f26028656

trunk/src/comp/middle/typeck.rs

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,37 +1086,24 @@ mod Pushdown {
10861086
//
10871087
// TODO: enforce this via a predicate.
10881088

1089-
fn pushdown_pat(&@fn_ctxt fcx, &ty::t expected,
1090-
&@ast::pat pat) -> @ast::pat {
1091-
auto p_1;
1092-
1089+
fn pushdown_pat(&@fn_ctxt fcx, &ty::t expected, &@ast::pat pat) {
10931090
alt (pat.node) {
10941091
case (ast::pat_wild(?ann)) {
10951092
auto t = Demand::simple(fcx, pat.span, expected,
10961093
ann_to_type(fcx.ccx.node_types, ann));
1097-
p_1 = ast::pat_wild(ast::ann_type(ast::ann_tag(ann), t,
1098-
none[vec[ty::t]],
1099-
none[@ts_ann]));
11001094
write_type(fcx.ccx.node_types, ast::ann_tag(ann),
11011095
tup(none[vec[ty::t]], t));
11021096
}
11031097
case (ast::pat_lit(?lit, ?ann)) {
11041098
auto t = Demand::simple(fcx, pat.span, expected,
11051099
ann_to_type(fcx.ccx.node_types, ann));
1106-
p_1 = ast::pat_lit(lit, ast::ann_type(ast::ann_tag(ann), t,
1107-
none[vec[ty::t]],
1108-
none[@ts_ann]));
11091100
write_type(fcx.ccx.node_types, ast::ann_tag(ann),
11101101
tup(none[vec[ty::t]], t));
11111102
}
11121103
case (ast::pat_bind(?id, ?did, ?ann)) {
11131104
auto t = Demand::simple(fcx, pat.span, expected,
11141105
ann_to_type(fcx.ccx.node_types, ann));
11151106
fcx.locals.insert(did, t);
1116-
p_1 = ast::pat_bind(id, did, ast::ann_type(ast::ann_tag(ann),
1117-
t,
1118-
none[vec[ty::t]],
1119-
none[@ts_ann]));
11201107
write_type(fcx.ccx.node_types, ast::ann_tag(ann),
11211108
tup(none[vec[ty::t]], t));
11221109
}
@@ -1141,22 +1128,18 @@ mod Pushdown {
11411128
}
11421129
}
11431130

1144-
let vec[@ast::pat] subpats_1 = vec();
11451131
auto i = 0u;
11461132
for (@ast::pat subpat in subpats) {
1147-
subpats_1 += vec(pushdown_pat(fcx, arg_tys.(i), subpat));
1133+
pushdown_pat(fcx, arg_tys.(i), subpat);
11481134
i += 1u;
11491135
}
11501136

11511137
// TODO: push down type from "expected".
1152-
p_1 = ast::pat_tag(id, subpats_1, ann);
11531138
write_type(fcx.ccx.node_types, ast::ann_tag(ann),
11541139
ty::ann_to_ty_param_substs_opt_and_ty(fcx.ccx.node_types,
11551140
ann));
11561141
}
11571142
}
1158-
1159-
ret @fold::respan[ast::pat_](pat.span, p_1);
11601143
}
11611144

11621145
// Push-down over typed expressions. Note that the expression that you
@@ -1714,24 +1697,20 @@ fn check_lit(@crate_ctxt ccx, &@ast::lit lit) -> ty::t {
17141697
fail; // not reached
17151698
}
17161699

1717-
fn check_pat(&@fn_ctxt fcx, &@ast::pat pat) -> @ast::pat {
1718-
auto new_pat;
1700+
fn check_pat(&@fn_ctxt fcx, &@ast::pat pat) {
17191701
alt (pat.node) {
17201702
case (ast::pat_wild(?ann)) {
17211703
auto typ = next_ty_var(fcx.ccx);
17221704
write_type_only(fcx.ccx.node_types, ast::ann_tag(ann), typ);
1723-
new_pat = ast::pat_wild(triv_ann(ast::ann_tag(ann), typ));
17241705
}
17251706
case (ast::pat_lit(?lt, ?ann)) {
17261707
auto typ = check_lit(fcx.ccx, lt);
17271708
write_type_only(fcx.ccx.node_types, ast::ann_tag(ann), typ);
1728-
new_pat = ast::pat_lit(lt, triv_ann(ast::ann_tag(ann), typ));
17291709
}
17301710
case (ast::pat_bind(?id, ?def_id, ?a)) {
17311711
auto typ = next_ty_var(fcx.ccx);
17321712
auto ann = triv_ann(ast::ann_tag(a), typ);
17331713
write_type_only(fcx.ccx.node_types, ast::ann_tag(ann), typ);
1734-
new_pat = ast::pat_bind(id, def_id, ann);
17351714
}
17361715
case (ast::pat_tag(?p, ?subpats, ?old_ann)) {
17371716
auto vdef = ast::variant_def_ids
@@ -1763,14 +1742,10 @@ fn check_pat(&@fn_ctxt fcx, &@ast::pat pat) -> @ast::pat {
17631742
fail; // TODO: recover
17641743
}
17651744

1766-
let vec[@ast::pat] new_subpats = vec();
17671745
for (@ast::pat subpat in subpats) {
1768-
new_subpats += vec(check_pat(fcx, subpat));
1746+
check_pat(fcx, subpat);
17691747
}
17701748

1771-
new_pat = ast::pat_tag(p, new_subpats,
1772-
ast::ann_type(ast::ann_tag(old_ann), path_tpot._1,
1773-
path_tpot._0, none[@ts_ann]));
17741749
write_type(fcx.ccx.node_types, ast::ann_tag(old_ann),
17751750
path_tpot);
17761751
}
@@ -1790,17 +1765,12 @@ fn check_pat(&@fn_ctxt fcx, &@ast::pat pat) -> @ast::pat {
17901765
fail; // TODO: recover
17911766
}
17921767

1793-
new_pat = ast::pat_tag(p, subpats,
1794-
ast::ann_type(ast::ann_tag(old_ann), path_tpot._1,
1795-
path_tpot._0, none[@ts_ann]));
17961768
write_type(fcx.ccx.node_types, ast::ann_tag(old_ann),
17971769
path_tpot);
17981770
}
17991771
}
18001772
}
18011773
}
1802-
1803-
ret @fold::respan[ast::pat_](pat.span, new_pat);
18041774
}
18051775

18061776
fn require_impure(&session::session sess,
@@ -2427,17 +2397,16 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
24272397
auto pattern_ty = expr_ty(fcx.ccx.tcx, fcx.ccx.node_types,
24282398
expr_0);
24292399

2430-
let vec[@ast::pat] pats_0 = vec();
2400+
let vec[@ast::pat] pats = vec();
24312401
for (ast::arm arm in arms) {
2432-
auto pat_0 = check_pat(fcx, arm.pat);
2433-
pattern_ty = Demand::simple(fcx, pat_0.span, pattern_ty,
2434-
pat_ty(fcx.ccx.tcx, fcx.ccx.node_types, pat_0));
2435-
pats_0 += vec(pat_0);
2402+
check_pat(fcx, arm.pat);
2403+
pattern_ty = Demand::simple(fcx, arm.pat.span, pattern_ty,
2404+
pat_ty(fcx.ccx.tcx, fcx.ccx.node_types, arm.pat));
2405+
pats += vec(arm.pat);
24362406
}
24372407

2438-
let vec[@ast::pat] pats_1 = vec();
2439-
for (@ast::pat pat_0 in pats_0) {
2440-
pats_1 += vec(Pushdown::pushdown_pat(fcx, pattern_ty, pat_0));
2408+
for (@ast::pat pat in pats) {
2409+
Pushdown::pushdown_pat(fcx, pattern_ty, pat);
24412410
}
24422411

24432412
// Now typecheck the blocks.
@@ -2456,9 +2425,9 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
24562425
for (ast::block block_0 in blocks_0) {
24572426
auto block_1 = Pushdown::pushdown_block(fcx, result_ty,
24582427
block_0);
2459-
auto pat_1 = pats_1.(i);
2428+
auto pat = pats.(i);
24602429
auto arm = arms.(i);
2461-
auto arm_1 = rec(pat=pat_1, block=block_1);
2430+
auto arm_1 = rec(pat=pat, block=block_1);
24622431
arms_1 += vec(arm_1);
24632432
i += 1u;
24642433
}

0 commit comments

Comments
 (0)