2012-01-08 15:32:40 -06:00
|
|
|
fn main() {
|
2012-08-27 16:22:25 -05:00
|
|
|
let p = comm::Port::<uint>();
|
|
|
|
let ch = comm::Chan(p);
|
2012-01-08 15:32:40 -06:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2012-06-14 21:02:30 -05:00
|
|
|
task::spawn(fn~(copy ch, copy y, move x) {
|
2012-01-08 15:32:40 -06:00
|
|
|
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);
|
|
|
|
});
|
2012-02-28 15:40:35 -06:00
|
|
|
// Ensure last-use analysis doesn't move y to child.
|
|
|
|
let _q = y;
|
2012-01-08 15:32:40 -06:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|