Skip to content

Phase 5.6 — Conformance: ambiguous multi-input lifetime produces diagnostic with suggested annotation #45

Description

@whoisclebs

Parent

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

Background

When a function takes two or more reference parameters and returns a reference, inference cannot determine which input the return borrows from without additional information. The compiler must reject the ambiguous form and include the exact 'a annotation to paste in the diagnostic — the developer confirms, not guesses. This is the key ergonomics guarantee of Paco's lifetime model.

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 — ambiguity detection; emits the suggested annotation in the diagnostic text.
  • compiler/paco-test-harness/src/lib.rs — golden test harness.

Scope

  • Create tests/conformance/phase_05/lifetime_ambiguous/input.paco — a pick(x: &string, y: &string) -> &string function with two reference inputs. No annotation.
  • Create tests/conformance/phase_05/lifetime_ambiguous/expected.stderr — the lifetime error including a help: line with the suggested 'a annotation.
  • Create tests/conformance/phase_05/lifetime_ambiguous/flags.toml with kind = "fail" and feature_min = 5.
  • Also create tests/conformance/phase_05/lifetime_explicit/ — the corrected version with explicit 'a annotations that compiles and runs.

Acceptance Criteria

  • Ambiguous version fails with a lifetime-ambiguity diagnostic.
  • Diagnostic includes a concrete suggested annotation.
  • Explicit version compiles and produces correct output.
  • Both golden tests added.
  • All previously passing conformance tests remain green.

Key files

  • tests/conformance/phase_05/lifetime_ambiguous/ — must-fail test
  • tests/conformance/phase_05/lifetime_explicit/ — fixed version
  • compiler/paco-borrow/src/lib.rs — ambiguity detection and suggestion
  • 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