@@ -1086,37 +1086,24 @@ mod Pushdown {
1086
1086
//
1087
1087
// TODO: enforce this via a predicate.
1088
1088
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) {
1093
1090
alt ( pat. node ) {
1094
1091
case ( ast:: pat_wild ( ?ann) ) {
1095
1092
auto t = Demand :: simple ( fcx, pat. span , expected,
1096
1093
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] ) ) ;
1100
1094
write_type ( fcx. ccx . node_types , ast:: ann_tag ( ann) ,
1101
1095
tup ( none[ vec[ ty:: t] ] , t) ) ;
1102
1096
}
1103
1097
case ( ast:: pat_lit ( ?lit, ?ann) ) {
1104
1098
auto t = Demand :: simple ( fcx, pat. span , expected,
1105
1099
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] ) ) ;
1109
1100
write_type ( fcx. ccx . node_types , ast:: ann_tag ( ann) ,
1110
1101
tup ( none[ vec[ ty:: t] ] , t) ) ;
1111
1102
}
1112
1103
case ( ast:: pat_bind ( ?id, ?did, ?ann) ) {
1113
1104
auto t = Demand :: simple ( fcx, pat. span , expected,
1114
1105
ann_to_type ( fcx. ccx . node_types , ann) ) ;
1115
1106
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] ) ) ;
1120
1107
write_type ( fcx. ccx . node_types , ast:: ann_tag ( ann) ,
1121
1108
tup ( none[ vec[ ty:: t] ] , t) ) ;
1122
1109
}
@@ -1141,22 +1128,18 @@ mod Pushdown {
1141
1128
}
1142
1129
}
1143
1130
1144
- let vec[ @ast:: pat] subpats_1 = vec ( ) ;
1145
1131
auto i = 0 u;
1146
1132
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) ;
1148
1134
i += 1 u;
1149
1135
}
1150
1136
1151
1137
// TODO: push down type from "expected".
1152
- p_1 = ast:: pat_tag ( id, subpats_1, ann) ;
1153
1138
write_type ( fcx. ccx . node_types , ast:: ann_tag ( ann) ,
1154
1139
ty:: ann_to_ty_param_substs_opt_and_ty ( fcx. ccx . node_types ,
1155
1140
ann) ) ;
1156
1141
}
1157
1142
}
1158
-
1159
- ret @fold:: respan[ ast:: pat_] ( pat. span , p_1) ;
1160
1143
}
1161
1144
1162
1145
// 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 {
1714
1697
fail; // not reached
1715
1698
}
1716
1699
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) {
1719
1701
alt ( pat. node) {
1720
1702
case ( ast:: pat_wild( ?ann) ) {
1721
1703
auto typ = next_ty_var( fcx. ccx) ;
1722
1704
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) ) ;
1724
1705
}
1725
1706
case ( ast:: pat_lit( ?lt, ?ann) ) {
1726
1707
auto typ = check_lit( fcx. ccx, lt) ;
1727
1708
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) ) ;
1729
1709
}
1730
1710
case ( ast:: pat_bind( ?id, ?def_id, ?a) ) {
1731
1711
auto typ = next_ty_var( fcx. ccx) ;
1732
1712
auto ann = triv_ann( ast:: ann_tag( a) , typ) ;
1733
1713
write_type_only( fcx. ccx. node_types, ast:: ann_tag( ann) , typ) ;
1734
- new_pat = ast:: pat_bind( id, def_id, ann) ;
1735
1714
}
1736
1715
case ( ast:: pat_tag( ?p, ?subpats, ?old_ann) ) {
1737
1716
auto vdef = ast:: variant_def_ids
@@ -1763,14 +1742,10 @@ fn check_pat(&@fn_ctxt fcx, &@ast::pat pat) -> @ast::pat {
1763
1742
fail; // TODO: recover
1764
1743
}
1765
1744
1766
- let vec[ @ast:: pat] new_subpats = vec( ) ;
1767
1745
for ( @ast:: pat subpat in subpats) {
1768
- new_subpats += vec ( check_pat( fcx, subpat) ) ;
1746
+ check_pat( fcx, subpat) ;
1769
1747
}
1770
1748
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] ) ) ;
1774
1749
write_type( fcx. ccx. node_types, ast:: ann_tag( old_ann) ,
1775
1750
path_tpot) ;
1776
1751
}
@@ -1790,17 +1765,12 @@ fn check_pat(&@fn_ctxt fcx, &@ast::pat pat) -> @ast::pat {
1790
1765
fail; // TODO: recover
1791
1766
}
1792
1767
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] ) ) ;
1796
1768
write_type( fcx. ccx. node_types, ast:: ann_tag( old_ann) ,
1797
1769
path_tpot) ;
1798
1770
}
1799
1771
}
1800
1772
}
1801
1773
}
1802
-
1803
- ret @fold:: respan[ ast:: pat_] ( pat. span, new_pat) ;
1804
1774
}
1805
1775
1806
1776
fn require_impure( & session:: session sess,
@@ -2427,17 +2397,16 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
2427
2397
auto pattern_ty = expr_ty( fcx. ccx. tcx, fcx. ccx. node_types,
2428
2398
expr_0) ;
2429
2399
2430
- let vec[ @ast:: pat] pats_0 = vec( ) ;
2400
+ let vec[ @ast:: pat] pats = vec( ) ;
2431
2401
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 ) ;
2436
2406
}
2437
2407
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) ;
2441
2410
}
2442
2411
2443
2412
// Now typecheck the blocks.
@@ -2456,9 +2425,9 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
2456
2425
for ( ast:: block block_0 in blocks_0) {
2457
2426
auto block_1 = Pushdown :: pushdown_block( fcx, result_ty,
2458
2427
block_0) ;
2459
- auto pat_1 = pats_1 . ( i) ;
2428
+ auto pat = pats . ( i) ;
2460
2429
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) ;
2462
2431
arms_1 += vec( arm_1) ;
2463
2432
i += 1 u;
2464
2433
}
0 commit comments