@@ -27,6 +27,7 @@ use trans::monomorphize;
27
27
use trans:: type_:: Type ;
28
28
use trans:: type_of:: * ;
29
29
use trans:: type_of;
30
+ use middle:: infer;
30
31
use middle:: ty:: { self , Ty } ;
31
32
use middle:: subst:: Substs ;
32
33
@@ -254,6 +255,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
254
255
_ => ccx. sess ( ) . bug ( "trans_native_call called on non-function type" )
255
256
} ;
256
257
let fn_sig = ccx. tcx ( ) . erase_late_bound_regions ( fn_sig) ;
258
+ let fn_sig = infer:: normalize_associated_type ( ccx. tcx ( ) , & fn_sig) ;
257
259
let llsig = foreign_signature ( ccx, & fn_sig, & passed_arg_tys[ ..] ) ;
258
260
let fn_type = cabi:: compute_abi_info ( ccx,
259
261
& llsig. llarg_tys ,
@@ -558,15 +560,15 @@ pub fn register_rust_fn_with_foreign_abi(ccx: &CrateContext,
558
560
-> ValueRef {
559
561
let _icx = push_ctxt ( "foreign::register_foreign_fn" ) ;
560
562
561
- let tys = foreign_types_for_id ( ccx, node_id) ;
562
- let llfn_ty = lltype_for_fn_from_foreign_types ( ccx, & tys) ;
563
563
let t = ccx. tcx ( ) . node_id_to_type ( node_id) ;
564
564
let cconv = match t. sty {
565
565
ty:: TyBareFn ( _, ref fn_ty) => {
566
566
llvm_calling_convention ( ccx, fn_ty. abi )
567
567
}
568
568
_ => panic ! ( "expected bare fn in register_rust_fn_with_foreign_abi" )
569
569
} ;
570
+ let tys = foreign_types_for_fn_ty ( ccx, t) ;
571
+ let llfn_ty = lltype_for_fn_from_foreign_types ( ccx, & tys) ;
570
572
let llfn = base:: register_fn_llvmty ( ccx, sp, sym, node_id, cconv, llfn_ty) ;
571
573
add_argument_attributes ( & tys, llfn) ;
572
574
debug ! ( "register_rust_fn_with_foreign_abi(node_id={}, llfn_ty={}, llfn={})" ,
@@ -937,18 +939,14 @@ fn foreign_signature<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
937
939
}
938
940
}
939
941
940
- fn foreign_types_for_id < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
941
- id : ast:: NodeId ) -> ForeignTypes < ' tcx > {
942
- foreign_types_for_fn_ty ( ccx, ccx. tcx ( ) . node_id_to_type ( id) )
943
- }
944
-
945
942
fn foreign_types_for_fn_ty < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
946
943
ty : Ty < ' tcx > ) -> ForeignTypes < ' tcx > {
947
944
let fn_sig = match ty. sty {
948
945
ty:: TyBareFn ( _, ref fn_ty) => & fn_ty. sig ,
949
946
_ => ccx. sess ( ) . bug ( "foreign_types_for_fn_ty called on non-function type" )
950
947
} ;
951
948
let fn_sig = ccx. tcx ( ) . erase_late_bound_regions ( fn_sig) ;
949
+ let fn_sig = infer:: normalize_associated_type ( ccx. tcx ( ) , & fn_sig) ;
952
950
let llsig = foreign_signature ( ccx, & fn_sig, & fn_sig. inputs ) ;
953
951
let fn_ty = cabi:: compute_abi_info ( ccx,
954
952
& llsig. llarg_tys ,
0 commit comments