@@ -5439,6 +5439,11 @@ fn trans_bind_thunk(&@local_ctxt cx, &span sp, &ty::t incoming_fty,
5439
5439
auto fcx = new_fn_ctxt( cx, sp, llthunk) ;
5440
5440
auto bcx = new_top_block_ctxt( fcx) ;
5441
5441
auto lltop = bcx. llbb;
5442
+ // Since we might need to construct derived tydescs that depend on
5443
+ // our bound tydescs, we need to load tydescs out of the environment
5444
+ // before derived tydescs are constructed. To do this, we load them
5445
+ // in the copy_args block.
5446
+ auto copy_args_bcx = new_raw_block_ctxt( fcx, fcx. llcopyargs) ;
5442
5447
5443
5448
// The 'llenv' that will arrive in the thunk we're creating is an
5444
5449
// environment that will contain the values of its arguments and a pointer
@@ -5448,7 +5453,8 @@ fn trans_bind_thunk(&@local_ctxt cx, &span sp, &ty::t incoming_fty,
5448
5453
// 'closure_ty', which was determined by trans_bind.
5449
5454
auto llclosure_ptr_ty =
5450
5455
type_of( cx. ccx, sp, ty:: mk_imm_box( cx. ccx. tcx, closure_ty) ) ;
5451
- auto llclosure = bcx. build. PointerCast ( fcx. llenv, llclosure_ptr_ty) ;
5456
+ auto llclosure = copy_args_bcx. build. PointerCast ( fcx. llenv,
5457
+ llclosure_ptr_ty) ;
5452
5458
5453
5459
// "target", in this context, means the function that's having some of its
5454
5460
// arguments bound and that will be called inside the thunk we're
@@ -5487,11 +5493,11 @@ fn trans_bind_thunk(&@local_ctxt cx, &span sp, &ty::t incoming_fty,
5487
5493
let uint i = 0 u;
5488
5494
while ( i < ty_param_count) {
5489
5495
auto lltyparam_ptr =
5490
- GEP_tup_like ( bcx , closure_ty, llclosure,
5496
+ GEP_tup_like ( copy_args_bcx , closure_ty, llclosure,
5491
5497
~[ 0 , abi:: box_rc_field_body,
5492
5498
abi:: closure_elt_ty_params, i as int] ) ;
5493
- bcx = lltyparam_ptr. bcx;
5494
- auto td = bcx . build. Load ( lltyparam_ptr. val) ;
5499
+ copy_args_bcx = lltyparam_ptr. bcx;
5500
+ auto td = copy_args_bcx . build. Load ( lltyparam_ptr. val) ;
5495
5501
llargs += ~[ td] ;
5496
5502
fcx. lltydescs += ~[ td] ;
5497
5503
i += 1 u;
0 commit comments