Skip to content

D144 completed (a bare local observes), D145 ranges in pipelines (#2544), D142 lists of resource views - #2547

Merged
ehartford merged 6 commits into
step3-adaptersfrom
d144-bare
Oct 22, 2026
Merged

ehartford merged 6 commits into
step3-adaptersfrom
d144-bare

Conversation

@ehartford

@ehartford ehartford commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

D144 completed, D145 (ranges in pipelines, #2544), and D142's resource views

Three rulings from Eric's "1. do it. 2. yes 3. fix it 4. do it" (2026-10-22), one commit each:

D144, a bare local is a place too ("2. yes"). let (tx, rx) = pair observes pair; taking it apart is let (tx, rx) = move pair. The one exception the first implementation kept (D115's implicit take for a bare local holding a resource) is gone, and pattern_binds_owned_value answers "nothing taken" for an identifier that observes its place, so the let no longer marks the subject moved. The channel fixtures spell move pair; behav_d144_bare_local_observes and err_d144_bare_local_destructure_moves pin it; the D144 record is updated.

D145 (delegated), a range has iter() and its bounds are start and end (#2544, "3. fix it"). A range is a sequence, so D142's rule covers it: (0..n) |> map(it * 2) iterates. std's RangeIter[T] (impl[T: One + Ord] Iter[T]) is built by range_iter / range_iter_inclusive over the bounds; Sema dispatches r.iter() and a range on the left of |> through the free-function implicit-iter record a slice uses; for keeps its counter loop. start/end are read-only fields (Sema records the bound's index for MIR, D65). Range[T] in a generic signature resolves and binds T. Spec words §4.7, §13.5; record D145.

D142, collecting views of resources builds a list of views ("3. fix it"). The ruling's letter — views of resources stay views — means collect[List]() over them is an ephemeral List[&T], which §22.1 rules 3 and 7 already describe. A local List[&T] is no longer refused; var vs = [] fed a resource view is one; collect over resource views is plain iter_collect with T = &T; the escape checks are the ones every ephemeral value has (err_d142_resource_views_escape). A struct field or a global of one stays refused (err_second_class_reference_in_container now pins the field). §3.3's bullet "elements of heap containers" is the one sentence that still says otherwise; its amendment is Eric's (proposed words in the stack's report).

Closes #2544.

Eric Hartford added 4 commits October 22, 2026 01:24
… `move pair` takes it apart

Eric ruled (2026-10-22) that the one case the first D144 implementation kept on
D115's implicit take — a bare local whose payload is a resource — observes like
every other place. check_pattern's PAT_IDENT branch loses the exception, and
pattern_binds_owned_value answers "nothing taken" for an identifier that observes
its place (check_pattern's mark), so the let no longer marks the subject moved.

The channel fixtures spell `let (tx, rx) = move pair`. behav_d144_bare_local_observes
pins the observing destructure and the moved one; err_d144_bare_local_destructure_moves
pins the refusal to move a part out of an observed pair. Decision record updated.
…range iterates on the left of |>

A range is a sequence, so D142's rule covers it. std.collections gains
RangeIter[T] (`impl[T: One + Ord] Iter[T]`), built by range_iter /
range_iter_inclusive over the range's bounds; Sema dispatches `r.iter()` and a
range on the left of `|>` to it through the same free-function implicit-iter
record a slice uses (demand_free_fn_implicit_iter), and `for` keeps its counter
loop. A range's `start` and `end` are read-only fields: Sema types them as the
element and records the bound's index under the access node (range_bound_fields,
D65); MIR projects fields 0 and 1 as the membership lowering does. `Range[T]` and
`RangeInclusive[T]` resolve in a generic signature (they were "unknown type"),
and a range argument binds T from its element.

Delegated decision D145 recorded; spec words in §4.7 and §13.5; fixture
behav_2544_range_in_pipeline.
…ral List[&T], §22.1 rules 3 and 7)

Eric ruled (2026-10-22: "fix it") that the ruling's letter — views of resources stay
views — means `collect[List]()` over resource views builds a `List[&T]`, not a
refusal. §22.1 rules 3 and 7 already describe that container: ephemeral, carrying
its views' origins, never a struct field or a global. Sema lifts the local-let
refusal of a `List[&T]` annotation (add_binding_view_deps already made such a
binding ephemeral); a push into `var vs = []` of a non-Copy view keeps the view as
the element (a Copy view still demands the value, D139); `collect` over resource
views dispatches to plain iter_collect with `T = &T`, in the method spelling and
the pipeline target; the value-building terminals keep their refusal. The escape
checks are the ones every ephemeral value has ("returned ephemeral value may
outlive its origin"). §3.3's "elements of heap containers" bullet is the sentence
left for Eric's wording.

Fixtures: behav_d142_resource_views_collect, err_d142_resource_views_escape;
err_second_class_reference_in_container now pins the struct-field case. D142
record amended.
…ruling

err_destructure_then_project and err_match_local_consumed_then_used spelled the
take implicitly; under D144 the bare local is observed and stays readable, so
they now spell `move` and pin the consumed case (the second also had an enum
spelled as a struct literal, masked by its expected failure).
err_match_field_binds_owned pinned the D32 implicit-field-move error for a
binding pattern on a field; D144 makes that binding observe, so it is now the
behavior fixture behav_match_field_binds_observes.
@ehartford
ehartford added this pull request to stack #2548 October 22, 2026 05:59
@ehartford ehartford changed the title d144 bare D144 completed (a bare local observes), D145 ranges in pipelines (#2544), D142 lists of resource views Oct 22, 2026
Eric Hartford added 2 commits October 22, 2026 02:03
… (an enum of values is not Copy today, so the bare local observes; ceremony reported)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

D142: a range on the left of a pipeline does not iterate (no iter() on Range[T])

1 participant