Repository navigation
std: ListIter is a view of the list; the list-iterator intrinsics retire (#2220 step 2) - #2526
Merged
Merged
Conversation
added 3 commits
October 21, 2026 00:05
…ters are With bodies
`ListIter[T]` is `{ list: &List[T], idx: isize }` with a `next()` body
yielding `&T` through the element place (D27, bounds-checked by `len()` and
`xs[i]`), `impl Iter[&T]`, and `List.iter()` / `iter_ref()` as std methods;
Sema's ListIter/ListIterRef intrinsic rows, builtin return types, the
#2145 iter->iter_ref rewrite and the by-value Copy flavor are gone, so a
list's adapters are std.traits' bodies (map, filter, fold, ...). The
terminals those bodies lacked are written: sum, product (trait One), min,
max, min_by, max_by, reduce, partition, unzip, flat_map, zip_with, and
collect into HashSet / BTreeSet, each with a `_views` twin for an iterator
of views (D22 section 6.2, D139); Default for f32/f64. `for x in xs.iter()`
stays the implicit form's counter loop through Sema's for_list_iter_recvs
record (D65). The intrinsics themselves retire in the next commit.
… inferable return types VECITER_NEXT, LIST_ITER, LIST_ITER_REF and VECITERREF_NEXT leave MirIntrinsic, the LLVM emitters, the emit-C builtins and every predicate list; ListIterRef (a Sema-synthesized type) and its layouts in Codegen, TypeLayout and emit-C go with them; the dead ListIter/ListIterRef branches of the adapter next emitters too. 108 iterator fixtures and 60 trait fixtures green on stage1. lib/std/traits.w: `impl Default for i32: fn default(): 0` and the like -- the trait declares the return, so the written type was ceremony (a reviewer caught it on the new One impls; the neighbours are folded the same way). behav_1346 renames its own `One` trait to PlusTwo with a comment: a same-named user trait rebinds std's impls (#2520).
… (D65) An inherent `List.iter` beside `impl Iterable for List: fn iter` and an inherent `ListIter.next` beside `impl Iter for ListIter: mut fn next` registered two declarations under one method symbol; audit:all named both (method registration missing, impl-mismatch). The trait impls carry the bodies; `iter_ref` stays an inherent alias.
ehartford
marked this pull request as ready for review
October 21, 2026 20:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#2220 step 2 (Eric's Option 2 ruling):
ListIter[T]is std's view of the list —{ list: &List[T], idx: isize }with anext()body yielding&Tthrough the element place (D27, bounds-checked bylen()andxs[i]),impl Iter[&T],List.iter()as theIterableimpl's one definition (D65: an inherent twin of the same name registered twice). The four list-iterator intrinsics (VECITER_NEXT, LIST_ITER, LIST_ITER_REF, VECITERREF_NEXT),ListIterRefand their layouts leave Sema, MIR, LLVM codegen, emit-C and TypeLayout; the #2145 iter→iter_ref rewrite and the by-value Copy flavor are gone, so a list's adapters arestd.traits' bodies. The terminals those bodies lacked are written in std (sum, product via a newOnetrait, min, max, min_by, max_by, reduce, partition, unzip, flat_map, zip_with, collect into HashSet/BTreeSet), each with a_viewstwin for an iterator of views (D22 §6.2, D139);Defaultfor f32/f64.for x in xs.iter()keeps the implicit form's counter loop through Sema'sfor_list_iter_recvsrecord.lib/std/traits.wone-liners drop their inferable return types (review).behav_1346renames its ownOnetrait (#2520). Measured: the view iterator is 1.6× faster than the retired intrinsic (1.14 ms vs 1.84 ms, 4M i64, -O3); with #2527 the std pipeline is within 5% of the retired intrinsics. 108 iterator and 60 trait fixtures green; gate green. Layer 1 of stack #2528.