Parent
Part of #7 (Phase 5: Implement borrowing and lifetime inference).
Background
The aliasing rule is the core safety invariant: a place may have either N shared borrows or exactly one mutable borrow, never both simultaneously. Creating a &mut borrow while a & borrow is live — or vice versa — is a hard compile error. This test targets that exact conflict.
Spec reference: docs/design/spec.md §3, ADR 0001 · Lint: borrow conflict · Crate: paco-borrow
What already exists
compiler/paco-borrow/src/lib.rs — aliasing-rule check; emits a borrow-conflict diagnostic when & and &mut coexist.
compiler/paco-test-harness/src/lib.rs — golden test harness.
Scope
- Create
tests/conformance/phase_05/borrow_conflict/input.paco — a main that holds a &string reference and then tries to take a &mut string on the same binding while the shared borrow is still live.
- Create
tests/conformance/phase_05/borrow_conflict/expected.stderr with the aliasing-rule diagnostic, citing both the existing shared borrow and the conflicting mutable borrow.
- Create
tests/conformance/phase_05/borrow_conflict/flags.toml with kind = "fail" and feature_min = 5.
Acceptance Criteria
Key files
tests/conformance/phase_05/borrow_conflict/ — new test directory
compiler/paco-borrow/src/lib.rs — aliasing-rule enforcement
compiler/paco-driver/tests/conformance.rs — conformance runner
Parent
Part of #7 (Phase 5: Implement borrowing and lifetime inference).
Background
The aliasing rule is the core safety invariant: a place may have either N shared borrows or exactly one mutable borrow, never both simultaneously. Creating a
&mutborrow while a&borrow is live — or vice versa — is a hard compile error. This test targets that exact conflict.Spec reference:
docs/design/spec.md §3, ADR 0001 · Lint: borrow conflict · Crate:paco-borrowWhat already exists
compiler/paco-borrow/src/lib.rs— aliasing-rule check; emits a borrow-conflict diagnostic when&and&mutcoexist.compiler/paco-test-harness/src/lib.rs— golden test harness.Scope
tests/conformance/phase_05/borrow_conflict/input.paco— amainthat holds a&stringreference and then tries to take a&mut stringon the same binding while the shared borrow is still live.tests/conformance/phase_05/borrow_conflict/expected.stderrwith the aliasing-rule diagnostic, citing both the existing shared borrow and the conflicting mutable borrow.tests/conformance/phase_05/borrow_conflict/flags.tomlwithkind = "fail"andfeature_min = 5.Acceptance Criteria
expected.stderrmatches actual stderr byte-for-byte.Key files
tests/conformance/phase_05/borrow_conflict/— new test directorycompiler/paco-borrow/src/lib.rs— aliasing-rule enforcementcompiler/paco-driver/tests/conformance.rs— conformance runner