Parent
Part of #7 (Phase 5: Implement borrowing and lifetime inference).
Background
The aliasing rule permits any number of simultaneous shared (&) borrows of the same value. This test confirms that creating two or more &T references to the same binding, passing them to functions, and reading through them all compiles without a borrow error.
Spec reference: docs/design/spec.md §3, ADR 0001 · Crate: paco-borrow
What already exists
compiler/paco-borrow/src/lib.rs — loan-set analysis; shared loans are additive, not conflicting.
compiler/paco-test-harness/src/lib.rs — golden test harness.
Scope
- Create
tests/conformance/phase_05/shared_borrows/input.paco — a main that creates two or three &string references to the same variable and passes them to a length(s: &string) -> int function.
- Create
tests/conformance/phase_05/shared_borrows/expected.stdout with the length values.
- Create
tests/conformance/phase_05/shared_borrows/flags.toml with kind = "run" and feature_min = 5.
Acceptance Criteria
Key files
tests/conformance/phase_05/shared_borrows/ — new test directory
compiler/paco-borrow/src/lib.rs — shared-loan analysis
compiler/paco-driver/tests/conformance.rs — conformance runner
Parent
Part of #7 (Phase 5: Implement borrowing and lifetime inference).
Background
The aliasing rule permits any number of simultaneous shared (
&) borrows of the same value. This test confirms that creating two or more&Treferences to the same binding, passing them to functions, and reading through them all compiles without a borrow error.Spec reference:
docs/design/spec.md §3, ADR 0001 · Crate:paco-borrowWhat already exists
compiler/paco-borrow/src/lib.rs— loan-set analysis; shared loans are additive, not conflicting.compiler/paco-test-harness/src/lib.rs— golden test harness.Scope
tests/conformance/phase_05/shared_borrows/input.paco— amainthat creates two or three&stringreferences to the same variable and passes them to alength(s: &string) -> intfunction.tests/conformance/phase_05/shared_borrows/expected.stdoutwith the length values.tests/conformance/phase_05/shared_borrows/flags.tomlwithkind = "run"andfeature_min = 5.Acceptance Criteria
&borrows of the same binding coexist without conflict.expected.stdoutbyte-for-byte.Key files
tests/conformance/phase_05/shared_borrows/— new test directorycompiler/paco-borrow/src/lib.rs— shared-loan analysiscompiler/paco-driver/tests/conformance.rs— conformance runner