24 lines
714 B
Rust
24 lines
714 B
Rust
// A waiting operation inside a `lock` block breaks the critical-section rule (E4304).
|
|
// expect: reject E4304
|
|
// phase: 6
|
|
// spec: docs/spec/15-source-language.md
|
|
module demo.wait_while_locked
|
|
// AIR twin: phase3/reject/sync_wait_while_locked.air
|
|
|
|
fn main(heap: cap<mem.alloc>) -> u64
|
|
effects [mem.alloc, task.wait]
|
|
{
|
|
let m = mutex.make(0u64);
|
|
match channel.make<u64>(1, heap) {
|
|
ok(tx, rx) => {
|
|
lock ref m as c {
|
|
*c = channel.recv(rx) or trap; // diagnostic here: channel.recv
|
|
} cancelled {}
|
|
channel.close_sender(move tx);
|
|
channel.close_receiver(move rx) or trap;
|
|
}
|
|
err(e) => { trap; }
|
|
}
|
|
mutex.take(move m)
|
|
}
|