Skip to content

Track reference origins and borrow conflicts #43

Description

@itsfuad

Goal

Complete safe-reference lifetime enforcement without adding lifetime syntax.

Current Boundary

  • &T and &mut T types, expressions, receivers, interface views, and reborrows are implemented.
  • Reference-containing aggregate storage remains rejected.
  • Reference returns remain rejected until origin summaries exist.
  • Obvious same-expression alias conflicts and owner-move-while-borrowed checks are not implemented yet.

Scope

  • Track origins for explicit borrows, receiver auto-borrows, field projections, reborrows, and borrowed interface values.
  • Summarize which reference parameters may supply a returned reference.
  • Allow safe parameter-origin reference returns while rejecting local-origin escapes.
  • Reject conflicting shared/mutable borrows where overlap is known.
  • Prevent moving or consuming an owner while derived references remain live.
  • Keep conservative rejection for unresolved aggregate/index overlap.
  • Keep v1 free of user-written lifetime parameters.

Validation

  • Focused ownership/typechecker tests for return origins, reborrows, alias conflicts, and owner moves.
  • Positive and negative x_test/ fixtures.
  • HIR/MIR/backend smoke for accepted returned references.
  • Full go test ./... and git diff --check.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestlanguage-modelPeeper language model, ownership, pointer, optional, array/slice workownershipOwnership, move, copy, pointer-safety work

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions