Files
aji/tests/conformance/source/linear/linear_projection.aji
T

16 lines
564 B
Rust

// expect: reject E1001
// grant: heap=mem.alloc:64
// phase: 6
// spec: docs/spec/03-memory-model.md §25; docs/spec/15-source-language.md §16
module test.linear
// AIR twin: linear/field.air
struct Pair { value: own<u64>, tag: u64 }
fn main(heap: cap<mem.alloc>) -> u64 effects [mem.alloc] {
let owner = own.new(42u64, heap) or trap;
let record = Pair { value: move owner, tag: 1u64 };
let bad = record.value; // diagnostic here: record.value
let (part, tag) = struct.unpack(move record);
assert(tag == 1);
return own.take(move part);
}