@@ -478,35 +478,29 @@ pub fn note_unique_llvm_symbol(ccx: &CrateContext, sym: ~str) {
478
478
pub fn get_res_dtor ( ccx : & CrateContext ,
479
479
did : ast:: DefId ,
480
480
parent_id : ast:: DefId ,
481
- substs : & [ ty:: t ] )
481
+ substs : & ty:: substs )
482
482
-> ValueRef {
483
483
let _icx = push_ctxt ( "trans_res_dtor" ) ;
484
484
let did = if did. krate != ast:: LOCAL_CRATE {
485
485
inline:: maybe_instantiate_inline ( ccx, did)
486
486
} else {
487
487
did
488
488
} ;
489
- if !substs. is_empty ( ) {
489
+
490
+ if !substs. tps . is_empty ( ) || !substs. self_ty . is_none ( ) {
490
491
assert_eq ! ( did. krate, ast:: LOCAL_CRATE ) ;
491
- let tsubsts = ty:: substs {
492
- regions : ty:: ErasedRegions ,
493
- self_ty : None ,
494
- tps : Vec :: from_slice ( substs) ,
495
- } ;
496
492
497
- let vtables = typeck:: check:: vtable:: trans_resolve_method ( ccx. tcx ( ) , did. node , & tsubsts ) ;
498
- let ( val, _) = monomorphize:: monomorphic_fn ( ccx, did, & tsubsts , vtables, None , None ) ;
493
+ let vtables = typeck:: check:: vtable:: trans_resolve_method ( ccx. tcx ( ) , did. node , substs ) ;
494
+ let ( val, _) = monomorphize:: monomorphic_fn ( ccx, did, substs , vtables, None , None ) ;
499
495
500
496
val
501
497
} else if did. krate == ast:: LOCAL_CRATE {
502
498
get_item_val ( ccx, did. node )
503
499
} else {
504
500
let tcx = ccx. tcx ( ) ;
505
501
let name = csearch:: get_symbol ( & ccx. sess ( ) . cstore , did) ;
506
- let class_ty = ty:: subst_tps ( tcx,
507
- substs,
508
- None ,
509
- ty:: lookup_item_type ( tcx, parent_id) . ty ) ;
502
+ let class_ty = ty:: subst ( tcx, substs,
503
+ ty:: lookup_item_type ( tcx, parent_id) . ty ) ;
510
504
let llty = type_of_dtor ( ccx, class_ty) ;
511
505
512
506
get_extern_fn ( & mut * ccx. externs . borrow_mut ( ) , ccx. llmod , name,
@@ -670,7 +664,7 @@ pub fn iter_structural_ty<'r,
670
664
repr : & adt:: Repr ,
671
665
av : ValueRef ,
672
666
variant : & ty:: VariantInfo ,
673
- tps : & [ ty:: t ] ,
667
+ substs : & ty:: substs ,
674
668
f : val_and_ty_fn < ' r , ' b > )
675
669
-> & ' b Block < ' b > {
676
670
let _icx = push_ctxt ( "iter_variant" ) ;
@@ -680,7 +674,7 @@ pub fn iter_structural_ty<'r,
680
674
for ( i, & arg) in variant. args . iter ( ) . enumerate ( ) {
681
675
cx = f ( cx,
682
676
adt:: trans_field_ptr ( cx, repr, av, variant. disr_val , i) ,
683
- ty:: subst_tps ( tcx, tps , None , arg) ) ;
677
+ ty:: subst ( tcx, substs , arg) ) ;
684
678
}
685
679
return cx;
686
680
}
@@ -722,7 +716,7 @@ pub fn iter_structural_ty<'r,
722
716
match adt:: trans_switch ( cx, & * repr, av) {
723
717
( _match:: single, None ) => {
724
718
cx = iter_variant ( cx, & * repr, av, & * * variants. get ( 0 ) ,
725
- substs. tps . as_slice ( ) , f) ;
719
+ substs, f) ;
726
720
}
727
721
( _match:: switch, Some ( lldiscrim_a) ) => {
728
722
cx = f ( cx, lldiscrim_a, ty:: mk_int ( ) ) ;
@@ -748,7 +742,7 @@ pub fn iter_structural_ty<'r,
748
742
& * repr,
749
743
av,
750
744
& * * variant,
751
- substs. tps . as_slice ( ) ,
745
+ substs,
752
746
|x, y, z| f ( x, y, z) ) ;
753
747
Br ( variant_cx, next_cx. llbb ) ;
754
748
}
@@ -1153,15 +1147,7 @@ pub fn new_fn_ctxt<'a>(ccx: &'a CrateContext,
1153
1147
} ,
1154
1148
id, param_substs. map( |s| s. repr( ccx. tcx( ) ) ) ) ;
1155
1149
1156
- let substd_output_type = match param_substs {
1157
- None => output_type,
1158
- Some ( substs) => {
1159
- ty:: subst_tps ( ccx. tcx ( ) ,
1160
- substs. tys . as_slice ( ) ,
1161
- substs. self_ty ,
1162
- output_type)
1163
- }
1164
- } ;
1150
+ let substd_output_type = output_type. substp ( ccx. tcx ( ) , param_substs) ;
1165
1151
let uses_outptr = type_of:: return_uses_outptr ( ccx, substd_output_type) ;
1166
1152
let debug_context = debuginfo:: create_function_debug_context ( ccx, id, param_substs, llfndecl) ;
1167
1153
@@ -1213,15 +1199,7 @@ pub fn init_function<'a>(fcx: &'a FunctionContext<'a>,
1213
1199
1214
1200
// This shouldn't need to recompute the return type,
1215
1201
// as new_fn_ctxt did it already.
1216
- let substd_output_type = match fcx. param_substs {
1217
- None => output_type,
1218
- Some ( substs) => {
1219
- ty:: subst_tps ( fcx. ccx . tcx ( ) ,
1220
- substs. tys . as_slice ( ) ,
1221
- substs. self_ty ,
1222
- output_type)
1223
- }
1224
- } ;
1202
+ let substd_output_type = output_type. substp ( fcx. ccx . tcx ( ) , fcx. param_substs ) ;
1225
1203
1226
1204
if !return_type_is_void ( fcx. ccx , substd_output_type) {
1227
1205
// If the function returns nil/bot, there is no real return
@@ -1508,18 +1486,8 @@ fn trans_enum_variant_or_tuple_like_struct(ccx: &CrateContext,
1508
1486
disr: ty:: Disr ,
1509
1487
param_substs: Option <& param_substs>,
1510
1488
llfndecl: ValueRef ) {
1511
- let ctor_ty = {
1512
- let no_substs: & [ ty:: t] = [ ] ;
1513
- let ty_param_substs: & [ ty:: t] = match param_substs {
1514
- Some ( substs) => substs. tys. as_slice( ) ,
1515
- None => no_substs
1516
- } ;
1517
-
1518
- ty:: subst_tps( ccx. tcx( ) ,
1519
- ty_param_substs,
1520
- None ,
1521
- ty:: node_id_to_type( ccx. tcx( ) , ctor_id) )
1522
- } ;
1489
+ let ctor_ty = ty:: node_id_to_type( ccx. tcx( ) , ctor_id) ;
1490
+ let ctor_ty = ctor_ty. substp( ccx. tcx( ) , param_substs) ;
1523
1491
1524
1492
let result_ty = match ty:: get( ctor_ty) . sty {
1525
1493
ty:: ty_bare_fn( ref bft) => bft. sig. output,
0 commit comments