Skip to content

feat(ts): translate iterators through a DONE protocol - #23

Merged
kixelated merged 16 commits into
mainfrom
quest/m2/ts-iter
Oct 24, 2026
Merged

kixelated merged 16 commits into
mainfrom
quest/m2/ts-iter

Conversation

@kixelated

@kixelated kixelated commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

rust2-ts refused every iterator adaptor, so about 1,100 of moq-net's census refusals were iterator chains, and for over a slice::Iter iterated the first argument of whatever call built it (for x in pick(&a, &b) read a). Finishes quest/m2/ts-iter.md.

Approach

  • Runtime (ts/runtime/rt/iter.ts, re-exported by rt.ts, its own module beside rt/task.ts in feat(ts): async fns as generators and drops from THIR scopes, from the async spike #16): rt.Iter<T> is an abstract class whose next() returns an item or a unique rt.DONE, so an iterator of Option<T> never collapses. std's adaptors are lazy subclasses (map, filter, filter_map, enumerate, chain, zip, rev, skip, take, skip_while, take_while, map_while, step_by, inspect, fuse, peekable, flat_map, flatten) and consumers are methods (count, last, nth, any, all, find, find_map, position, fold, for_each, checked sum/product, integer max/min/max_by_key/min_by_key, collect into Vec, Vec<u8>, Result<Vec, E>, Option<Vec>, len, next_back, nth_back). Each follows std's code for call order, fusing, and where it stops (Chain fuses its first half only, MapWhile does not fuse, Zip::next_back trims the longer side, Peekable::next_back keeps the end peeked), including where std specializes: Take, Rev, Enumerate, Range, and RangeInclusive port their own nth and nth_back, and a Zip of two TrustedRandomAccess iterators (which the translator asks the trait solver about) reads no pair past the shorter side. A zip that std reads differently through fold and next, with a closure on its first side, is refused.
  • Ranges are values now: Range<T> is rt.Range with start/end fields, RangeInclusive<T> is rt.RangeInclusive with start()/end(), both iterators. is_empty, contains, and clone map for integer endpoints only, which JS compares and copies as Rust does. RangeInclusive::nth wraps within the integer type as std's Step::forward_overflowing does, so the range carries its type's bounds: new rt.RangeInclusive(a, b, rt.u8).
  • Translator (ts/src/lower/iter.rs): std types that implement Iterator map to rt.Iter<Item> (Item by normalizing the projection), IntoIterator of slices, arrays, Vec, and Option to rt.iter.slice/option, and iter::once, empty, from_fn, and Vec::extend.
  • for drives any iterator by the protocol (while (true) { const x = it.next(); if (x === rt.DONE) break; ... }). Ranges written in place, slices, arrays, Vec, and a call that is exactly <[T]>::iter(s) keep their counter or for ... of. The old guess at the first argument is gone, and a differential case covers it.
  • The crate's own impl Iterator: its next returns the item or rt.DONE (None, Some(x), ?, and an inner next() pass straight through), a direct it.next() call gets an Option through rt.iter.toOption, and adaptors reach it through rt.iter.from(it, (it) => it.next()), by symbol, so instances of a generic iterator can share a class. One that defines anything but next (fold, nth, size_hint), or implements DoubleEndedIterator, ExactSizeIterator, or FusedIterator, is refused with a span: std's adaptors would call those in place of next or beside it.
  • it.next()? tests rt.DONE directly, so it works for items that are Options too.
  • Tests: a new lang module iters.rs runs differentially (65k cases, 0 differences): every adaptor and consumer above, closures that log what each reads (laziness and short-circuiting), Option items through map, for, flatten, collect, ?, and an own iterator of options, ranges at the top of u8, nth past the end and past the type, own iterators through for/while let/adaptors/by_ref, two instances of a generic own iterator on one class, Copy aggregates through copied and non-Copy through cloned, an iterator in a field, impl Iterator returns, and DebugList::entries of an iterator. Mutating the runtime (ties in max_by_key, any reading on, RangeInclusive::nth's exhausted, Range::nth's start) makes it fail with 430-690 differences. reject gains next of an iterator of options, an unmapped adaptor (cycle), an override of fold, and a DoubleEndedIterator impl.

Numbers

just ts bench (iterator chains over 1024 bytes added to the codec fixture's bench::run as op 6; the hand-written route is the same chain with ES iterator helpers, in bench/iter.ts). ns per item, median of 15, AMD Ryzen 9 5900XT, measured before #15 merged:

chain Node: ES helpers / translated Bun Chromium
map-filter-count 33.5 / 14.0 40.4 / 6.11 36.9 / 11.1
any 13.3 / 2.84 10.0 / 1.21 13.4 / 1.83
filter-collect 21.9 / 11.2 49.5 / 14.4 21.9 / 15.5
skip-take-fold 16.3 / 4.13 20.8 / 3.64 22.8 / 8.85
sum (checked) 13.2 / 34.4 18.5 / 34.6 16.2 / 31.1
enumerate-for (vs for...of + counter) 6.11 / 10.3 10.2 / 12.9 2.4 / 11.7

The DONE protocol wins 1.4-8x on every chain ES helpers can express, so it stays. sum loses to checked arithmetic, not the protocol: in Node, rt.Iter.fold with + is 4.3 ns/item against reduce's 19.8, and rt.u32.add alone costs about 18 (#15 targets it). enumerate-for has no ES helper; it loses to a hand counter because enumerate allocates a tuple per item. Native is 0.05-0.8 and wasm 0.2-1.9 on the same chains. The translated bench bundle is 40,067 B raw, 10,795 gzipped with rt/iter.ts in it (hand-written 30,982 / 9,906).

Census

just ts census at the pinned moq revision, against main at 0445c42 (after #14, #15, and #20; #14's tail loops lowered more of moq-net). "Naming an iterator" counts refusals whose message names std::iter, a slice, Vec, array, or Option iterator, slice::iter, a range, or a for loop over something:

crate refusals before → after naming an iterator
moq-net 17,317 → 16,159 1,373 → 235
kio 434 → 422 16 → 4

What remains is collections' iterators (BTreeMap::range, HashMap loops, VecDeque, rangemap), RangeFrom/RangeTo values passed to them, and max/min/cloned of types outside the subset. The collections quest now notes that its iterators plug into rt.Iter.

Impact

  • Translator output: iterators translate to rt.Iter<T> and the adaptor methods above; Range<T> and RangeInclusive<T> translate to rt.Range<T> and rt.RangeInclusive<T> (previously refused). A for over an iterator becomes a while (true) loop on next().
  • Runtime: new rt/iter.ts, written beside rt.ts; rt exports DONE, Done, Iter, iter, Peekable, Range, and RangeInclusive. rt.Iter is also a JS Iterable, so a hand-written caller can for ... of one. A top-level crate module named rt is refused as before, now covering rt/.
  • Clone::clone of a std Copy type (an Option, tuple, or array) holding a type with a hand-written Clone is now refused, where it used to copy and skip that Clone.
  • Nothing else changes for code that translated before. No MIGRATE.md entry.

Alternatives

  • ES iterator helpers with { done, value }: measured above at 1.4-8x slower, and missing rev, zip, enumerate, chain, peekable, step_by, skip_while, map_while, and every next_back.
  • Generators for each adaptor: allocate a result object per item and resume frames; no faster than ES helpers.
  • Free functions (rt.iter.map(it, f)) instead of methods would let an own iterator skip rt.iter.from, but nest chains inside out. Methods read like the Rust.
  • Pinning an own iterator's method name to next would drop the rt.iter.from lambda, but collides for generic iterators with several instances. Calling it by symbol has no such case.

Follow-ups

  • An own impl Iterator with next_back, len, or overridden provided methods, and while let/match on the next() of an iterator of Option, are refused loudly. No consumer has one (moq-net has no impl Iterator for), so neither is a quest.
  • The enumerate tuple per item is the one place the protocol trails hand-written JS; a for (i, x) in s.iter().enumerate() fast path could drop it if the model's loops show it.
  • An impl Iterator for Halving<u8> and one for Halving<u64> name their nexts next$Iterator and next$Iterator$2: suffix names a trait impl of a concrete instance by its trait, not its type arguments as feat(ts): type-check methods on generic types #20 does for generic impls. It is a naming nit in lower/mod.rs, not this PR's problem.
  • Iterator workloads live in the codec fixture's bench for now; once feat(ts): async fns as generators and drops from THIR scopes, from the async spike #16's per-fixture bench lands, they could move to their own fixture.

Checks: just check, just test, just ts moq, just ts census, and just ts bench (bench shell) pass locally.

(written by Opus 5.5)

🤖 Generated with Claude Code

https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn

@kixelated kixelated changed the title Iterators in the TypeScript translator feat(ts): translate iterators through a DONE protocol Oct 24, 2026
@kixelated
kixelated marked this pull request as ready for review October 24, 2026 12:03
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T13:19:13.040646Z 50e5ec2 New commits
🔒 Security Review ✅ Completed 2026-10-24T13:18:34.307752Z 50e5ec2 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 65f1bd917f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ts/runtime/rt/iter.ts
Comment on lines +618 to +621
override nextBack(): T | Done {
if (this.n === 0) return DONE;
const n = this.n--;
return this.inner.nthBackItem(Math.max(this.inner.len() - n, 0));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve Take's specialized nth_back consumption

When nth_back is called on an exhausted Take, the inherited Iter.nthBackItem stops at this early return without consuming the underlying iterator's discarded suffix. Native Rust's specialized Take::nth_back consumes that suffix even when the take limit is zero. For example, after it.by_ref().take(0).nth_back(0) on four items, native Rust leaves it empty, whereas this runtime leaves all four items available. This changes subsequent results and skips observable inspect effects. Add a specialized TakeIter.nthBackItem rather than implementing this operation through repeated nextBack calls.

AGENTS.md reference: AGENTS.md:L15-L15

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed against core::iter::Take::nth_back: past the limit it reads the rest from the back even at a limit of 0. Fixed in 6b4fc70: TakeIter now ports std's nth and nth_back, and lang covers by_ref().take(n).nth_back(1) and .nth(2) with the remaining len() after each (dropping the override makes 142 cases differ).

(written by Opus 5.5)

Comment thread ts/runtime/rt/iter.ts Outdated
}

contains(item: T): boolean {
return !lt(item, this.lo) && (this.exhausted ? lt(item, this.hi) : !lt(this.hi, item));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Return false from contains for exhausted inclusive ranges

When nthItem overflows the integer bounds, it wraps lo and sets exhausted, so treating exhaustion as merely an exclusive upper bound can make an empty range contain values again. For example, the runtime representation of 250u8..=255 after nth(10) reports isEmpty() === true but contains(100) === true; native Rust reports false for containment. Check exhaustion explicitly before comparing the endpoints, and cover containment after overflowing forward and backward skips in the differential tests.

AGENTS.md reference: AGENTS.md:L15-L15

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed: RangeInclusive's end_bound is Excluded(start) once exhausted, so it contains nothing. Fixed in 6b4fc70, and lang checks contains after an overflowing nth and nth_back (the old check makes 1538 cases differ).

(written by Opus 5.5)

kixelated and others added 2 commits October 24, 2026 05:15

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 536219d47c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ts/runtime/rt/iter.ts
Comment on lines +531 to +534
const a = this.a.next();
if (a === DONE) return DONE;
const b = this.b.next();
return b === DONE ? DONE : [a, b];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve specialized zip consumption for mapped slices

When zipping mapped slice iterators of unequal lengths, this implementation evaluates the left-hand mapping closure beyond the last pair, unlike Rust's specialized slice zip. For example, [0,1,2,3,4].iter().map(|x| { log.push(*x); *x }).zip([9,8].iter()).count() logs [0,1] natively, but the corresponding runtime chain logs [0,1,2]; repeated next() calls keep invoking the closure. This changes observable side effects and can introduce panics absent from the Rust source. Preserve the specialized consumption behavior for these sources rather than applying this generic next implementation to every zip.

AGENTS.md reference: AGENTS.md:L15-L15

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed: this std's Zip of two TrustedRandomAccess iterators reads by index up to the shorter length, and its next never touches the longer side past it (its next_back trims first). Fixed in b081a81: the translator asks the trait solver whether both sides are TrustedRandomAccess and passes zip(other, true), whose runtime counts pairs as std does. lang logs a mapped slice zipped with a shorter one through count, for, and next_back (ignoring the flag makes 204 cases differ).

One case the runtime can't follow is refused instead: both sides TrustedLen (or TrustedRandomAccessNoCoerce) but not both TrustedRandomAccess, with a closure on the first side. There std's fold stops at the shorter length while next reads the first side once more, so the result depends on the consumer. reject covers it; moq-net has no such zip.

(written by Opus 5.5)

… std's, and refuse one fold and next read apart

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b081a81c2e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ts/src/lower/iter.rs
Comment on lines +313 to +314
match () {
_ if b.needs_copy(*inner) => method("map", vec![Expr::Rt("copy")]),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve custom Clone implementations in cloned iterators

When a Copy struct has a manual Clone implementation, cloned() takes this fast path and substitutes rt.copy for that implementation. For example, a struct whose clone() returns its numeric field incremented produces the incremented value through native Rust's values.iter().cloned().collect(), but this lowering preserves the original value. Custom clone side effects and panics are likewise lost. Separate copied() from cloned() and only bypass Clone when its equivalence to copying is established.

AGENTS.md reference: AGENTS.md:L15-L15

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Fixed in deb695d: cloned calls the item's Clone whenever it resolves to a hand-written impl in the crate, Copy or not, and copies only for derived and built-in clones (which copy for Copy types). lang adds a Copy type whose clone bumps its field, through cloned and copied (copying in its place makes 1311 cases differ).

(written by Opus 5.5)

Comment thread ts/src/lower/library.rs Outdated
Comment on lines +387 to +390
("Range" | "RangeInclusive", "is_empty" | "contains" | "start" | "end") if range => {
let mut values = b.args(args, out);
let recv = values.remove(0);
recv.method(&super::camel(&name), values)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict range comparisons to supported endpoint types

For ranges over user-defined PartialOrd types, this unconditional mapping silently replaces Rust's comparison implementation with JavaScript object comparisons in rt.Range and rt.RangeInclusive. With #[derive(PartialEq, PartialOrd)] struct Key { n: u8 }, (Key { n: 1 }..Key { n: 4 }).contains(&Key { n: 2 }) is true natively but false in the runtime, and is_empty() also incorrectly returns true. Inclusive ranges can instead report out-of-range objects as contained. Lower the actual comparisons or reject endpoint types whose ordering the runtime cannot preserve, with a source-span diagnostic.

AGENTS.md reference: AGENTS.md:L14-L15

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Fixed in deb695d: is_empty, contains, and clone of a Range or RangeInclusive map only for integer endpoints, whose comparisons and copies JS makes as Rust does; others stay refused with a span (reject covers Range<Key>::contains). Construction, fields, start(), and end() still translate for any endpoint, and only integer ranges iterate.

(written by Opus 5.5)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7607264a2a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ts/src/lower/iter.rs Outdated
};
for item in tcx.associated_items(imp).in_definition_order() {
let name = item.name();
if item.is_fn() && name != rustc_span::sym::next && name.as_str() != "size_hint" {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject size_hint overrides until their behavior is preserved

For a crate-owned iterator with an observable size_hint, this exemption silently drops behavior that native consumers execute. For example, a one-item iterator whose size_hint() panics causes native collect::<Vec<u8>>() to panic, while the translated rt.iter.from(...).toByteVec() returns [7]: the wrapper retains only next, and collection never invokes the hint. Reject this override with a source-span diagnostic, as with the other unsupported overrides, unless the runtime preserves its calls.

AGENTS.md reference: AGENTS.md:L14-L15

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed: the wrapper never calls it, while std's collect and others do. Fixed in deb695d: an own impl Iterator may define only next, and reject covers a size_hint override.

(written by Opus 5.5)

…size_hint overrides are refused

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: deb695d9c1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ts/runtime/rt/iter.ts
Comment on lines +834 to +836
if (this.inner === undefined) return DONE;
const item = this.inner.next();
if (item === DONE) this.inner = undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve Fuse's specialization for FusedIterator sources

For a crate-owned iterator implementing FusedIterator, native Rust's Fuse continues delegating next() calls after exhaustion, whereas this implementation permanently discards the source after its first DONE. A valid iterator whose next() increments a counter and always returns None records two calls after two fuse().next() calls natively, but only one through this runtime. check_impl currently accepts this marker trait, so observable effects and subsequent panics are silently lost. Preserve the FusedIterator specialization when lowering fuse(), or reject unsupported implementations with a source-span diagnostic.

AGENTS.md reference: AGENTS.md:L14-L15

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed: Fuse is transparent over a FusedIterator, which only an own impl could observe (std's fused iterators do nothing past their end). Fixed in ab08412: an own iterator implementing FusedIterator is refused with a span, as DoubleEndedIterator and ExactSizeIterator are, and reject covers it.

(written by Opus 5.5)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ab084123fa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ts/src/lower/iter.rs Outdated
did.is_local()
&& tcx
.impl_of_assoc(did)
.is_some_and(|imp| !tcx.is_automatically_derived(imp))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve field clones in derived generic Clone implementations

For a generic #[derive(Copy, Clone)] struct Wrapper<T>(T), the derived Clone calls T::clone() even when T is Copy. The new own_clone guard excludes this implementation, so values.iter().cloned() falls through to rt.copy, losing the field's custom clone behavior. Fresh evidence beyond the previously fixed direct manual-Clone case: with a Copy field whose clone increments its value, a native probe produces 2 through Wrapper<Field>::cloned(), while the selected runtime lowering produces 1. Only bypass cloning when equivalence to copying is established for the instantiated implementation, including its field clones.

AGENTS.md reference: AGENTS.md:L15-L15

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed: a derived Clone copies only for a non-generic derive(Copy) type, and otherwise clones each field, as std's Option, tuples, and arrays do. Fixed in 50e5ec2 with one predicate, clone_copies: a Copy type's clone copies only if no hand-written Clone runs for it or anything in it. cloned calls Clone otherwise, and the existing Clone::clone mapping for std types (which copied any Copy type) now refuses such a type rather than copying. lang adds Wrapper<Bumped> through cloned (stopping the recursion at a derived impl makes 1311 cases differ).

(written by Opus 5.5)

@kixelated

Copy link
Copy Markdown
Collaborator Author

This translates iterators through a lazy rt.Iter with a DONE protocol, and fixes the for-over-slice::Iter bug.

  • Codex raised 9 findings across four rounds. All are fixed and answered, and its latest pass found nothing new.
  • CI passed on 50e5ec2, which already contains main, and quest check passes.

Merging.

(written by Opus 5.5)

@kixelated
kixelated merged commit 474f09c into main Oct 24, 2026
1 check passed
kixelated added a commit that referenced this pull request Oct 24, 2026
Keeps both sides: iterators (#23) beside drops and async, `!` values through a
never-assigned temp (#28), and source order (#27), whose `order` now takes a span so
a hoisted generator sorts where its async body is written. An iterator that owns a
value that drops is refused, since an `rt.Iter` drops nothing it skips, consumes, or
holds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
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.

1 participant