Skip to content

D27 campaign: element access observes — vec[i] is a place, get(i) returns &T, remove transfers #740

Closed

Description

@ehartford

Eric's D27 ruling (decisions.md; normative text beside the operator-trait table in the specification) extends D22's doctrine to positional collections. The compiler is NON-COMPLIANT until this campaign lands.

Target semantics

  • xs[i] denotes the element place: reads yield a view (&T); writes (mutable base) mutate in place via IndexPlace, including receiver chains xs[i].tags.push(v).
  • xs.get(i) returns &T, read-only, panics on out-of-range. No Option — for positional access absence is a bug (keyed maps keep Option[&V] per D22).
  • remove(i) -> T is the ownership-transfer op.
  • Copy elements materialize at owned demands (contextual Copy); non-Copy owned demands rejected per D22 §13.6 (escapes: borrow, clone, remove).
  • Bindings per D27 ruling 3: unannotated let binds the view; a typed binding is an owned demand — uniform for fields and elements.
  • Uniform across Vec, fixed arrays, slices, and user IndexGet/IndexPlace impls.

Work items

  1. Sema: type vec[i]/get(i) as views; place-project [i] through IndexPlace; origin propagation through unannotated bindings (D22 rule 4) so a let-bound view consumed later is caught.
  2. MIR/codegen: stop materializing element copies at reads; element place projections for chains.
  3. Retire (supersede, don't layer) the interim gates: Vec index/get element copies of Drop elements are ungated (double free); #607 gate covers for/match only #715 element-copy gate and the deliberately over-broad Checker accepts owning-field read through a view as a silent aliasing bit-copy (move-out-of-borrow unrejected) #730 unannotated-let field gate (see D26/D27) — only after origins-through-bindings can catch the deferred consume.
  4. Fixture conformance: issue64 mutation-through-get chains respelled to the [i] place form (get chains observe only); err_elem_copy_* pins stay (call-arg/assign/struct-field demands still reject); new pins for typed-let demand, get-chain-mutation rejection, and view-origin-through-binding.
  5. with migrate guidance + docs examples sweep for let x = v.get(i) idioms.

Escalation: if place semantics for [i] prove irreconcilable with view-liveness (§3.2), surface to Eric — do not narrow the doctrine (D27 reopen clause).

Activity

  1. 11 remaining items

  2. ehartford commented on Aug 31, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-08-31: CLOSE (campaign complete). D27 is recorded done (CLAUDE.md + docs/d27-implementation-plan.md; the #715/#730 interim gates retired); element views + owned-demand materialization verified incidentally by today's probes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions