Skip to content

Phase 5.5 — Conformance: lifetime inference on single-input reference return needs no annotation #44

Description

@whoisclebs

Parent

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

Background

When a function takes a single reference parameter and returns a reference, the return can only borrow from that one input — the lifetime is unambiguous and the compiler infers it automatically without any annotation. This is the common case and should require zero explicit 'a syntax from the programmer.

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

What already exists

  • compiler/paco-borrow/src/lib.rs — single-input lifetime inference; infers return lifetime from the sole reference parameter.
  • compiler/paco-test-harness/src/lib.rs — golden test harness.

Scope

  • Create tests/conformance/phase_05/lifetime_inferred/input.paco — a first_word(s: &string) -> &string function that returns a slice of its input, and a main that calls it and prints the result. No 'a annotations.
  • Create tests/conformance/phase_05/lifetime_inferred/expected.stdout with the expected word.
  • Create tests/conformance/phase_05/lifetime_inferred/flags.toml with kind = "run" and feature_min = 5.

Acceptance Criteria

  • Compiles without any lifetime annotation.
  • Return value correctly reflects the input.
  • Output matches expected.stdout byte-for-byte.
  • All previously passing conformance tests remain green.

Key files

  • tests/conformance/phase_05/lifetime_inferred/ — new test directory
  • compiler/paco-borrow/src/lib.rs — single-input inference
  • 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