Skip to content

Phase 5.2 — Conformance: mutable borrow allows field mutation #41

Description

@whoisclebs

Parent

Part of #7 (Phase 5: Implement borrowing and lifetime inference).

Background

A &mut borrow grants exclusive write access to a value. While a &mut borrow is live no other borrow — shared or mutable — may exist for the same place. This test verifies the positive case: a single &mut T reference correctly enables field mutation, and the aliasing rule is only violated when a second borrow is introduced, which is covered separately.

Spec reference: docs/design/spec.md §3, ADR 0001 · Crate: paco-borrow

What already exists

  • compiler/paco-borrow/src/lib.rs&mut loan analysis; mutation through the reference is permitted.
  • compiler/paco-test-harness/src/lib.rs — golden test harness.

Scope

  • Create tests/conformance/phase_05/mutable_borrow/input.paco — a fn increment(n: &mut int) that adds 1 to *n, and a main that calls it and prints the updated value.
  • Create tests/conformance/phase_05/mutable_borrow/expected.stdout with the incremented value.
  • Create tests/conformance/phase_05/mutable_borrow/flags.toml with kind = "run" and feature_min = 5.

Acceptance Criteria

  • Compiles without borrow diagnostics.
  • Field mutation through &mut is reflected in the original binding.
  • Output matches expected.stdout byte-for-byte.
  • All previously passing conformance tests remain green.

Key files

  • tests/conformance/phase_05/mutable_borrow/ — new test directory
  • compiler/paco-borrow/src/lib.rs — mutable-loan tracking
  • 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