Skip to content

Commit 601c299

Browse files
committed
Fix closures over known-size polymorphic values.
1 parent a32f287 commit 601c299

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/comp/middle/trans.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5199,9 +5199,10 @@ fn trans_expr_out(cx: &@block_ctxt, e: &@ast::expr, output: out_method) ->
51995199
let fn_pair =
52005200
alt fn_res {
52015201
some(fn_pair) { fn_pair }
5202-
none. { create_fn_pair(ccx, s, llfnty, llfn, false) }
5202+
none. { {fn_pair: create_fn_pair(ccx, s, llfnty, llfn, false),
5203+
bcx: cx} }
52035204
};
5204-
ret rslt(cx, fn_pair);
5205+
ret rslt(fn_pair.bcx, fn_pair.fn_pair);
52055206
}
52065207
ast::expr_block(blk) {
52075208
let sub_cx = new_scope_block_ctxt(cx, "block-expr body");
@@ -6446,8 +6447,8 @@ fn finish_fn(fcx: &@fn_ctxt, lltop: BasicBlockRef) {
64466447
fn trans_closure(bcx_maybe: &option::t[@block_ctxt],
64476448
llfnty: &option::t[TypeRef], cx: @local_ctxt, sp: &span,
64486449
f: &ast::_fn, llfndecl: ValueRef, ty_self: option::t[ty::t],
6449-
ty_params: &ast::ty_param[], id: ast::node_id) ->
6450-
option::t[ValueRef] {
6450+
ty_params: &ast::ty_param[], id: ast::node_id)
6451+
-> option::t[{fn_pair: ValueRef, bcx: @block_ctxt}] {
64516452
set_uwtable(llfndecl);
64526453

64536454
// Set up arguments to the function.
@@ -6464,28 +6465,27 @@ fn trans_closure(bcx_maybe: &option::t[@block_ctxt],
64646465
copy_args_to_allocas(fcx, f.decl.inputs, arg_tys);
64656466

64666467
// Figure out if we need to build a closure and act accordingly
6467-
let closure = none;
6468-
alt f.proto {
6468+
let res = alt f.proto {
64696469
ast::proto_block. | ast::proto_closure. {
64706470
let bcx = option::get(bcx_maybe);
64716471
let upvars = get_freevars(cx.ccx.tcx, id);
64726472

6473-
let llenvptr = if (f.proto == ast::proto_block) {
6473+
let env = if (f.proto == ast::proto_block) {
64746474
let llenv = build_environment(bcx, upvars);
64756475
load_environment(bcx, fcx, llenv.ptrty, upvars);
6476-
llenv.ptr
6476+
{ptr: llenv.ptr, bcx: bcx}
64776477
} else {
64786478
let llenv = build_copying_closure(bcx, upvars);
64796479
load_environment_heap(bcx, fcx, llenv.ptrty, upvars);
6480-
llenv.ptr
6480+
{ptr: llenv.ptr, bcx: llenv.bcx}
64816481
};
64826482

6483-
closure =
6484-
some(create_real_fn_pair(bcx, option::get(llfnty), llfndecl,
6485-
llenvptr));
6483+
let closure = create_real_fn_pair(env.bcx, option::get(llfnty),
6484+
llfndecl, env.ptr);
6485+
some({fn_pair: closure, bcx: env.bcx})
64866486
}
6487-
_ { }
6488-
}
6487+
_ { none }
6488+
};
64896489

64906490
// Create the first basic block in the function and keep a handle on it to
64916491
// pass to finish_fn later.
@@ -6520,7 +6520,7 @@ fn trans_closure(bcx_maybe: &option::t[@block_ctxt],
65206520
// Insert the mandatory first few basic blocks before lltop.
65216521
finish_fn(fcx, lltop);
65226522

6523-
ret closure;
6523+
ret res;
65246524
}
65256525

65266526
fn trans_fn_inner(cx: @local_ctxt, sp: &span, f: &ast::_fn,

0 commit comments

Comments
 (0)