@@ -4514,8 +4514,10 @@ fn trans_bind_thunk(cx: &@local_ctxt, sp: &span, incoming_fty: &ty::t,
4514
4514
let lltargetfn =
4515
4515
bcx. build . GEP ( lltarget. val , ~[ C_int ( 0 ) , C_int ( abi:: fn_field_code) ] ) ;
4516
4516
4517
- // Cast the outgoing function to the appropriate type (see the comments in
4518
- // trans_bind below for why this is necessary).
4517
+ // Cast the outgoing function to the appropriate type.
4518
+ // This is necessary because the type of the function that we have
4519
+ // in the closure does not know how many type descriptors the function
4520
+ // needs to take.
4519
4521
let lltargetty =
4520
4522
type_of_fn_from_ty ( bcx_ccx ( bcx) , sp, outgoing_fty, ty_param_count) ;
4521
4523
lltargetfn = bcx. build . PointerCast ( lltargetfn, T_ptr ( T_ptr ( lltargetty) ) ) ;
@@ -4625,21 +4627,12 @@ fn trans_bind_1(cx: &@block_ctxt, f: &@ast::expr, f_res: &lval_result,
4625
4627
bcx = bindings_tydesc. bcx ;
4626
4628
bcx. build . Store ( bindings_tydesc. val , bound_tydesc) ;
4627
4629
4628
- // Determine the LLVM type for the outgoing function type. This
4629
- // may be different from the type returned by trans_malloc_boxed()
4630
- // since we have more information than that function does;
4631
- // specifically, we know how many type descriptors the outgoing
4632
- // function has, which type_of() doesn't, as only we know which
4633
- // item the function refers to.
4634
- let llfnty = type_of_fn_from_ty ( bcx_ccx ( bcx) , cx. sp ,
4635
- outgoing_fty, ty_param_count) ;
4636
- let llclosurety = T_ptr ( T_fn_pair ( * bcx_ccx ( bcx) , llfnty) ) ;
4637
-
4638
4630
// Store thunk-target.
4639
4631
let bound_target =
4640
4632
bcx. build . GEP ( closure, ~[ C_int ( 0 ) , C_int ( abi:: closure_elt_target) ] ) ;
4641
- let src = bcx. build . Load ( f_res. res . val ) ;
4642
- bound_target = bcx. build . PointerCast ( bound_target, llclosurety) ;
4633
+ let llclosurety = T_ptr ( type_of ( bcx_ccx ( cx) , cx. sp , outgoing_fty) ) ;
4634
+ let src_loc = bcx. build . PointerCast ( f_res. res . val , llclosurety) ;
4635
+ let src = bcx. build . Load ( src_loc) ;
4643
4636
bcx. build . Store ( src, bound_target) ;
4644
4637
4645
4638
// Copy expr values into boxed bindings.
0 commit comments