Parent
Part of #7 (Phase 5: Implement borrowing and lifetime inference).
Background
A reference must not outlive the value it points to. When a borrow is stored in a variable and the owner goes out of scope first, the reference becomes a dangling pointer. The lifetime checker must detect this and reject the program before it reaches codegen.
Spec reference: docs/design/spec.md §3, ADR 0001 · Crate: paco-borrow
What already exists
compiler/paco-borrow/src/lib.rs — lifetime scope tracking; detects borrows that escape their owner's scope.
compiler/paco-test-harness/src/lib.rs — golden test harness.
Scope
- Create
tests/conformance/phase_05/borrow_outlives_owner/input.paco — a main that creates a reference to a value defined in an inner block, then uses the reference after the inner block ends (owner dropped).
- Create
tests/conformance/phase_05/borrow_outlives_owner/expected.stderr with the lifetime error and span on the escaping reference.
- Create
tests/conformance/phase_05/borrow_outlives_owner/flags.toml with kind = "fail" and feature_min = 5.
Acceptance Criteria
Key files
tests/conformance/phase_05/borrow_outlives_owner/ — new test directory
compiler/paco-borrow/src/lib.rs — escape detection
compiler/paco-driver/tests/conformance.rs — conformance runner
Parent
Part of #7 (Phase 5: Implement borrowing and lifetime inference).
Background
A reference must not outlive the value it points to. When a borrow is stored in a variable and the owner goes out of scope first, the reference becomes a dangling pointer. The lifetime checker must detect this and reject the program before it reaches codegen.
Spec reference:
docs/design/spec.md §3, ADR 0001 · Crate:paco-borrowWhat already exists
compiler/paco-borrow/src/lib.rs— lifetime scope tracking; detects borrows that escape their owner's scope.compiler/paco-test-harness/src/lib.rs— golden test harness.Scope
tests/conformance/phase_05/borrow_outlives_owner/input.paco— amainthat creates a reference to a value defined in an inner block, then uses the reference after the inner block ends (owner dropped).tests/conformance/phase_05/borrow_outlives_owner/expected.stderrwith the lifetime error and span on the escaping reference.tests/conformance/phase_05/borrow_outlives_owner/flags.tomlwithkind = "fail"andfeature_min = 5.Acceptance Criteria
expected.stderrmatches actual stderr byte-for-byte.Key files
tests/conformance/phase_05/borrow_outlives_owner/— new test directorycompiler/paco-borrow/src/lib.rs— escape detectioncompiler/paco-driver/tests/conformance.rs— conformance runner