Skip to content

Commit cd97f4e

Browse files
msullivanbrson
authored andcommitted
Fix handling of derived tydescs in bind.
In trans_bind_thunk, we need to load the tydescs from the environment *before* we try to construct derived tydescs from them.
1 parent 0beb271 commit cd97f4e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/comp/middle/trans.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5439,6 +5439,11 @@ fn trans_bind_thunk(&@local_ctxt cx, &span sp, &ty::t incoming_fty,
54395439
auto fcx = new_fn_ctxt(cx, sp, llthunk);
54405440
auto bcx = new_top_block_ctxt(fcx);
54415441
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);
54425447

54435448
// The 'llenv' that will arrive in the thunk we're creating is an
54445449
// 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,
54485453
// 'closure_ty', which was determined by trans_bind.
54495454
auto llclosure_ptr_ty =
54505455
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);
54525458

54535459
// "target", in this context, means the function that's having some of its
54545460
// 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,
54875493
let uint i = 0u;
54885494
while (i < ty_param_count) {
54895495
auto lltyparam_ptr =
5490-
GEP_tup_like(bcx, closure_ty, llclosure,
5496+
GEP_tup_like(copy_args_bcx, closure_ty, llclosure,
54915497
~[0, abi::box_rc_field_body,
54925498
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);
54955501
llargs += ~[td];
54965502
fcx.lltydescs += ~[td];
54975503
i += 1u;

0 commit comments

Comments
 (0)