Skip to content

Phase 4.2 — Conformance: double-move is rejected with use-after-move diagnostic #36

Description

@whoisclebs

Parent

Part of #6 (Phase 4: Implement ownership and move semantics).

Background

A double-move — moving the same value into two separate consumers — must be rejected at compile time. The borrow checker tracks the move state of each binding; once a value is marked MovedOut, any further use emits use-after-move. This test targets the most explicit form: two consecutive function calls each consuming the same variable.

Spec reference: docs/design/spec.md §3 · Lint: use-after-move · Crate: paco-borrow

What already exists

  • compiler/paco-borrow/src/lib.rs — definite-assignment dataflow; MovedOut state blocks subsequent reads.
  • compiler/paco-test-harness/src/lib.rs — golden test harness.

Scope

  • Create tests/conformance/phase_04/double_move/input.paco — a consume(s: string) function and main that passes the same string to consume twice.
  • Create tests/conformance/phase_04/double_move/expected.stderr with the use-after-move diagnostic on the second call.
  • Create tests/conformance/phase_04/double_move/flags.toml with kind = "fail" and feature_min = 4.

Acceptance Criteria

  • Compilation fails with use-after-move on the second call.
  • Span points at the second use (not the first).
  • expected.stderr matches actual stderr byte-for-byte.
  • All previously passing conformance tests remain green.

Key files

  • tests/conformance/phase_04/double_move/ — new test directory
  • compiler/paco-borrow/src/lib.rs — move-state 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/4Phase 4: ownership and move semanticsstatus/readyAll dependencies met — ready to implement

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions