Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
51fd615
chore(quest): claim quest/m2/ts-drop.md
kixelated Oct 27, 2026
3557c11
Merge remote-tracking branch 'origin/main' into worktree-agent-a78e5d…
kixelated Oct 27, 2026
d8b28dd
feat(ts): drop what std's iterators own
kixelated Oct 27, 2026
ba3bcd5
Merge remote-tracking branch 'origin/main' into worktree-agent-a78e5d…
kixelated Oct 27, 2026
0a01766
feat(ts): skip iterator drop paths where nothing drops, and rewrite t…
kixelated Oct 27, 2026
eb9d876
fix(ts): drop a hash iterator's entries once when a drop panics
kixelated Oct 27, 2026
0ccae57
Merge remote-tracking branch 'origin/main' into worktree-agent-a78e5d…
kixelated Oct 27, 2026
c06f73a
fix(ts): skip from the back as std's `skip`, `take`, and `step_by` do
kixelated Oct 27, 2026
114b9a4
fix(ts): step forward as std's `step_by` does, and saturate its counts
kixelated Oct 27, 2026
1672244
test(ts): a step_by count past usize::MAX saturates
kixelated Oct 27, 2026
e732b4b
fix(ts): a hash iterator that drops nothing reads each entry to count
kixelated Oct 27, 2026
9f7a821
fix(ts): refuse a closure that drops, passed to a map that may drop it
kixelated Oct 27, 2026
1b072d4
fix(ts): read an iterator borrowed by `&mut` through its borrow
kixelated Oct 27, 2026
5871bdb
Merge origin/main into quest/m2/ts-drop
kixelated Oct 27, 2026
2c01ac1
perf(ts): drop-aware iterator paths as functions a bundle can leave out
kixelated Oct 27, 2026
771e3e6
Merge origin/main into quest/m2/ts-drop
kixelated Oct 27, 2026
ff5f56c
fix(ts): a panicking collect drops collected items only by their dropper
kixelated Oct 27, 2026
405151c
chore(quest): add ts-iter-nth for std's skips without drops
kixelated Oct 27, 2026
17aba73
Merge origin/main into quest/m2/ts-drop
kixelated Oct 27, 2026
a390d5c
fix(ts): split a skip's nth past a usize's greatest as std's does
kixelated Oct 27, 2026
eebf34d
Merge origin/main into quest/m2/ts-drop
kixelated Oct 27, 2026
44e7b25
fix(ts): glue for a field generic over lifetimes or a tuple of parame…
kixelated Oct 27, 2026
de3a50a
Merge origin/main into quest/m2/ts-drop
kixelated Oct 27, 2026
db28893
Merge origin/main into quest/m2/ts-drop
kixelated Oct 27, 2026
d698cb7
Merge origin/main into quest/m2/ts-drop
kixelated Oct 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions quest/m2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The fork's feature quests folded into the [exporter](/quest/m1/ffi-export.md);
- [Drop in the TypeScript translator](/quest/m2/ts-drop.md) - every value that drops in moq-net and kio drops where Rust drops it
- [Async in the TypeScript translator](/quest/m2/ts-async.md) - moq-net's and kio's async code translates with Rust's lazy futures
- [Shared ownership](/quest/m2/ts-shared.md) - `Arc`/`Rc`/`Weak` keep exact counts, and locks and atomics become plain values
- [Iterator skips that read as std's](/quest/m2/ts-iter-nth.md) - `nth` and `nth_back` of what drops nothing read the items std's do
- [Share constant aggregates](/quest/m2/ts-const-share.md) - `Ok(())` and other constants nothing writes into are one frozen object
- [Translate moq-net's model to TypeScript](/quest/m2/ts-model/README.md) - the model translates with kio, moq-clock, and moq-pattern, for moq to compare against WASM
- [Waiting: Swift 6.4 in nixpkgs-unstable](/quest/m2/uniffi-swift-arm.md) - the nightly UniFFI fixtures move back to arm
Expand Down
36 changes: 18 additions & 18 deletions quest/m2/ts-drop.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [M] Drop in the TypeScript translator
# [S] Drop in the TypeScript translator

## Goal

Expand All @@ -15,27 +15,27 @@ a flag where a value moved on some paths only. A panic unwinds through the clean
blocks of `-C panic=unwind` MIR, which a function runs from a `catch`. A value without
`[Symbol.dispose]`, such as an enum or a tuple, drops through glue lowered from rustc's
`drop_in_place` shim. A runtime function that may drop what std's would (a collection's
`clear`, `unwrap_or`'s fallback) takes a dropper for each such type after its own
arguments (`drop_fn` and `droppers` in `drop.rs`). The task fixture's `drops.rs` checks
these against native Rust, natively unwinding too.
`clear`, `unwrap_or`'s fallback, an adaptor's rejects) takes a dropper for each such
type after its own arguments (`drop_fn` and `droppers` in `drop.rs`), and a consumer
that takes an iterator by value takes `rt.drop` for it. The task fixture's `drops.rs`
and `drops/iters.rs` check these against native Rust, natively unwinding too.

What still fails translation, by the census at the pinned moq revision (moq-net's, then
kio's):

- An iterator that owns a value that drops (124, 6), and the collection methods that
make one (19): `drain`, `into_keys`, and `into_values`. Most are a `for` loop over a
`Vec` or a map, and a `collect` of cloned `Path`s. An `rt.Iter` drops nothing it
skips, consumes, or still holds when it drops. Sources that own items need droppers
and a `[Symbol.dispose]` for what remains; adaptors drop what they discard (`filter`'s
rejects, `skip`, `nth`, `last`, `count`, `zip`'s unmatched item, `max_by_key`'s
losers) and what they hold (`Peekable`'s item, `Flatten`'s inner iterators); a
consumer that takes the iterator by value drops it, also when a closure panics. Look
out for `collect`, whose order of drops on a panic may differ between std's in-place and
generic paths, and for closures an adaptor holds, which must drop with it or refuse.
`extend` of a map or set already inserts each item as `insert` does, panics included,
but nothing tests it yet. A B-tree's `collect` sorts first, and a panicking `Ord` leaves
Rust's `Vec` in an order JS's `sort` won't match.
- A closure that owns a value that drops, dropped without a call that takes it (10, 0).
- A closure that owns a value that drops, dropped without a call that takes it (17, 0),
as `Option::map` drops it on `None` and `Result::map` on an error. An arrow function
has no `[Symbol.dispose]`; one that owns droppable captures needs one, and so do the
adaptors that hold it (`map`'s, `filter`'s), which drop it after their iterator, as
std's fields do.

Refused with none in the census, each where std's order is one JS's can't follow yet:
`into_keys` and `into_values` of a hash map whose other half drops (`fold` drops it
after the half it yields, `next` before); `zip` of two `TrustedRandomAccess` iterators
of items that drop; a `flatten` whose inner iterator holds items once ended, or that a
`fold` reads where both its source and inner iterators drop; a B-tree's `collect` of
entries that drop, sorted by the crate's own `Ord`; a `collect` in place of a `zip`
whose second iterator drops; and `DebugList::entries` of items that drop.

Watch the cost: a function whose cleanup does something JS can see sets a variable
before each call that can panic and wraps its body in a `try`; measure any change on
Expand Down
23 changes: 23 additions & 0 deletions quest/m2/ts-iter-nth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# [S] Iterator skips that read as std's

## Goal

rust2-ts's `nth`, `nth_back`, and the adaptors built on them read the same items std's
do of an iterator that drops nothing, so a `by_ref` source or an `inspect` closure sees
std's reads, proven by differential tests against native Rust.

## Plan

Found by review of [#101](https://github.com/kixelated/rust2/pull/101) on 2026-10-27.
Without a dropper, `rt.iterNth` and `nthBackItem` are `main`'s methods, which only
`Enumerate`, `Rev`, `Take`, `Range`, and the `by_ref` wrapper override. std's `Fuse`,
`Skip`, `Chain`, `StepBy`, `Peekable`, `Flatten`, and `Copied` forward to
what they wrap, and `Take`'s `nth_back` and `advance_back_by` read past its limit, so
`(0..3).by_ref().take(0).fuse().nth_back(0)` leaves the range empty in Rust but not here.
#101's `rt.owned*` dispatchers already follow std's order where an item drops.

- Weigh calling those dispatchers without a dropper against methods on each class: the
codec's bundle carries every class a dispatcher names.
- Cover `by_ref` and `inspect` sources under each adaptor.

Public API: the translator's output.
5 changes: 4 additions & 1 deletion ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ panic drops matches native Rust's. A value without `[Symbol.dispose]` of its own
an enum or a tuple, drops through glue lowered from rustc's `drop_in_place` shim, a
function of its type's own (`drop$Held`). The runtime functions for std's collections,
`Arc`, and the std functions that may discard an operand (`unwrap_or`, a map's `insert`)
take what drops each value they may drop, and drop it where std's do. A `Drop` impl that
take what drops each value they may drop, and drop it where std's do. So do iterators: one
that owns its items, as a `Vec`'s `into_iter` or a map's `drain` does, drops those it still
holds by `[Symbol.dispose]`, an adaptor drops what it skips or rejects, and a consumer that
takes an iterator by value drops it, a panic included. A `Drop` impl that
panics leaves the rest to drop as Rust's does: a class's glue and the runtime's droppers
go on to the rest of the value and its container, but a hash table leaks its other
entries, as std's does.
Expand Down
Loading