Skip to content

Phase 5.1 — Conformance: multiple simultaneous shared borrows are allowed #40

Description

@whoisclebs

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

  • Compiles without borrow diagnostics.
  • Multiple & borrows of the same binding coexist without conflict.
  • Output matches expected.stdout byte-for-byte.
  • All previously passing conformance tests remain green.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/analysisType system, trait solver, borrow checker, pattern matchingenhancementNew feature or requestphase/5Phase 5: borrowing and lifetime inferencestatus/readyAll dependencies met — ready to implement

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions