Add a cleanup for copying closures. Closes #804.
This commit is contained in:
parent
9a5e9806f3
commit
66a255ac92
|
@ -6387,6 +6387,9 @@ fn trans_closure(bcx_maybe: &option::t[@block_ctxt],
|
|||
|
||||
let closure = create_real_fn_pair(env.bcx, option::get(llfnty),
|
||||
llfndecl, env.ptr);
|
||||
if copying {
|
||||
add_clean_temp(bcx, closure, node_id_type(cx.ccx, id))
|
||||
}
|
||||
some({fn_pair: closure, bcx: env.bcx})
|
||||
}
|
||||
_ { none }
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// Make sure we don't leak lambdas in silly ways.
|
||||
fn force(f: &fn()) { f() }
|
||||
fn main() {
|
||||
let x = 7;
|
||||
lambda() { log_err x; };
|
||||
force(lambda() { log_err x; });
|
||||
}
|
Loading…
Reference in New Issue