28 lines
831 B
Rust
28 lines
831 B
Rust
// After an island is sent, the sender holds nothing that reaches it.
|
|
// expect: reject E2001
|
|
// phase: 6
|
|
// spec: docs/spec/03-memory-model.md
|
|
module demo.use_after_send
|
|
// AIR twin: phase4/reject/island_use_after_send.air
|
|
|
|
fn main(heap: cap<mem.alloc>) -> u64
|
|
effects [mem.alloc, task.wait]
|
|
{
|
|
match channel.make<island<u64>>(1, heap) {
|
|
ok(tx, rx) => {
|
|
let isl = island.create(1u64, heap) or trap;
|
|
channel.send(tx, move isl) or trap;
|
|
{
|
|
ref g = isl; // diagnostic here
|
|
let r = island.root(g);
|
|
}
|
|
channel.close_sender(move tx);
|
|
let back = channel.recv(rx) or trap;
|
|
island.destroy(move back);
|
|
channel.close_receiver(move rx) or trap;
|
|
0
|
|
}
|
|
err(e) => { trap; }
|
|
}
|
|
}
|