rust/src/test/run-pass/task-spawn-move-and-copy.rs
Tim Chevalier 39d9c30a15 Remove code from parser that was awaiting snapshot
Remove old parser functions as well as support for old-style capture
clauses. Remove remaining old-style capture clauses.
2012-06-14 19:09:02 -07:00

27 lines
660 B
Rust

fn main() {
let p = comm::port::<uint>();
let ch = comm::chan(p);
let x = ~1;
let x_in_parent = ptr::addr_of(*x) as uint;
let y = ~2;
let y_in_parent = ptr::addr_of(*y) as uint;
task::spawn(fn~(copy ch, copy y, move x) {
let x_in_child = ptr::addr_of(*x) as uint;
comm::send(ch, x_in_child);
let y_in_child = ptr::addr_of(*y) as uint;
comm::send(ch, y_in_child);
});
// Ensure last-use analysis doesn't move y to child.
let _q = y;
let x_in_child = comm::recv(p);
assert x_in_parent == x_in_child;
let y_in_child = comm::recv(p);
assert y_in_parent != y_in_child;
}