Skip to content

Phase 4.5 — Conformance: drop order is reverse of declaration order within a scope #39

Description

@whoisclebs

Parent

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

Background

RAII (Resource Acquisition Is Initialization) means values are destroyed in reverse declaration order when their scope ends. The compiler inserts Drop calls in this order in the MIR/eval layer. This test verifies the drop order by using a struct whose drop method prints its name — the output order proves the order of destruction.

Spec reference: docs/design/spec.md §3 · Crates: paco-mir, paco-eval

What already exists

  • compiler/paco-eval/src/lib.rs — executes Drop calls in reverse declaration order at scope exit.
  • compiler/paco-test-harness/src/lib.rs — golden test harness.

Scope

  • Create tests/conformance/phase_04/drop_order/input.paco — a main that declares two or three named values with drop methods that print; verify the printed sequence is reverse of declaration order.
  • Create tests/conformance/phase_04/drop_order/expected.stdout showing drops in reverse order.
  • Create tests/conformance/phase_04/drop_order/flags.toml with kind = "run" and feature_min = 4.

Acceptance Criteria

  • Drop methods are called at scope exit.
  • Drop order is the reverse of declaration order.
  • Output matches expected.stdout byte-for-byte.
  • All previously passing conformance tests remain green.

Key files

  • tests/conformance/phase_04/drop_order/ — new test directory
  • compiler/paco-eval/src/lib.rs — drop-order execution
  • 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