Skip to content

ephemeral view-structs: second-class structs with view fields, Copy-eligible (D28 ruling 2) #748

Closed

Description

@ehartford

Ruling

D28 ruling 2 (Eric, 2026-07-31): the view-token mechanism's new shape.
§3.3 bans reference fields, so a Copy view token cannot respell its str
fields as &str — exactly the gap D27 ruling 1's reopen clause anticipated
('mechanism, not intent'). The blessed destination: extend the EXISTING
ephemeral type marker (precedent: pub type ScopedJoinHandle ephemeral
in lib/std/thread.w; §3.4 ephemeral-return propagation) to structs with view
fields.

Semantics sketch (normative wording goes to Eric before landing)

  • A struct declared ephemeral may contain view fields (&str,
    &[T], other view types).
  • The struct is itself second-class: parameters, locals, and returns only —
    no heap containers, no non-ephemeral struct fields, no escaping-closure
    captures, no globals (§3.3's list, applied to the struct as a whole).
  • Ephemerality propagates through returns exactly like §3.4 chains — no
    lifetime annotations, ever ('This restriction eliminates lifetime
    annotations entirely' stays true).
  • Such a struct may opt into Copy — copying views is copying views.
  • Origin tracking: the struct value carries its fields' origins; D22
    view-origin rules apply through field projection.

Payoff

JsonView re-acquires by-value Copy (D27 ruling 1's declared
signatures stand unchanged); Package/ProjectInfo/Diagnostics can
return to cheap by-value passing where they are genuinely views. Interim
state after #747's de-Copy is borrow-at-boundaries, which D5 auto-ref makes
spelling-invisible.

Dependencies

After #747 (the str flip) — the de-Copy interim is acceptable and this
campaign is not on the roundtrip's critical path. Spec text requires Eric's
blessing of exact wording (AGENTS.md: spec changes are solemn).

Reopen trigger recorded in D28

If ephemeral view-struct origin tracking proves irreconcilable with §3.4's
propagation chains, surface to Eric — do not narrow the doctrine.

Activity

  1. added a commit that references this issue on Aug 9, 2026
  2. added 3 commits that reference this issue on Aug 17, 2026
  3. ehartford commented on Aug 31, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-08-31: CLOSE (overcome by events). D28 ruling 2 landed: the spec carries the ephemeral-struct text, JsonView ephemeral: Copy is live (lib/std/json.w:24), and probes confirm both directions (view-field ephemeral struct passes by value; a plain struct with &str is rejected). One note for the record: a local Vec[ephemeral-struct] currently compiles — legal under the landed propagation text, but if "no heap containers" was intended literally that deserves its own narrow issue.

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