28 lines
717 B
LLVM
28 lines
717 B
LLVM
; A guard passed through a block argument still depends on the mutex borrow it was locked through; ending that borrow while the guard is live is rejected.
|
|
; expect: reject E2102
|
|
; phase: 3
|
|
; spec: docs/spec/04-concurrency-and-atomics.md §40
|
|
module test.cfg_provenance_guard_parent
|
|
air 0
|
|
lang 0.1
|
|
features [cancellation, effects, ownership, sync, tasks]
|
|
|
|
fn @main() -> u64
|
|
effects [task.wait]
|
|
entry:
|
|
%z = const.u64 0
|
|
%m = mutex.make %z
|
|
%mr = borrow.ref %m
|
|
mutex.lock %mr, ok -> @locked, cancelled -> @out
|
|
locked(%g: guard<u64>):
|
|
br @next(%g)
|
|
next(%g2: guard<u64>):
|
|
borrow.end %mr
|
|
mutex.unlock %g2
|
|
%v = mutex.take %m
|
|
ret %v
|
|
out:
|
|
borrow.end %mr
|
|
%w = mutex.take %m
|
|
ret %w
|