@@ -177,10 +177,12 @@ fn ty_param_count_and_ty_for_def(&@fn_ctxt fcx, &ast::span sp, &ast::def defn)
177
177
}
178
178
}
179
179
180
+ type ty_param_substs_opt_and_ty = tup ( option:: t[ vec[ ty:: t ] ] , ty:: t ) ;
181
+
180
182
// Instantiates the given path, which must refer to an item with the given
181
183
// number of type parameters and type.
182
184
fn instantiate_path ( & @fn_ctxt fcx , & ast:: path pth, & ty_param_count_and_ty tpt,
183
- & span sp, uint ann_tag ) -> ast :: ann {
185
+ & span sp) -> ty_param_substs_opt_and_ty {
184
186
auto ty_param_count = tpt. _0 ;
185
187
auto t = bind_params_in_type ( fcx. ccx . tcx , tpt. _1 ) ;
186
188
@@ -211,7 +213,7 @@ fn instantiate_path(&@fn_ctxt fcx, &ast::path pth, &ty_param_count_and_ty tpt,
211
213
ty_substs_opt = some[ vec[ ty:: t] ] ( ty_substs) ;
212
214
}
213
215
214
- ret ast :: ann_type ( ann_tag , t , ty_substs_opt, none [ @ts_ann ] ) ;
216
+ ret tup ( ty_substs_opt, t ) ;
215
217
}
216
218
217
219
fn ast_mode_to_mode ( ast:: mode mode) -> ty:: mode {
@@ -1656,8 +1658,8 @@ fn check_pat(&@fn_ctxt fcx, &@ast::pat pat) -> @ast::pat {
1656
1658
1657
1659
auto tpt = ty:: lookup_item_type( fcx. ccx. sess, fcx. ccx. tcx,
1658
1660
fcx. ccx. type_cache, vdef. _0) ;
1659
- auto ann = instantiate_path ( fcx , p , tpt , pat . span ,
1660
- ast :: ann_tag ( old_ann ) ) ;
1661
+
1662
+ auto path_tpot = instantiate_path ( fcx , p , tpt , pat . span ) ;
1661
1663
1662
1664
alt ( struct ( fcx. ccx. tcx, t) ) {
1663
1665
// N-ary variants have function types.
@@ -1681,7 +1683,9 @@ fn check_pat(&@fn_ctxt fcx, &@ast::pat pat) -> @ast::pat {
1681
1683
new_subpats += vec( check_pat( fcx, subpat) ) ;
1682
1684
}
1683
1685
1684
- new_pat = ast:: pat_tag( p, new_subpats, ann) ;
1686
+ new_pat = ast:: pat_tag( p, new_subpats,
1687
+ ast:: ann_type( ast:: ann_tag( old_ann) , path_tpot. _1,
1688
+ path_tpot. _0, none[ @ts_ann] ) ) ;
1685
1689
}
1686
1690
1687
1691
// Nullary variants have tag types.
@@ -1699,7 +1703,9 @@ fn check_pat(&@fn_ctxt fcx, &@ast::pat pat) -> @ast::pat {
1699
1703
fail; // TODO: recover
1700
1704
}
1701
1705
1702
- new_pat = ast:: pat_tag( p, subpats, ann) ;
1706
+ new_pat = ast:: pat_tag( p, subpats,
1707
+ ast:: ann_type( ast:: ann_tag( old_ann) , path_tpot. _1,
1708
+ path_tpot. _0, none[ @ts_ann] ) ) ;
1703
1709
}
1704
1710
}
1705
1711
}
@@ -1946,10 +1952,11 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
1946
1952
auto tpt = ty_param_count_and_ty_for_def( fcx, expr. span, defn) ;
1947
1953
1948
1954
if ( ty:: def_has_ty_params( defn) ) {
1949
- auto ann = instantiate_path( fcx, pth, tpt, expr. span,
1950
- ast:: ann_tag( old_ann) ) ;
1955
+ auto path_tpot = instantiate_path( fcx, pth, tpt, expr. span) ;
1951
1956
ret @fold:: respan[ ast:: expr_] ( expr. span,
1952
- ast:: expr_path( pth, ann) ) ;
1957
+ ast:: expr_path( pth,
1958
+ ast:: ann_type( ast:: ann_tag( old_ann) , path_tpot. _1,
1959
+ path_tpot. _0, none[ @ts_ann] ) ) ) ;
1953
1960
}
1954
1961
1955
1962
// The definition doesn't take type parameters. If the programmer
0 commit comments