diff --git a/quest/m2/README.md b/quest/m2/README.md index dd64d1900..94f3bc8c9 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -29,7 +29,6 @@ The fork's feature quests folded into the [exporter](/quest/m1/ffi-export/README - [Byte-slice locals that crash the translator](/quest/m2/ts-scalar-ice.md) - `take_apart` never reaches the arm `find_scalars` promised it wouldn't - [Fixture cases by name](/quest/m2/ts-harness-names.md) - adding a harness case never renumbers another - [Byte slices without objects](/quest/m2/ts-byte-views/README.md) - reading through a translated cursor allocates no object per read -- [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 - [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 diff --git a/quest/m2/ts-async.md b/quest/m2/ts-async.md index aa57a4070..2906b5b23 100644 --- a/quest/m2/ts-async.md +++ b/quest/m2/ts-async.md @@ -39,7 +39,3 @@ An async block that captures part of a variable, which THIR refused 47 times, is capture like any other in MIR. Public API: the translator's output for async code. - -## Required - -- [Drop in the TypeScript translator](/quest/m2/ts-drop.md) - async bodies hold the values that drop it still refuses diff --git a/quest/m2/ts-drop.md b/quest/m2/ts-drop.md deleted file mode 100644 index 9e706f422..000000000 --- a/quest/m2/ts-drop.md +++ /dev/null @@ -1,48 +0,0 @@ -# [S] Drop in the TypeScript translator - -## Goal - -[rust2-ts](/ts/README.md) translates every value that drops in moq-net's model and kio: -each `drop()` runs where Rust drops it, in Rust's drop order, including on early -return, `?`, panic, and a cancelled future, proven by differential tests against -native Rust. - -## Plan - -Decided by the MIR spike ([#36](https://github.com/kixelated/rust2/pull/36)): drop -points come from MIR's drop elaboration, which puts each drop where Rust runs it, with -a flag where a value moved on some paths only. A panic unwinds through the cleanup -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, 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. A closure that owns a value that -drops carries `[Symbol.dispose]` (`rt.closure`), and one that `Fn` or `FnMut` call drops -after a call through `FnOnce` (`rt.callOnce`, and `rt.once` for std's). The task -fixture's `drops.rs`, `drops/iters.rs`, and `drops/closures.rs` check these against -native Rust, natively unwinding too. - -Nothing that drops fails translation in the census at the pinned moq revision. Refused -with none in the census, each where std's order is one JS's can't follow yet: -a closure that owns a value that drops, given to std's iterators or a collection's -methods, which hold or call it (an adaptor drops it after its iterator, as std's fields -do, and each consumer where its `fold` path does); -`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; `successors` of items that drop, which holds the next one; -and `DebugList::entries` of items that drop. - -Next, from [#115](https://github.com/kixelated/rust2/pull/115): `rt.iterFromFn` and -`rt.iterSuccessors` take droppers for their closure and for `successors`' pending item, -as std's fields drop them, which lifts both refusals and the reject fixture's second -refusal of dropping the `Take` around them. - -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 -the [TS benchmark](/ts/README.md#bench). - -Public API: the translator's output for values that drop. diff --git a/quest/m2/ts-model/README.md b/quest/m2/ts-model/README.md index 7b35fc781..3006aee83 100644 --- a/quest/m2/ts-model/README.md +++ b/quest/m2/ts-model/README.md @@ -46,7 +46,6 @@ Public API: the translator's output for moq-net's model. ## Required -- [Drop in the TypeScript translator](/quest/m2/ts-drop.md) - kio closes a channel when its last producer drops - [Shared ownership](/quest/m2/ts-shared.md) - kio's waiters are `Arc`/`Weak` with observable counts, and its atomics and locks are plain values - [Translate safe dependencies with the package](/quest/m2/ts-model/crates.md) - kio, moq-clock, moq-pattern, and rangemap translate as one program with moq-net - [Std gaps the model reaches](/quest/m2/ts-model/std-more.md) - ranges, wrappers, and `Vec`'s editing methods diff --git a/quest/m2/ts-shared.md b/quest/m2/ts-shared.md index 31563f788..2081981c1 100644 --- a/quest/m2/ts-shared.md +++ b/quest/m2/ts-shared.md @@ -32,7 +32,3 @@ is its own guard. Left: `Rc`, `weak_count` (a dropped `Weak` counts nothing yet) - Measure the counter overhead on the [TS benchmark](/ts/README.md#bench). Public API: the translator's output for shared and interior-mutable types. - -## Required - -- [Drop in the TypeScript translator](/quest/m2/ts-drop.md) - the last strong drop runs `Drop` diff --git a/quest/m3/README.md b/quest/m3/README.md index 459d70f41..4bb8362b0 100644 --- a/quest/m3/README.md +++ b/quest/m3/README.md @@ -24,3 +24,4 @@ generic std gap is planned here even when moq never calls it. - [An inclusive range drained by a fold](/quest/m3/ts-range-fold.md) - a folded `RangeInclusive` ends in core's state - [bool's combinators from core's MIR](/quest/m3/ts-bool-core.md) - `bool::then` lowers from core, retiring `rt.boolThen` - [Binding gaps](/quest/m3/ts-bind-gaps.md) - bound types as keys, unit returns checked, renamed dependencies +- [Drop order in std's folds and iterators](/quest/m3/ts-drop-order.md) - the values that drop still refused in std's folds, zips, flattens, and collects drop as std's do diff --git a/quest/m3/ts-drop-order.md b/quest/m3/ts-drop-order.md new file mode 100644 index 000000000..1fa9d9713 --- /dev/null +++ b/quest/m3/ts-drop-order.md @@ -0,0 +1,42 @@ +# [M] Drop order in std's folds and iterators + +## Goal + +[rust2-ts](/ts/README.md) translates the values that drop which it still refuses +inside std's iterators and formatting, each dropping where std's does, in std's order, +on a panic too, proven by the task fixture's differential and unwinding tests against +native Rust. None appears in moq's census at the pinned revision; rust2 aims to support +all of std. + +## Plan + +Moved from the m2 drop quest on 2026-10-27, once moq-net, its model, and kio had no +drop refusal left ([#139](https://github.com/kixelated/rust2/pull/139)). Each is refused +with a span where std's order is one JS's can't follow yet: + +- A consumer that std folds (`count`, `fold`, `sum`, `collect`, ...) of an iterator + holding a closure that drops beside anything else that drops: std's `fold` drops an + adaptor's closure as its own ends, before the source, where dropping the adaptor + drops it after (`folds` and `held` in `iter.rs`). +- A closure that owns a value that drops given to a std function that takes another + value that drops by value, such as `for_each` of items that drop, that keeps it + other than in an adaptor, or that calls it through `FnOnce` other than where + `discards` in `library.rs` says, as `or_insert_with` does (`called_closures`). +- `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. +- `DebugList::entries` of items that drop. + +The fold refusals share one fix: give each `rt.Iter` a `fold` that drops what it holds +where std's `fold` for that adaptor does (`Map` and `Filter` delegate to their source's +with their closure wrapped, `TakeWhile`, `Chain`, and `Peekable` each fold their own +way), and have by-value consumers drop through it rather than `rt.drop`. + +Watch the cost: measure any change to a hot path on the +[TS benchmark](/ts/README.md#bench). + +Public API: the translator's output for values that drop in std's iterators. diff --git a/ts/README.md b/ts/README.md index ef5bf02c8..9897cb7db 100644 --- a/ts/README.md +++ b/ts/README.md @@ -427,8 +427,9 @@ Until they translate, an item that needs one, such as a boxed future, binds to hand-written TS ([bindings](#bindings)). These fail translation: floats ([Floats](/quest/m2/ts-model/floats.md)), statics, async closures, a closure that owns a value -that drops given to std's iterators or collections, and values that drop in some -iterators ([Drop](/quest/m2/ts-drop.md)), a `Cow` of other than `str`, +that drops given to a std function that drops it beside another value that drops, as +`for_each` of items that drop does, or keeps it other than in an iterator adaptor, and +values that drop in some iterators ([drop order](/quest/m3/ts-drop-order.md)), a `Cow` of other than `str`, a collection holding a type that can be `undefined`, as `()` and `Option` can, a std function without a mapping of its own that makes or reads an `Option` whose `None` is `rt.None`, as `find` over `Option`s does, an `Option` of an `Option` of `()` or another diff --git a/ts/fixtures/reject/census.md b/ts/fixtures/reject/census.md index 67d64b2cc..e9a66020f 100644 --- a/ts/fixtures/reject/census.md +++ b/ts/fixtures/reject/census.md @@ -1,54 +1,54 @@ # Census of `reject-fixture` -- Refusals: 78 -- Function instances: 76 +- Refusals: 72 +- Function instances: 75 - Generic functions no instance reached, lowered over their type parameters: 4 ## By construct | Count | Construct | First | | ---: | --- | --- | -| 11 | unsupported call to `_` | fixtures/reject/src/lib.rs:28:4 | -| 5 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | fixtures/reject/src/lib.rs:61:11 | -| 4 | a variant of `_`, which is not supported: either is the same JS string | fixtures/reject/src/lib.rs:398:2 | -| 4 | an assignment through a reference to `_` | fixtures/reject/src/lib.rs:115:2 | +| 10 | unsupported call to `_` | fixtures/reject/src/lib.rs:28:4 | +| 4 | a variant of `_`, which is not supported: either is the same JS string | fixtures/reject/src/lib.rs:393:2 | +| 4 | an assignment through a reference to `_` | fixtures/reject/src/lib.rs:117:2 | | 4 | unsupported type `_` | fixtures/reject/src/lib.rs:7:14 | | 3 | `_` with a mutable reference to a value JS copies, which its mapping would copy | fixtures/reject/src/lib.rs:17:2 | -| 3 | dropping `_`, which is not supported yet | fixtures/reject/src/lib.rs:61:18 | -| 3 | replacing the value behind a reference to `_` | fixtures/reject/src/lib.rs:99:2 | -| 2 | `_` is not supported: it would be pending two ways with one value | fixtures/reject/src/lib.rs:119:20 | +| 3 | replacing the value behind a reference to `_` | fixtures/reject/src/lib.rs:101:2 | +| 2 | `_` is not supported: it would be pending two ways with one value | fixtures/reject/src/lib.rs:121:20 | | 2 | `_` is not supported: its `None` and `Some` would both be `rt.None` | fixtures/reject/src/lib.rs:23:15 | | 2 | `_` of `_`, whose `None` is `rt.None`, which is not supported yet | fixtures/reject/src/lib.rs:48:42 | -| 2 | `_` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it | fixtures/reject/src/lib.rs:266:16 | -| 2 | a field of `_` | fixtures/reject/src/lib.rs:282:7 | -| 2 | an iterator of the crate implementing `_`, which is not supported yet | fixtures/reject/src/lib.rs:173:1 | -| 2 | constructing `_` from another crate | fixtures/reject/src/lib.rs:159:23 | -| 2 | overriding `_`, which std's adaptors call in place of `next` or beside it | fixtures/reject/src/lib.rs:153:2 | -| 1 | `Pointer` formatting, as in `{:p}`, is not supported | fixtures/reject/src/lib.rs:82:2 | -| 1 | `_` is not supported yet | fixtures/reject/src/lib.rs:409:18 | +| 2 | `_` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it | fixtures/reject/src/lib.rs:268:16 | +| 2 | a field of `_` | fixtures/reject/src/lib.rs:284:7 | +| 2 | an iterator of the crate implementing `_`, which is not supported yet | fixtures/reject/src/lib.rs:175:1 | +| 2 | constructing `_` from another crate | fixtures/reject/src/lib.rs:161:23 | +| 2 | overriding `_`, which std's adaptors call in place of `next` or beside it | fixtures/reject/src/lib.rs:155:2 | +| 2 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | fixtures/reject/src/lib.rs:380:13 | +| 1 | `Pointer` formatting, as in `{:p}`, is not supported | fixtures/reject/src/lib.rs:84:2 | +| 1 | `_` is not supported yet | fixtures/reject/src/lib.rs:404:18 | | 1 | `_` is not supported: its field `_` is `_`, typed `_`, whose `None` would be `rt.None` as `_` | fixtures/reject/src/lib.rs:38:2 | -| 1 | `_` of `_` by `_`, which is not supported yet | fixtures/reject/src/lib.rs:310:6 | -| 1 | `_` of `_`, which drops `_`, which is not supported yet | fixtures/reject/src/lib.rs:67:13 | -| 1 | `_` through a held type's own, which is not supported yet | fixtures/reject/src/lib.rs:342:2 | -| 1 | `_`, which is not supported yet | fixtures/reject/src/lib.rs:318:9 | -| 1 | `fold` of `_`, which folds a `flatten` whose source and iterators both drop, which is not supported yet | fixtures/reject/src/lib.rs:235:26 | -| 1 | a `_` cast from `_` to `_` | fixtures/reject/src/lib.rs:110:2 | -| 1 | a `zip` of `_` and `_`, which std reads by index, of items that drop, which is not supported yet | fixtures/reject/src/lib.rs:240:30 | -| 1 | a `zip` of `_`, whose closures std calls one item further through `next` than through `fold` | fixtures/reject/src/lib.rs:186:51 | -| 1 | a coercion to `_` | fixtures/reject/src/lib.rs:365:2 | -| 1 | a constant of type `_` | fixtures/reject/src/lib.rs:94:2 | -| 1 | a copy of a closure that changes what it captured | fixtures/reject/src/lib.rs:276:14 | -| 1 | a mutable borrow of a subslice of `_`, which JS would copy, having no views | fixtures/reject/src/lib.rs:245:13 | -| 1 | a mutable reference into a `Result`'s payload, passed on or kept | fixtures/reject/src/lib.rs:441:12 | -| 1 | a printable type must implement `Display` or `Debug` | fixtures/reject/src/lib.rs:106:1 | +| 1 | `_` of `_` by `_`, which is not supported yet | fixtures/reject/src/lib.rs:312:6 | +| 1 | `_` of `_`, which drops `_`, which is not supported yet | fixtures/reject/src/lib.rs:69:13 | +| 1 | `_` of `_`, which folds a closure that drops beside what else drops, which is not supported yet | fixtures/reject/src/lib.rs:63:23 | +| 1 | `_` through a held type's own, which is not supported yet | fixtures/reject/src/lib.rs:344:2 | +| 1 | `_`, which is not supported yet | fixtures/reject/src/lib.rs:320:9 | +| 1 | `fold` of `_`, which folds a `flatten` whose source and iterators both drop, which is not supported yet | fixtures/reject/src/lib.rs:237:26 | +| 1 | a `_` cast from `_` to `_` | fixtures/reject/src/lib.rs:112:2 | +| 1 | a `zip` of `_` and `_`, which std reads by index, of items that drop, which is not supported yet | fixtures/reject/src/lib.rs:242:30 | +| 1 | a `zip` of `_`, whose closures std calls one item further through `next` than through `fold` | fixtures/reject/src/lib.rs:188:51 | +| 1 | a coercion to `_` | fixtures/reject/src/lib.rs:367:2 | +| 1 | a constant of type `_` | fixtures/reject/src/lib.rs:96:2 | +| 1 | a copy of a closure that changes what it captured | fixtures/reject/src/lib.rs:278:14 | +| 1 | a mutable borrow of a subslice of `_`, which JS would copy, having no views | fixtures/reject/src/lib.rs:247:13 | +| 1 | a mutable reference into a `Result`'s payload, passed on or kept | fixtures/reject/src/lib.rs:436:12 | +| 1 | a printable type must implement `Display` or `Debug` | fixtures/reject/src/lib.rs:108:1 | | 1 | a scalar constant of type `_` | fixtures/reject/src/lib.rs:8:2 | -| 1 | a zero-sized constant of type `_` | fixtures/reject/src/lib.rs:76:2 | -| 1 | an iterator that owns `_`, which drops, which is not supported yet | fixtures/reject/src/lib.rs:392:13 | +| 1 | a zero-sized constant of type `_` | fixtures/reject/src/lib.rs:78:2 | | 1 | arithmetic on `_` | fixtures/reject/src/lib.rs:8:2 | | 1 | collecting `_`, whose `None` is `rt.None`, which is not supported yet | fixtures/reject/src/lib.rs:43:43 | -| 1 | comparing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:292:52 | -| 1 | constructing `_` | fixtures/reject/src/lib.rs:416:53 | -| 1 | hashing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:292:52 | +| 1 | comparing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:294:52 | +| 1 | constructing `_` | fixtures/reject/src/lib.rs:411:53 | +| 1 | hashing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:294:52 | +| 1 | passing `_`, which drops, to `_`, which is not supported yet | fixtures/reject/src/lib.rs:388:4 | ## By API @@ -56,167 +56,149 @@ The type or module each refused type or path belongs to. | Count | API | First | | ---: | --- | --- | -| 7 | `std::borrow::Cow` | fixtures/reject/src/lib.rs:398:2 | +| 7 | `std::borrow::Cow` | fixtures/reject/src/lib.rs:393:2 | | 6 | `Option` | fixtures/reject/src/lib.rs:23:15 | | 6 | `f64` | fixtures/reject/src/lib.rs:7:14 | -| 5 | `Iterator` | fixtures/reject/src/lib.rs:48:42 | -| 5 | `{closure}` | fixtures/reject/src/lib.rs:61:11 | -| 3 | `std::iter::Map` | fixtures/reject/src/lib.rs:61:18 | +| 4 | `Iterator` | fixtures/reject/src/lib.rs:48:42 | +| 3 | `std::iter::Map` | fixtures/reject/src/lib.rs:63:23 | | 3 | `std::slice` | fixtures/reject/src/lib.rs:28:4 | -| 3 | `std::sync::Arc` | fixtures/reject/src/lib.rs:115:2 | -| 2 | `HashMap` | fixtures/reject/src/lib.rs:287:6 | -| 2 | `Meters` | fixtures/reject/src/lib.rs:99:2 | -| 2 | `Noisy` | fixtures/reject/src/lib.rs:67:13 | -| 2 | `Poll` | fixtures/reject/src/lib.rs:119:20 | -| 2 | `std::collections::HashMap` | fixtures/reject/src/lib.rs:67:13 | -| 2 | `std::iter::Iterator` | fixtures/reject/src/lib.rs:266:16 | -| 2 | `std::iter::Take` | fixtures/reject/src/lib.rs:390:79 | -| 2 | `std::ops::Range` | fixtures/reject/src/lib.rs:194:8 | -| 2 | `std::pin::Pin` | fixtures/reject/src/lib.rs:130:2 | -| 2 | `std::vec::IntoIter` | fixtures/reject/src/lib.rs:467:17 | -| 2 | `std::vec::Vec` | fixtures/reject/src/lib.rs:292:52 | -| 2 | `u8` | fixtures/reject/src/lib.rs:94:2 | -| 1 | `DoubleEndedIterator` | fixtures/reject/src/lib.rs:173:1 | -| 1 | `Entry` | fixtures/reject/src/lib.rs:381:13 | -| 1 | `FusedIterator` | fixtures/reject/src/lib.rs:227:1 | -| 1 | `Hasher` | fixtures/reject/src/lib.rs:318:9 | -| 1 | `IntToFloat` | fixtures/reject/src/lib.rs:110:2 | +| 3 | `std::sync::Arc` | fixtures/reject/src/lib.rs:117:2 | +| 3 | `{closure}` | fixtures/reject/src/lib.rs:380:13 | +| 2 | `HashMap` | fixtures/reject/src/lib.rs:289:6 | +| 2 | `Meters` | fixtures/reject/src/lib.rs:101:2 | +| 2 | `Poll` | fixtures/reject/src/lib.rs:121:20 | +| 2 | `std::collections::HashMap` | fixtures/reject/src/lib.rs:69:13 | +| 2 | `std::iter::Iterator` | fixtures/reject/src/lib.rs:268:16 | +| 2 | `std::ops::Range` | fixtures/reject/src/lib.rs:196:8 | +| 2 | `std::pin::Pin` | fixtures/reject/src/lib.rs:132:2 | +| 2 | `std::vec::IntoIter` | fixtures/reject/src/lib.rs:462:17 | +| 2 | `std::vec::Vec` | fixtures/reject/src/lib.rs:294:52 | +| 2 | `u8` | fixtures/reject/src/lib.rs:96:2 | +| 1 | `DoubleEndedIterator` | fixtures/reject/src/lib.rs:175:1 | +| 1 | `Entry` | fixtures/reject/src/lib.rs:380:13 | +| 1 | `FusedIterator` | fixtures/reject/src/lib.rs:229:1 | +| 1 | `Hasher` | fixtures/reject/src/lib.rs:320:9 | +| 1 | `IntToFloat` | fixtures/reject/src/lib.rs:112:2 | | 1 | `Maybe` | fixtures/reject/src/lib.rs:38:2 | +| 1 | `Noisy` | fixtures/reject/src/lib.rs:69:13 | | 1 | `T \| undefined` | fixtures/reject/src/lib.rs:38:2 | -| 1 | `[u16; 1]` | fixtures/reject/src/lib.rs:259:22 | +| 1 | `[u16; 1]` | fixtures/reject/src/lib.rs:261:22 | +| 1 | `count` | fixtures/reject/src/lib.rs:63:23 | | 1 | `dyn std::ops::Fn(u8) -> u8` | fixtures/reject/src/lib.rs:11:16 | -| 1 | `from_fn` | fixtures/reject/src/lib.rs:391:13 | -| 1 | `into_keys` | fixtures/reject/src/lib.rs:67:13 | -| 1 | `std::collections::hash_map::Entry` | fixtures/reject/src/lib.rs:431:15 | -| 1 | `std::iter::Chain` | fixtures/reject/src/lib.rs:186:51 | -| 1 | `std::iter::Flatten` | fixtures/reject/src/lib.rs:235:26 | +| 1 | `into_keys` | fixtures/reject/src/lib.rs:69:13 | +| 1 | `std::collections::hash_map::Entry` | fixtures/reject/src/lib.rs:426:15 | +| 1 | `std::iter::Chain` | fixtures/reject/src/lib.rs:188:51 | +| 1 | `std::iter::Flatten` | fixtures/reject/src/lib.rs:237:26 | | 1 | `std::iter::IntoIterator` | fixtures/reject/src/lib.rs:17:2 | -| 1 | `std::iter::Rev` | fixtures/reject/src/lib.rs:180:14 | -| 1 | `std::mem` | fixtures/reject/src/lib.rs:60:29 | -| 1 | `std::ops::RangeFrom` | fixtures/reject/src/lib.rs:282:48 | -| 1 | `std::ops::RangeTo` | fixtures/reject/src/lib.rs:282:7 | -| 1 | `std::option::Option` | fixtures/reject/src/lib.rs:448:2 | -| 1 | `std::slice::Iter` | fixtures/reject/src/lib.rs:140:11 | -| 1 | `std::str` | fixtures/reject/src/lib.rs:371:4 | -| 1 | `std::string::String` | fixtures/reject/src/lib.rs:88:10 | -| 1 | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:135:2 | -| 1 | `successors` | fixtures/reject/src/lib.rs:390:15 | -| 1 | `u32` | fixtures/reject/src/lib.rs:245:13 | -| 1 | `u64` | fixtures/reject/src/lib.rs:110:2 | +| 1 | `std::iter::Rev` | fixtures/reject/src/lib.rs:182:14 | +| 1 | `std::ops::RangeFrom` | fixtures/reject/src/lib.rs:284:48 | +| 1 | `std::ops::RangeTo` | fixtures/reject/src/lib.rs:284:7 | +| 1 | `std::option::Option` | fixtures/reject/src/lib.rs:443:2 | +| 1 | `std::slice::Iter` | fixtures/reject/src/lib.rs:142:11 | +| 1 | `std::str` | fixtures/reject/src/lib.rs:373:4 | +| 1 | `std::string::String` | fixtures/reject/src/lib.rs:90:10 | +| 1 | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:137:2 | +| 1 | `str` | fixtures/reject/src/lib.rs:388:4 | +| 1 | `u32` | fixtures/reject/src/lib.rs:247:13 | +| 1 | `u64` | fixtures/reject/src/lib.rs:112:2 | | 1 | `value` | fixtures/reject/src/lib.rs:38:2 | -| 1 | `{async closure}` | fixtures/reject/src/lib.rs:76:2 | +| 1 | `{async closure}` | fixtures/reject/src/lib.rs:78:2 | ## By type or path | Count | Construct | Type or path | First | | ---: | --- | --- | --- | -| 4 | a variant of `_`, which is not supported: either is the same JS string | `std::borrow::Cow` | fixtures/reject/src/lib.rs:398:2 | +| 4 | a variant of `_`, which is not supported: either is the same JS string | `std::borrow::Cow` | fixtures/reject/src/lib.rs:393:2 | | 3 | unsupported type `_` | `f64` | fixtures/reject/src/lib.rs:7:14 | -| 2 | `_` is not supported: it would be pending two ways with one value | `Poll` | fixtures/reject/src/lib.rs:119:20 | +| 2 | `_` is not supported: it would be pending two ways with one value | `Poll` | fixtures/reject/src/lib.rs:121:20 | | 2 | `_` is not supported: its `None` and `Some` would both be `rt.None` | `Option` | fixtures/reject/src/lib.rs:23:15 | -| 2 | an assignment through a reference to `_` | `std::pin::Pin` | fixtures/reject/src/lib.rs:130:2 | -| 2 | dropping `_`, which is not supported yet | `std::iter::Take` | fixtures/reject/src/lib.rs:390:79 | -| 2 | replacing the value behind a reference to `_` | `Meters` | fixtures/reject/src/lib.rs:99:2 | -| 2 | unsupported call to `_` | `::sum` | fixtures/reject/src/lib.rs:467:17 | -| 1 | `_` is not supported yet | `std::borrow::Cow` | fixtures/reject/src/lib.rs:409:18 | +| 2 | an assignment through a reference to `_` | `std::pin::Pin` | fixtures/reject/src/lib.rs:132:2 | +| 2 | replacing the value behind a reference to `_` | `Meters` | fixtures/reject/src/lib.rs:101:2 | +| 2 | unsupported call to `_` | `::sum` | fixtures/reject/src/lib.rs:462:17 | +| 1 | `_` is not supported yet | `std::borrow::Cow` | fixtures/reject/src/lib.rs:404:18 | | 1 | `_` is not supported: its field `_` is `_`, typed `_`, whose `None` would be `rt.None` as `_` | `Maybe`, `value`, `Option`, `T \| undefined`, `Option` | fixtures/reject/src/lib.rs:38:2 | -| 1 | `_` of `_` by `_`, which is not supported yet | `HashMap::contains_key`, `std::collections::HashMap`, `u8` | fixtures/reject/src/lib.rs:310:6 | -| 1 | `_` of `_`, which drops `_`, which is not supported yet | `into_keys`, `std::collections::HashMap`, `Noisy` | fixtures/reject/src/lib.rs:67:13 | -| 1 | `_` of `_`, whose `None` is `rt.None`, which is not supported yet | `HashMap::get`, `Option` | fixtures/reject/src/lib.rs:287:6 | +| 1 | `_` of `_` by `_`, which is not supported yet | `HashMap::contains_key`, `std::collections::HashMap`, `u8` | fixtures/reject/src/lib.rs:312:6 | +| 1 | `_` of `_`, which drops `_`, which is not supported yet | `into_keys`, `std::collections::HashMap`, `Noisy` | fixtures/reject/src/lib.rs:69:13 | +| 1 | `_` of `_`, which folds a closure that drops beside what else drops, which is not supported yet | `count`, `std::iter::Map` | fixtures/reject/src/lib.rs:63:23 | +| 1 | `_` of `_`, whose `None` is `rt.None`, which is not supported yet | `HashMap::get`, `Option` | fixtures/reject/src/lib.rs:289:6 | | 1 | `_` of `_`, whose `None` is `rt.None`, which is not supported yet | `Iterator::find`, `Option` | fixtures/reject/src/lib.rs:48:42 | -| 1 | `_` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it | `std::iter::Iterator::count` | fixtures/reject/src/lib.rs:266:38 | -| 1 | `_` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it | `std::iter::Iterator::filter` | fixtures/reject/src/lib.rs:266:16 | -| 1 | `_` through a held type's own, which is not supported yet | `::ne` | fixtures/reject/src/lib.rs:342:2 | -| 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::collections::hash_map::Entry::and_modify` | fixtures/reject/src/lib.rs:431:15 | +| 1 | `_` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it | `std::iter::Iterator::count` | fixtures/reject/src/lib.rs:268:38 | +| 1 | `_` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it | `std::iter::Iterator::filter` | fixtures/reject/src/lib.rs:268:16 | +| 1 | `_` through a held type's own, which is not supported yet | `::ne` | fixtures/reject/src/lib.rs:344:2 | +| 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::collections::hash_map::Entry::and_modify` | fixtures/reject/src/lib.rs:426:15 | | 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::iter::IntoIterator::into_iter` | fixtures/reject/src/lib.rs:17:2 | -| 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::slice::last_mut` | fixtures/reject/src/lib.rs:424:21 | -| 1 | `_`, which is not supported yet | `Hasher::write` | fixtures/reject/src/lib.rs:318:9 | -| 1 | `fold` of `_`, which folds a `flatten` whose source and iterators both drop, which is not supported yet | `std::iter::Flatten` | fixtures/reject/src/lib.rs:235:26 | -| 1 | a `_` cast from `_` to `_` | `IntToFloat`, `u64`, `f64` | fixtures/reject/src/lib.rs:110:2 | -| 1 | a `zip` of `_` and `_`, which std reads by index, of items that drop, which is not supported yet | `std::iter::Map`, `std::ops::Range` | fixtures/reject/src/lib.rs:240:30 | -| 1 | a `zip` of `_`, whose closures std calls one item further through `next` than through `fold` | `std::iter::Chain` | fixtures/reject/src/lib.rs:186:51 | -| 1 | a coercion to `_` | `std::sync::Arc` | fixtures/reject/src/lib.rs:365:2 | -| 1 | a constant of type `_` | `&u8` | fixtures/reject/src/lib.rs:94:2 | -| 1 | a field of `_` | `std::ops::RangeFrom` | fixtures/reject/src/lib.rs:282:48 | -| 1 | a field of `_` | `std::ops::RangeTo` | fixtures/reject/src/lib.rs:282:7 | -| 1 | a mutable borrow of a subslice of `_`, which JS would copy, having no views | `u32` | fixtures/reject/src/lib.rs:245:13 | +| 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::slice::last_mut` | fixtures/reject/src/lib.rs:419:21 | +| 1 | `_`, which is not supported yet | `Hasher::write` | fixtures/reject/src/lib.rs:320:9 | +| 1 | `fold` of `_`, which folds a `flatten` whose source and iterators both drop, which is not supported yet | `std::iter::Flatten` | fixtures/reject/src/lib.rs:237:26 | +| 1 | a `_` cast from `_` to `_` | `IntToFloat`, `u64`, `f64` | fixtures/reject/src/lib.rs:112:2 | +| 1 | a `zip` of `_` and `_`, which std reads by index, of items that drop, which is not supported yet | `std::iter::Map`, `std::ops::Range` | fixtures/reject/src/lib.rs:242:30 | +| 1 | a `zip` of `_`, whose closures std calls one item further through `next` than through `fold` | `std::iter::Chain` | fixtures/reject/src/lib.rs:188:51 | +| 1 | a coercion to `_` | `std::sync::Arc` | fixtures/reject/src/lib.rs:367:2 | +| 1 | a constant of type `_` | `&u8` | fixtures/reject/src/lib.rs:96:2 | +| 1 | a field of `_` | `std::ops::RangeFrom` | fixtures/reject/src/lib.rs:284:48 | +| 1 | a field of `_` | `std::ops::RangeTo` | fixtures/reject/src/lib.rs:284:7 | +| 1 | a mutable borrow of a subslice of `_`, which JS would copy, having no views | `u32` | fixtures/reject/src/lib.rs:247:13 | | 1 | a scalar constant of type `_` | `f64` | fixtures/reject/src/lib.rs:8:2 | -| 1 | a zero-sized constant of type `_` | `{async closure}` | fixtures/reject/src/lib.rs:76:2 | -| 1 | an assignment through a reference to `_` | `std::sync::Arc` | fixtures/reject/src/lib.rs:115:2 | -| 1 | an assignment through a reference to `_` | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:135:2 | -| 1 | an iterator of the crate implementing `_`, which is not supported yet | `DoubleEndedIterator` | fixtures/reject/src/lib.rs:173:1 | -| 1 | an iterator of the crate implementing `_`, which is not supported yet | `FusedIterator` | fixtures/reject/src/lib.rs:227:1 | -| 1 | an iterator that owns `_`, which drops, which is not supported yet | `Noisy` | fixtures/reject/src/lib.rs:392:13 | +| 1 | a zero-sized constant of type `_` | `{async closure}` | fixtures/reject/src/lib.rs:78:2 | +| 1 | an assignment through a reference to `_` | `std::sync::Arc` | fixtures/reject/src/lib.rs:117:2 | +| 1 | an assignment through a reference to `_` | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:137:2 | +| 1 | an iterator of the crate implementing `_`, which is not supported yet | `DoubleEndedIterator` | fixtures/reject/src/lib.rs:175:1 | +| 1 | an iterator of the crate implementing `_`, which is not supported yet | `FusedIterator` | fixtures/reject/src/lib.rs:229:1 | | 1 | arithmetic on `_` | `f64` | fixtures/reject/src/lib.rs:8:2 | | 1 | collecting `_`, whose `None` is `rt.None`, which is not supported yet | `Option` | fixtures/reject/src/lib.rs:43:43 | -| 1 | comparing `_` as a key, which is not supported yet | `std::vec::Vec` | fixtures/reject/src/lib.rs:292:52 | -| 1 | constructing `_` | `std::borrow::Cow` | fixtures/reject/src/lib.rs:416:53 | -| 1 | constructing `_` from another crate | `std::iter::Map` | fixtures/reject/src/lib.rs:159:23 | -| 1 | constructing `_` from another crate | `std::iter::Rev` | fixtures/reject/src/lib.rs:180:14 | -| 1 | dropping `_`, which is not supported yet | `std::iter::Map` | fixtures/reject/src/lib.rs:61:18 | -| 1 | hashing `_` as a key, which is not supported yet | `std::vec::Vec` | fixtures/reject/src/lib.rs:292:52 | -| 1 | overriding `_`, which std's adaptors call in place of `next` or beside it | `Iterator::fold` | fixtures/reject/src/lib.rs:153:2 | -| 1 | overriding `_`, which std's adaptors call in place of `next` or beside it | `Iterator::size_hint` | fixtures/reject/src/lib.rs:207:2 | -| 1 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | `{closure}`, `Entry::or_insert_with` | fixtures/reject/src/lib.rs:381:13 | -| 1 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | `{closure}`, `Iterator::any` | fixtures/reject/src/lib.rs:382:11 | -| 1 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | `{closure}`, `Iterator::map` | fixtures/reject/src/lib.rs:61:11 | -| 1 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | `{closure}`, `from_fn::from_fn` | fixtures/reject/src/lib.rs:391:13 | -| 1 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | `{closure}`, `successors::successors` | fixtures/reject/src/lib.rs:390:15 | -| 1 | replacing the value behind a reference to `_` | `[u16; 1]` | fixtures/reject/src/lib.rs:259:22 | -| 1 | unsupported call to `_` | `::deref` | fixtures/reject/src/lib.rs:410:2 | -| 1 | unsupported call to `_` | `::eq` | fixtures/reject/src/lib.rs:448:2 | -| 1 | unsupported call to `_` | `::cycle` | fixtures/reject/src/lib.rs:140:11 | -| 1 | unsupported call to `_` | `::write_fmt` | fixtures/reject/src/lib.rs:88:10 | -| 1 | unsupported call to `_` | `std::mem::size_of_val` | fixtures/reject/src/lib.rs:60:29 | -| 1 | unsupported call to `_` | `std::ops::Range::contains` | fixtures/reject/src/lib.rs:194:8 | -| 1 | unsupported call to `_` | `std::slice::copy_within` | fixtures/reject/src/lib.rs:360:4 | +| 1 | comparing `_` as a key, which is not supported yet | `std::vec::Vec` | fixtures/reject/src/lib.rs:294:52 | +| 1 | constructing `_` | `std::borrow::Cow` | fixtures/reject/src/lib.rs:411:53 | +| 1 | constructing `_` from another crate | `std::iter::Map` | fixtures/reject/src/lib.rs:161:23 | +| 1 | constructing `_` from another crate | `std::iter::Rev` | fixtures/reject/src/lib.rs:182:14 | +| 1 | hashing `_` as a key, which is not supported yet | `std::vec::Vec` | fixtures/reject/src/lib.rs:294:52 | +| 1 | overriding `_`, which std's adaptors call in place of `next` or beside it | `Iterator::fold` | fixtures/reject/src/lib.rs:155:2 | +| 1 | overriding `_`, which std's adaptors call in place of `next` or beside it | `Iterator::size_hint` | fixtures/reject/src/lib.rs:209:2 | +| 1 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | `{closure}`, `Entry::or_insert_with` | fixtures/reject/src/lib.rs:380:13 | +| 1 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | `{closure}`, `Iterator::for_each` | fixtures/reject/src/lib.rs:381:16 | +| 1 | passing `_`, which drops, to `_`, which is not supported yet | `{closure}`, `str::contains` | fixtures/reject/src/lib.rs:388:4 | +| 1 | replacing the value behind a reference to `_` | `[u16; 1]` | fixtures/reject/src/lib.rs:261:22 | +| 1 | unsupported call to `_` | `::deref` | fixtures/reject/src/lib.rs:405:2 | +| 1 | unsupported call to `_` | `::eq` | fixtures/reject/src/lib.rs:443:2 | +| 1 | unsupported call to `_` | `::cycle` | fixtures/reject/src/lib.rs:142:11 | +| 1 | unsupported call to `_` | `::write_fmt` | fixtures/reject/src/lib.rs:90:10 | +| 1 | unsupported call to `_` | `std::ops::Range::contains` | fixtures/reject/src/lib.rs:196:8 | +| 1 | unsupported call to `_` | `std::slice::copy_within` | fixtures/reject/src/lib.rs:362:4 | | 1 | unsupported call to `_` | `std::slice::sort` | fixtures/reject/src/lib.rs:28:4 | -| 1 | unsupported call to `_` | `std::str::split` | fixtures/reject/src/lib.rs:371:4 | +| 1 | unsupported call to `_` | `std::str::split` | fixtures/reject/src/lib.rs:373:4 | | 1 | unsupported type `_` | `dyn std::ops::Fn(u8) -> u8` | fixtures/reject/src/lib.rs:11:16 | ## Spans -
unsupported call to `_` (11) +
unsupported call to `_` (10) - fixtures/reject/src/lib.rs:28:4: unsupported call to `std::slice::::sort` -- fixtures/reject/src/lib.rs:60:29: unsupported call to `std::mem::size_of_val::` -- fixtures/reject/src/lib.rs:88:10: unsupported call to `::write_fmt` -- fixtures/reject/src/lib.rs:140:11: unsupported call to ` as std::iter::Iterator>::cycle` -- fixtures/reject/src/lib.rs:194:8: unsupported call to `std::ops::Range::::contains::` -- fixtures/reject/src/lib.rs:360:4: unsupported call to `core::slice::::copy_within::>` -- fixtures/reject/src/lib.rs:371:4: unsupported call to `core::str::::split::<[char; 2]>` -- fixtures/reject/src/lib.rs:410:2: unsupported call to ` as std::ops::Deref>::deref` -- fixtures/reject/src/lib.rs:448:2: unsupported call to ` as std::cmp::PartialEq>::eq` -- fixtures/reject/src/lib.rs:467:17: unsupported call to ` as std::iter::Iterator>::sum::` -- fixtures/reject/src/lib.rs:467:38: unsupported call to ` as std::iter::Iterator>::sum::` - -
- -
passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet (5) - -- fixtures/reject/src/lib.rs:61:11: passing `{closure@fixtures/reject/src/lib.rs:60:10: 60:23}`, a closure that owns a value that drops, to `Iterator::map`, which is not supported yet -- fixtures/reject/src/lib.rs:381:13: passing `{closure@fixtures/reject/src/lib.rs:381:28: 381:35}`, a closure that owns a value that drops, to `Entry::or_insert_with`, which is not supported yet -- fixtures/reject/src/lib.rs:382:11: passing `{closure@fixtures/reject/src/lib.rs:382:15: 382:24}`, a closure that owns a value that drops, to `Iterator::any`, which is not supported yet -- fixtures/reject/src/lib.rs:390:15: passing `{closure@fixtures/reject/src/lib.rs:390:48: 390:56}`, a closure that owns a value that drops, to `successors::successors`, which is not supported yet -- fixtures/reject/src/lib.rs:391:13: passing `{closure@fixtures/reject/src/lib.rs:391:32: 391:39}`, a closure that owns a value that drops, to `from_fn::from_fn`, which is not supported yet +- fixtures/reject/src/lib.rs:90:10: unsupported call to `::write_fmt` +- fixtures/reject/src/lib.rs:142:11: unsupported call to ` as std::iter::Iterator>::cycle` +- fixtures/reject/src/lib.rs:196:8: unsupported call to `std::ops::Range::::contains::` +- fixtures/reject/src/lib.rs:362:4: unsupported call to `core::slice::::copy_within::>` +- fixtures/reject/src/lib.rs:373:4: unsupported call to `core::str::::split::<[char; 2]>` +- fixtures/reject/src/lib.rs:405:2: unsupported call to ` as std::ops::Deref>::deref` +- fixtures/reject/src/lib.rs:443:2: unsupported call to ` as std::cmp::PartialEq>::eq` +- fixtures/reject/src/lib.rs:462:17: unsupported call to ` as std::iter::Iterator>::sum::` +- fixtures/reject/src/lib.rs:462:38: unsupported call to ` as std::iter::Iterator>::sum::`
a variant of `_`, which is not supported: either is the same JS string (4) -- fixtures/reject/src/lib.rs:398:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string -- fixtures/reject/src/lib.rs:399:30: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string -- fixtures/reject/src/lib.rs:400:27: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string -- fixtures/reject/src/lib.rs:405:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +- fixtures/reject/src/lib.rs:393:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +- fixtures/reject/src/lib.rs:394:30: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +- fixtures/reject/src/lib.rs:395:27: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +- fixtures/reject/src/lib.rs:400:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string
an assignment through a reference to `_` (4) -- fixtures/reject/src/lib.rs:115:2: an assignment through a reference to `std::sync::Arc` -- fixtures/reject/src/lib.rs:130:2: an assignment through a reference to `std::pin::Pin>` -- fixtures/reject/src/lib.rs:135:2: an assignment through a reference to `std::sync::MutexGuard<'_, u8>` -- fixtures/reject/src/lib.rs:253:2: an assignment through a reference to `std::pin::Pin<&mut Noisy>` +- fixtures/reject/src/lib.rs:117:2: an assignment through a reference to `std::sync::Arc` +- fixtures/reject/src/lib.rs:132:2: an assignment through a reference to `std::pin::Pin>` +- fixtures/reject/src/lib.rs:137:2: an assignment through a reference to `std::sync::MutexGuard<'_, u8>` +- fixtures/reject/src/lib.rs:255:2: an assignment through a reference to `std::pin::Pin<&mut Noisy>`
@@ -225,38 +207,30 @@ The type or module each refused type or path belongs to. - fixtures/reject/src/lib.rs:7:14: unsupported type `f64` - fixtures/reject/src/lib.rs:7:25: unsupported type `f64` - fixtures/reject/src/lib.rs:11:16: unsupported type `dyn std::ops::Fn(u8) -> u8` -- fixtures/reject/src/lib.rs:108:51: unsupported type `f64` +- fixtures/reject/src/lib.rs:110:51: unsupported type `f64`
`_` with a mutable reference to a value JS copies, which its mapping would copy (3) - fixtures/reject/src/lib.rs:17:2: `std::iter::IntoIterator::into_iter` with a mutable reference to a value JS copies, which its mapping would copy -- fixtures/reject/src/lib.rs:424:21: `core::slice::::last_mut` with a mutable reference to a value JS copies, which its mapping would copy -- fixtures/reject/src/lib.rs:431:15: `std::collections::hash_map::Entry::<'a, K, V, A>::and_modify` with a mutable reference to a value JS copies, which its mapping would copy - -
- -
dropping `_`, which is not supported yet (3) - -- fixtures/reject/src/lib.rs:61:18: dropping `std::iter::Map, {closure@fixtures/reject/src/lib.rs:60:10: 60:23}>`, which is not supported yet -- fixtures/reject/src/lib.rs:390:79: dropping `std::iter::Take>`, which is not supported yet -- fixtures/reject/src/lib.rs:391:62: dropping `std::iter::Take>`, which is not supported yet +- fixtures/reject/src/lib.rs:419:21: `core::slice::::last_mut` with a mutable reference to a value JS copies, which its mapping would copy +- fixtures/reject/src/lib.rs:426:15: `std::collections::hash_map::Entry::<'a, K, V, A>::and_modify` with a mutable reference to a value JS copies, which its mapping would copy
replacing the value behind a reference to `_` (3) -- fixtures/reject/src/lib.rs:99:2: replacing the value behind a reference to `Meters` -- fixtures/reject/src/lib.rs:103:2: replacing the value behind a reference to `Meters` -- fixtures/reject/src/lib.rs:259:22: replacing the value behind a reference to `[u16; 1]` +- fixtures/reject/src/lib.rs:101:2: replacing the value behind a reference to `Meters` +- fixtures/reject/src/lib.rs:105:2: replacing the value behind a reference to `Meters` +- fixtures/reject/src/lib.rs:261:22: replacing the value behind a reference to `[u16; 1]`
`_` is not supported: it would be pending two ways with one value (2) -- fixtures/reject/src/lib.rs:119:20: `Poll>>` is not supported: it would be pending two ways with one value -- fixtures/reject/src/lib.rs:124:54: `Poll>` is not supported: it would be pending two ways with one value +- fixtures/reject/src/lib.rs:121:20: `Poll>>` is not supported: it would be pending two ways with one value +- fixtures/reject/src/lib.rs:126:54: `Poll>` is not supported: it would be pending two ways with one value
@@ -270,54 +244,61 @@ The type or module each refused type or path belongs to.
`_` of `_`, whose `None` is `rt.None`, which is not supported yet (2) - fixtures/reject/src/lib.rs:48:42: `Iterator::find` of `Option>`, whose `None` is `rt.None`, which is not supported yet -- fixtures/reject/src/lib.rs:287:6: `HashMap::get` of `Option<&std::option::Option>`, whose `None` is `rt.None`, which is not supported yet +- fixtures/reject/src/lib.rs:289:6: `HashMap::get` of `Option<&std::option::Option>`, whose `None` is `rt.None`, which is not supported yet
`_` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it (2) -- fixtures/reject/src/lib.rs:266:16: `std::iter::Iterator::filter` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it -- fixtures/reject/src/lib.rs:266:38: `std::iter::Iterator::count` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it +- fixtures/reject/src/lib.rs:268:16: `std::iter::Iterator::filter` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it +- fixtures/reject/src/lib.rs:268:38: `std::iter::Iterator::count` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it
a field of `_` (2) -- fixtures/reject/src/lib.rs:282:7: a field of `std::ops::RangeTo` -- fixtures/reject/src/lib.rs:282:48: a field of `std::ops::RangeFrom` +- fixtures/reject/src/lib.rs:284:7: a field of `std::ops::RangeTo` +- fixtures/reject/src/lib.rs:284:48: a field of `std::ops::RangeFrom`
an iterator of the crate implementing `_`, which is not supported yet (2) -- fixtures/reject/src/lib.rs:173:1: an iterator of the crate implementing `DoubleEndedIterator`, which is not supported yet -- fixtures/reject/src/lib.rs:227:1: an iterator of the crate implementing `FusedIterator`, which is not supported yet +- fixtures/reject/src/lib.rs:175:1: an iterator of the crate implementing `DoubleEndedIterator`, which is not supported yet +- fixtures/reject/src/lib.rs:229:1: an iterator of the crate implementing `FusedIterator`, which is not supported yet
constructing `_` from another crate (2) -- fixtures/reject/src/lib.rs:159:23: constructing `std::iter::Map` from another crate -- fixtures/reject/src/lib.rs:180:14: constructing `std::iter::Rev` from another crate +- fixtures/reject/src/lib.rs:161:23: constructing `std::iter::Map` from another crate +- fixtures/reject/src/lib.rs:182:14: constructing `std::iter::Rev` from another crate
overriding `_`, which std's adaptors call in place of `next` or beside it (2) -- fixtures/reject/src/lib.rs:153:2: overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it -- fixtures/reject/src/lib.rs:207:2: overriding `Iterator::size_hint`, which std's adaptors call in place of `next` or beside it +- fixtures/reject/src/lib.rs:155:2: overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it +- fixtures/reject/src/lib.rs:209:2: overriding `Iterator::size_hint`, which std's adaptors call in place of `next` or beside it + +
+ +
passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet (2) + +- fixtures/reject/src/lib.rs:380:13: passing `{closure@fixtures/reject/src/lib.rs:380:28: 380:35}`, a closure that owns a value that drops, to `Entry::or_insert_with`, which is not supported yet +- fixtures/reject/src/lib.rs:381:16: passing `{closure@fixtures/reject/src/lib.rs:381:25: 381:33}`, a closure that owns a value that drops, to `Iterator::for_each`, which is not supported yet
`Pointer` formatting, as in `{:p}`, is not supported (1) -- fixtures/reject/src/lib.rs:82:2: `Pointer` formatting, as in `{:p}`, is not supported +- fixtures/reject/src/lib.rs:84:2: `Pointer` formatting, as in `{:p}`, is not supported
`_` is not supported yet (1) -- fixtures/reject/src/lib.rs:409:18: `std::borrow::Cow<'_, [u8]>` is not supported yet +- fixtures/reject/src/lib.rs:404:18: `std::borrow::Cow<'_, [u8]>` is not supported yet
@@ -329,85 +310,91 @@ The type or module each refused type or path belongs to.
`_` of `_` by `_`, which is not supported yet (1) -- fixtures/reject/src/lib.rs:310:6: `HashMap::contains_key` of `std::collections::HashMap` by `u8`, which is not supported yet +- fixtures/reject/src/lib.rs:312:6: `HashMap::contains_key` of `std::collections::HashMap` by `u8`, which is not supported yet
`_` of `_`, which drops `_`, which is not supported yet (1) -- fixtures/reject/src/lib.rs:67:13: `into_keys` of `std::collections::HashMap`, which drops `Noisy`, which is not supported yet +- fixtures/reject/src/lib.rs:69:13: `into_keys` of `std::collections::HashMap`, which drops `Noisy`, which is not supported yet + +
+ +
`_` of `_`, which folds a closure that drops beside what else drops, which is not supported yet (1) + +- fixtures/reject/src/lib.rs:63:23: `count` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:62:10: 62:25}>`, which folds a closure that drops beside what else drops, which is not supported yet
`_` through a held type's own, which is not supported yet (1) -- fixtures/reject/src/lib.rs:342:2: ` as PartialEq>::ne` through a held type's own, which is not supported yet +- fixtures/reject/src/lib.rs:344:2: ` as PartialEq>::ne` through a held type's own, which is not supported yet
`_`, which is not supported yet (1) -- fixtures/reject/src/lib.rs:318:9: `Hasher::write`, which is not supported yet +- fixtures/reject/src/lib.rs:320:9: `Hasher::write`, which is not supported yet
`fold` of `_`, which folds a `flatten` whose source and iterators both drop, which is not supported yet (1) -- fixtures/reject/src/lib.rs:235:26: `fold` of `std::iter::Flatten>>`, which folds a `flatten` whose source and iterators both drop, which is not supported yet +- fixtures/reject/src/lib.rs:237:26: `fold` of `std::iter::Flatten>>`, which folds a `flatten` whose source and iterators both drop, which is not supported yet
a `_` cast from `_` to `_` (1) -- fixtures/reject/src/lib.rs:110:2: a `IntToFloat` cast from `u64` to `f64` +- fixtures/reject/src/lib.rs:112:2: a `IntToFloat` cast from `u64` to `f64`
a `zip` of `_` and `_`, which std reads by index, of items that drop, which is not supported yet (1) -- fixtures/reject/src/lib.rs:240:30: a `zip` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:240:15: 240:19}>` and `std::ops::Range`, which std reads by index, of items that drop, which is not supported yet +- fixtures/reject/src/lib.rs:242:30: a `zip` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:242:15: 242:19}>` and `std::ops::Range`, which std reads by index, of items that drop, which is not supported yet
a `zip` of `_`, whose closures std calls one item further through `next` than through `fold` (1) -- fixtures/reject/src/lib.rs:186:51: a `zip` of `std::iter::Chain, {closure@fixtures/reject/src/lib.rs:186:15: 186:18}>, std::iter::Copied>>`, whose closures std calls one item further through `next` than through `fold` +- fixtures/reject/src/lib.rs:188:51: a `zip` of `std::iter::Chain, {closure@fixtures/reject/src/lib.rs:188:15: 188:18}>, std::iter::Copied>>`, whose closures std calls one item further through `next` than through `fold`
a coercion to `_` (1) -- fixtures/reject/src/lib.rs:365:2: a coercion to `std::sync::Arc<[u8]>` +- fixtures/reject/src/lib.rs:367:2: a coercion to `std::sync::Arc<[u8]>`
a constant of type `_` (1) -- fixtures/reject/src/lib.rs:94:2: a constant of type `&u8` +- fixtures/reject/src/lib.rs:96:2: a constant of type `&u8`
a copy of a closure that changes what it captured (1) -- fixtures/reject/src/lib.rs:276:14: a copy of a closure that changes what it captured +- fixtures/reject/src/lib.rs:278:14: a copy of a closure that changes what it captured
a mutable borrow of a subslice of `_`, which JS would copy, having no views (1) -- fixtures/reject/src/lib.rs:245:13: a mutable borrow of a subslice of `u32`, which JS would copy, having no views +- fixtures/reject/src/lib.rs:247:13: a mutable borrow of a subslice of `u32`, which JS would copy, having no views
a mutable reference into a `Result`'s payload, passed on or kept (1) -- fixtures/reject/src/lib.rs:441:12: a mutable reference into a `Result`'s payload, passed on or kept +- fixtures/reject/src/lib.rs:436:12: a mutable reference into a `Result`'s payload, passed on or kept
a printable type must implement `Display` or `Debug` (1) -- fixtures/reject/src/lib.rs:106:1: a printable type must implement `Display` or `Debug` +- fixtures/reject/src/lib.rs:108:1: a printable type must implement `Display` or `Debug`
@@ -419,13 +406,7 @@ The type or module each refused type or path belongs to.
a zero-sized constant of type `_` (1) -- fixtures/reject/src/lib.rs:76:2: a zero-sized constant of type `{async closure@fixtures/reject/src/lib.rs:75:10: 75:18}` - -
- -
an iterator that owns `_`, which drops, which is not supported yet (1) - -- fixtures/reject/src/lib.rs:392:13: an iterator that owns `Noisy`, which drops, which is not supported yet +- fixtures/reject/src/lib.rs:78:2: a zero-sized constant of type `{async closure@fixtures/reject/src/lib.rs:77:10: 77:18}`
@@ -443,18 +424,24 @@ The type or module each refused type or path belongs to.
comparing `_` as a key, which is not supported yet (1) -- fixtures/reject/src/lib.rs:292:52: comparing `std::vec::Vec` as a key, which is not supported yet +- fixtures/reject/src/lib.rs:294:52: comparing `std::vec::Vec` as a key, which is not supported yet
constructing `_` (1) -- fixtures/reject/src/lib.rs:416:53: constructing `std::borrow::Cow<'_, std::sync::Arc>` +- fixtures/reject/src/lib.rs:411:53: constructing `std::borrow::Cow<'_, std::sync::Arc>`
hashing `_` as a key, which is not supported yet (1) -- fixtures/reject/src/lib.rs:292:52: hashing `std::vec::Vec` as a key, which is not supported yet +- fixtures/reject/src/lib.rs:294:52: hashing `std::vec::Vec` as a key, which is not supported yet + +
+ +
passing `_`, which drops, to `_`, which is not supported yet (1) + +- fixtures/reject/src/lib.rs:388:4: passing `{closure@fixtures/reject/src/lib.rs:388:13: 388:27}`, which drops, to `str::contains`, which is not supported yet
diff --git a/ts/fixtures/reject/expected.txt b/ts/fixtures/reject/expected.txt index b7335e933..293e72324 100644 --- a/ts/fixtures/reject/expected.txt +++ b/ts/fixtures/reject/expected.txt @@ -1,6 +1,6 @@ -a root must not be generic at fixtures/reject/src/lib.rs:108:1 +a root must not be generic at fixtures/reject/src/lib.rs:110:1 no item `missing` in the crate -a printable type must implement `Display` or `Debug` at fixtures/reject/src/lib.rs:106:1 +a printable type must implement `Display` or `Debug` at fixtures/reject/src/lib.rs:108:1 unsupported type `f64` at fixtures/reject/src/lib.rs:7:14 a scalar constant of type `f64` at fixtures/reject/src/lib.rs:8:2 arithmetic on `f64` at fixtures/reject/src/lib.rs:8:2 @@ -13,65 +13,59 @@ unsupported call to `std::slice::::sort` at fixtures/reject/src/lib.r `Iterator::find` of `Option>`, whose `None` is `rt.None`, which is not supported yet at fixtures/reject/src/lib.rs:48:42 `Maybe<()>` is not supported: its field `value` is `Option`, typed `T | undefined`, whose `None` would be `rt.None` as `Option<()>` at fixtures/reject/src/lib.rs:38:2 collecting `Option<()>`, whose `None` is `rt.None`, which is not supported yet at fixtures/reject/src/lib.rs:43:43 -unsupported call to `std::mem::size_of_val::` at fixtures/reject/src/lib.rs:60:29 -passing `{closure@fixtures/reject/src/lib.rs:60:10: 60:23}`, a closure that owns a value that drops, to `Iterator::map`, which is not supported yet at fixtures/reject/src/lib.rs:61:11 -dropping `std::iter::Map, {closure@fixtures/reject/src/lib.rs:60:10: 60:23}>`, which is not supported yet at fixtures/reject/src/lib.rs:61:18 -`into_keys` of `std::collections::HashMap`, which drops `Noisy`, which is not supported yet at fixtures/reject/src/lib.rs:67:13 -a zero-sized constant of type `{async closure@fixtures/reject/src/lib.rs:75:10: 75:18}` at fixtures/reject/src/lib.rs:76:2 -`Pointer` formatting, as in `{:p}`, is not supported at fixtures/reject/src/lib.rs:82:11 -unsupported call to `::write_fmt` at fixtures/reject/src/lib.rs:88:10 -a constant of type `&u8` at fixtures/reject/src/lib.rs:94:2 -replacing the value behind a reference to `Meters` at fixtures/reject/src/lib.rs:99:2 -replacing the value behind a reference to `Meters` at fixtures/reject/src/lib.rs:103:2 -an assignment through a reference to `std::sync::Arc` at fixtures/reject/src/lib.rs:115:2 -`Poll>>` is not supported: it would be pending two ways with one value at fixtures/reject/src/lib.rs:119:20 -`Poll>` is not supported: it would be pending two ways with one value at fixtures/reject/src/lib.rs:124:54 -an assignment through a reference to `std::pin::Pin>` at fixtures/reject/src/lib.rs:130:2 -an assignment through a reference to `std::sync::MutexGuard<'_, u8>` at fixtures/reject/src/lib.rs:135:2 -unsupported call to ` as std::iter::Iterator>::cycle` at fixtures/reject/src/lib.rs:140:11 -constructing `std::iter::Map` from another crate at fixtures/reject/src/lib.rs:159:23 -constructing `std::iter::Rev` from another crate at fixtures/reject/src/lib.rs:180:14 -a `zip` of `std::iter::Chain, {closure@fixtures/reject/src/lib.rs:186:15: 186:18}>, std::iter::Copied>>`, whose closures std calls one item further through `next` than through `fold` at fixtures/reject/src/lib.rs:186:51 -unsupported call to `std::ops::Range::::contains::` at fixtures/reject/src/lib.rs:194:8 -`fold` of `std::iter::Flatten>>`, which folds a `flatten` whose source and iterators both drop, which is not supported yet at fixtures/reject/src/lib.rs:235:26 -a `zip` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:240:15: 240:19}>` and `std::ops::Range`, which std reads by index, of items that drop, which is not supported yet at fixtures/reject/src/lib.rs:240:30 -a mutable borrow of a subslice of `u32`, which JS would copy, having no views at fixtures/reject/src/lib.rs:245:13 -an assignment through a reference to `std::pin::Pin<&mut Noisy>` at fixtures/reject/src/lib.rs:253:2 -replacing the value behind a reference to `[u16; 1]` at fixtures/reject/src/lib.rs:259:22 -`std::iter::Iterator::filter` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it at fixtures/reject/src/lib.rs:266:16 -`std::iter::Iterator::count` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it at fixtures/reject/src/lib.rs:266:38 -a copy of a closure that changes what it captured at fixtures/reject/src/lib.rs:276:14 -a field of `std::ops::RangeTo` at fixtures/reject/src/lib.rs:282:7 -a field of `std::ops::RangeFrom` at fixtures/reject/src/lib.rs:282:48 -`HashMap::get` of `Option<&std::option::Option>`, whose `None` is `rt.None`, which is not supported yet at fixtures/reject/src/lib.rs:287:6 -hashing `std::vec::Vec` as a key, which is not supported yet at fixtures/reject/src/lib.rs:292:52 -comparing `std::vec::Vec` as a key, which is not supported yet at fixtures/reject/src/lib.rs:292:52 -`HashMap::contains_key` of `std::collections::HashMap` by `u8`, which is not supported yet at fixtures/reject/src/lib.rs:310:6 -unsupported call to `core::slice::::copy_within::>` at fixtures/reject/src/lib.rs:360:4 -a coercion to `std::sync::Arc<[u8]>` at fixtures/reject/src/lib.rs:365:2 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:398:2 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:400:27 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:399:30 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:405:2 -`std::borrow::Cow<'_, [u8]>` is not supported yet at fixtures/reject/src/lib.rs:409:18 -unsupported call to ` as std::ops::Deref>::deref` at fixtures/reject/src/lib.rs:410:2 -constructing `std::borrow::Cow<'_, std::sync::Arc>` at fixtures/reject/src/lib.rs:416:53 -unsupported call to `core::str::::split::<[char; 2]>` at fixtures/reject/src/lib.rs:371:4 -passing `{closure@fixtures/reject/src/lib.rs:381:28: 381:35}`, a closure that owns a value that drops, to `Entry::or_insert_with`, which is not supported yet at fixtures/reject/src/lib.rs:381:13 -passing `{closure@fixtures/reject/src/lib.rs:382:15: 382:24}`, a closure that owns a value that drops, to `Iterator::any`, which is not supported yet at fixtures/reject/src/lib.rs:382:11 -passing `{closure@fixtures/reject/src/lib.rs:390:48: 390:56}`, a closure that owns a value that drops, to `successors::successors`, which is not supported yet at fixtures/reject/src/lib.rs:390:15 -dropping `std::iter::Take>`, which is not supported yet at fixtures/reject/src/lib.rs:390:79 -passing `{closure@fixtures/reject/src/lib.rs:391:32: 391:39}`, a closure that owns a value that drops, to `from_fn::from_fn`, which is not supported yet at fixtures/reject/src/lib.rs:391:13 -dropping `std::iter::Take>`, which is not supported yet at fixtures/reject/src/lib.rs:391:62 -an iterator that owns `Noisy`, which drops, which is not supported yet at fixtures/reject/src/lib.rs:392:13 -unsupported call to ` as std::iter::Iterator>::sum::` at fixtures/reject/src/lib.rs:467:17 -unsupported call to ` as std::iter::Iterator>::sum::` at fixtures/reject/src/lib.rs:467:38 -`core::slice::::last_mut` with a mutable reference to a value JS copies, which its mapping would copy at fixtures/reject/src/lib.rs:424:21 -`std::collections::hash_map::Entry::<'a, K, V, A>::and_modify` with a mutable reference to a value JS copies, which its mapping would copy at fixtures/reject/src/lib.rs:431:15 -a mutable reference into a `Result`'s payload, passed on or kept at fixtures/reject/src/lib.rs:441:12 -unsupported call to ` as std::cmp::PartialEq>::eq` at fixtures/reject/src/lib.rs:448:2 -overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:153:2 -an iterator of the crate implementing `DoubleEndedIterator`, which is not supported yet at fixtures/reject/src/lib.rs:173:1 -overriding `Iterator::size_hint`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:207:2 -an iterator of the crate implementing `FusedIterator`, which is not supported yet at fixtures/reject/src/lib.rs:227:1 -`Hasher::write`, which is not supported yet at fixtures/reject/src/lib.rs:318:9 +`count` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:62:10: 62:25}>`, which folds a closure that drops beside what else drops, which is not supported yet at fixtures/reject/src/lib.rs:63:23 +`into_keys` of `std::collections::HashMap`, which drops `Noisy`, which is not supported yet at fixtures/reject/src/lib.rs:69:13 +a zero-sized constant of type `{async closure@fixtures/reject/src/lib.rs:77:10: 77:18}` at fixtures/reject/src/lib.rs:78:2 +`Pointer` formatting, as in `{:p}`, is not supported at fixtures/reject/src/lib.rs:84:11 +unsupported call to `::write_fmt` at fixtures/reject/src/lib.rs:90:10 +a constant of type `&u8` at fixtures/reject/src/lib.rs:96:2 +replacing the value behind a reference to `Meters` at fixtures/reject/src/lib.rs:101:2 +replacing the value behind a reference to `Meters` at fixtures/reject/src/lib.rs:105:2 +an assignment through a reference to `std::sync::Arc` at fixtures/reject/src/lib.rs:117:2 +`Poll>>` is not supported: it would be pending two ways with one value at fixtures/reject/src/lib.rs:121:20 +`Poll>` is not supported: it would be pending two ways with one value at fixtures/reject/src/lib.rs:126:54 +an assignment through a reference to `std::pin::Pin>` at fixtures/reject/src/lib.rs:132:2 +an assignment through a reference to `std::sync::MutexGuard<'_, u8>` at fixtures/reject/src/lib.rs:137:2 +unsupported call to ` as std::iter::Iterator>::cycle` at fixtures/reject/src/lib.rs:142:11 +constructing `std::iter::Map` from another crate at fixtures/reject/src/lib.rs:161:23 +constructing `std::iter::Rev` from another crate at fixtures/reject/src/lib.rs:182:14 +a `zip` of `std::iter::Chain, {closure@fixtures/reject/src/lib.rs:188:15: 188:18}>, std::iter::Copied>>`, whose closures std calls one item further through `next` than through `fold` at fixtures/reject/src/lib.rs:188:51 +unsupported call to `std::ops::Range::::contains::` at fixtures/reject/src/lib.rs:196:8 +`fold` of `std::iter::Flatten>>`, which folds a `flatten` whose source and iterators both drop, which is not supported yet at fixtures/reject/src/lib.rs:237:26 +a `zip` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:242:15: 242:19}>` and `std::ops::Range`, which std reads by index, of items that drop, which is not supported yet at fixtures/reject/src/lib.rs:242:30 +a mutable borrow of a subslice of `u32`, which JS would copy, having no views at fixtures/reject/src/lib.rs:247:13 +an assignment through a reference to `std::pin::Pin<&mut Noisy>` at fixtures/reject/src/lib.rs:255:2 +replacing the value behind a reference to `[u16; 1]` at fixtures/reject/src/lib.rs:261:22 +`std::iter::Iterator::filter` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it at fixtures/reject/src/lib.rs:268:16 +`std::iter::Iterator::count` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it at fixtures/reject/src/lib.rs:268:38 +a copy of a closure that changes what it captured at fixtures/reject/src/lib.rs:278:14 +a field of `std::ops::RangeTo` at fixtures/reject/src/lib.rs:284:7 +a field of `std::ops::RangeFrom` at fixtures/reject/src/lib.rs:284:48 +`HashMap::get` of `Option<&std::option::Option>`, whose `None` is `rt.None`, which is not supported yet at fixtures/reject/src/lib.rs:289:6 +hashing `std::vec::Vec` as a key, which is not supported yet at fixtures/reject/src/lib.rs:294:52 +comparing `std::vec::Vec` as a key, which is not supported yet at fixtures/reject/src/lib.rs:294:52 +`HashMap::contains_key` of `std::collections::HashMap` by `u8`, which is not supported yet at fixtures/reject/src/lib.rs:312:6 +unsupported call to `core::slice::::copy_within::>` at fixtures/reject/src/lib.rs:362:4 +a coercion to `std::sync::Arc<[u8]>` at fixtures/reject/src/lib.rs:367:2 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:393:2 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:395:27 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:394:30 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:400:2 +`std::borrow::Cow<'_, [u8]>` is not supported yet at fixtures/reject/src/lib.rs:404:18 +unsupported call to ` as std::ops::Deref>::deref` at fixtures/reject/src/lib.rs:405:2 +constructing `std::borrow::Cow<'_, std::sync::Arc>` at fixtures/reject/src/lib.rs:411:53 +unsupported call to `core::str::::split::<[char; 2]>` at fixtures/reject/src/lib.rs:373:4 +passing `{closure@fixtures/reject/src/lib.rs:380:28: 380:35}`, a closure that owns a value that drops, to `Entry::or_insert_with`, which is not supported yet at fixtures/reject/src/lib.rs:380:13 +passing `{closure@fixtures/reject/src/lib.rs:381:25: 381:33}`, a closure that owns a value that drops, to `Iterator::for_each`, which is not supported yet at fixtures/reject/src/lib.rs:381:16 +passing `{closure@fixtures/reject/src/lib.rs:388:13: 388:27}`, which drops, to `str::contains`, which is not supported yet at fixtures/reject/src/lib.rs:388:4 +unsupported call to ` as std::iter::Iterator>::sum::` at fixtures/reject/src/lib.rs:462:17 +unsupported call to ` as std::iter::Iterator>::sum::` at fixtures/reject/src/lib.rs:462:38 +`core::slice::::last_mut` with a mutable reference to a value JS copies, which its mapping would copy at fixtures/reject/src/lib.rs:419:21 +`std::collections::hash_map::Entry::<'a, K, V, A>::and_modify` with a mutable reference to a value JS copies, which its mapping would copy at fixtures/reject/src/lib.rs:426:15 +a mutable reference into a `Result`'s payload, passed on or kept at fixtures/reject/src/lib.rs:436:12 +unsupported call to ` as std::cmp::PartialEq>::eq` at fixtures/reject/src/lib.rs:443:2 +overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:155:2 +an iterator of the crate implementing `DoubleEndedIterator`, which is not supported yet at fixtures/reject/src/lib.rs:175:1 +overriding `Iterator::size_hint`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:209:2 +an iterator of the crate implementing `FusedIterator`, which is not supported yet at fixtures/reject/src/lib.rs:229:1 +`Hasher::write`, which is not supported yet at fixtures/reject/src/lib.rs:320:9 diff --git a/ts/fixtures/reject/src/lib.rs b/ts/fixtures/reject/src/lib.rs index 85de41a3d..0823ee3ec 100644 --- a/ts/fixtures/reject/src/lib.rs +++ b/ts/fixtures/reject/src/lib.rs @@ -54,11 +54,13 @@ impl Drop for Noisy { fn drop(&mut self) {} } -/// A closure that owns a value that drops, which `map` would hold but never drop. -pub fn owning_closure(v: &[u8]) -> usize { +/// A closure that owns a value that drops, which `count`'s `fold` drops before the items +/// `map` holds, where dropping `map` drops it after. +pub fn owning_closure(v: Vec) -> usize { let n = Noisy(1); - let f = move |x: &u8| *x + std::mem::size_of_val(&n) as u8; - v.iter().map(f).count() + // Through a reference, it owns `n` whole rather than a copy of its field. + let f = move |x: Noisy| x.0 + (&n).0; + v.into_iter().map(f).count() } /// std's `fold` of `into_keys` drops each value after its key, where `next` drops it first. @@ -371,26 +373,19 @@ pub fn split_chars(s: &str) -> usize { s.split(['a', 'b']).count() } -/// Closures that own a value that drops, which `any` and `or_insert_with` would call but -/// never drop. -pub fn called_closure(v: &[u8], m: &mut std::collections::HashMap) -> bool { - fn id(n: &Noisy) -> u8 { - n.0 - } +/// Closures that own a value that drops, which `or_insert_with` would call but never drop +/// if the key is there, and which `for_each` drops before the items it doesn't reach. +pub fn called_closure(v: Vec, m: &mut std::collections::HashMap) { let (a, b) = (Noisy(1), Noisy(2)); m.entry(1).or_insert_with(move || b); - v.iter().any(move |&x| x == id(&a)) -} - -/// Each drops its closure, and the `Noisy` it owns, when it is done with it, as -/// `successors` does the item it holds next. -pub fn owning_lazy() -> usize { - let (b, c) = (Noisy(2), Noisy(3)); - // Through a reference, each owns its `Noisy` whole rather than a copy of its field. - let walked = std::iter::successors(Some(0u8), move |_| Some((&b).0)).take(2).count(); - let made = std::iter::from_fn(move || Some((&c).0)).take(2).count(); - let held = std::iter::successors(Some(Noisy(4)), |_| None).count(); - walked + made + held + v.into_iter().for_each(move |x| assert!(x.0 != (&a).0)); +} + +/// A closure that owns a value that drops, given as a `Pattern`, which `contains` would +/// call but never drop. +pub fn pattern_closure(s: &str) -> bool { + let n = Noisy(1); + s.contains(move |c: char| c as u8 == (&n).0) } /// A `Cow` is a JS string, which keeps no variant to match on or ask about. diff --git a/ts/fixtures/reject/ts.toml b/ts/fixtures/reject/ts.toml index f6fe558a6..1442dcc07 100644 --- a/ts/fixtures/reject/ts.toml +++ b/ts/fixtures/reject/ts.toml @@ -50,7 +50,7 @@ roots = [ "cow_made", "split_chars", "called_closure", - "owning_lazy", + "pattern_closure", "parts_summed", "last_bumped", "modified", diff --git a/ts/fixtures/task/expected/core/option.ts b/ts/fixtures/task/expected/core/option.ts index 8ab57220e..1398aa065 100644 --- a/ts/fixtures/task/expected/core/option.ts +++ b/ts/fixtures/task/expected/core/option.ts @@ -35,6 +35,13 @@ export function unwrapOr$Option_u64(self: rt.u64 | undefined, default_: rt.u64): return self; } +export function map$Option_Guard_u32_iterated_closure16(self: Guard.Guard | undefined, f: (a0: Guard.Guard) => rt.u32): rt.u32 | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + export function map$Option_u32_u32_blasted_closure3(self: rt.u32 | undefined, f: (a0: rt.u32) => rt.u32): rt.u32 | undefined { let _0!: rt.u32 | undefined; let _8: boolean = false; diff --git a/ts/fixtures/task/expected/drops.ts b/ts/fixtures/task/expected/drops.ts index 72c049577..1bef255ef 100644 --- a/ts/fixtures/task/expected/drops.ts +++ b/ts/fixtures/task/expected/drops.ts @@ -4,7 +4,7 @@ import * as rt from "./rt.ts"; import { drop$Arc_Wrap_Pair_Held, drop$Arc_str_Arc_str, drop$Bomb_Guard, drop$Guard_Entries_Bomb_Guard_Held, drop$Held, drop$Mutex_Held, drop$Option_Box_Held, drop$Option_Guard_Guard, drop$Option_Held, drop$Pair_Held, drop$Result_Guard_Guard, drop$Result_u8_Key, drop$Wrap_Arc_Held, drop$Wrap_Guard, drop$Wrap_Held, drop$Wrap_Pair_Held, drop$Wrap_Vec_Wrap_Held } from "./lib.ts"; import { isSomeAnd$Option_Guard_options_closure7, unwrapOr$Option_Guard, unwrapOr$Option_u64, mapOr$Option_u32_Guard_options_closure2, okOr$Option_Guard_Guard, filter$Option_Guard_options_closure4, orElse$Option_Guard_options_closure6, zip$Option_Guard_Guard, clone$Clone_Option_Arc_Guard } from "./core/option.ts"; import { ok$Result_Guard_Guard, err$Result_Guard_Guard, mapOrElse$Result_Guard_Guard_u32_options_closure9_options_closure10, inspectErr$Result_u8_Key_tripped_closure6, andThen$Result_Guard_Guard_Guard_options_closure8, unwrapOr$Result_Guard_Guard } from "./core/result.ts"; -import { scoped, discarded, blasted } from "./drops/closures.ts"; +import { scoped, discarded, iterated, blasted } from "./drops/closures.ts"; import { looped, collected, drained, extended, bombed, spent } from "./drops/iters.ts"; import * as Bomb from "./drops.Bomb.ts"; import * as Entries from "./drops.Entries.ts"; @@ -22,7 +22,7 @@ import * as Log from "./log.Log.ts"; import * as Guard from "./model.Guard.ts"; /** - * Run scenario `arg % 22`, panicking at the point `arg / 22 % 8` names, if any: what + * Run scenario `arg % 23`, panicking at the point `arg / 23 % 11` names, if any: what * every value std holds drops, where Rust drops it, and in Rust's order. */ export function run(log: Log.Log, id: rt.u32, arg: rt.u8): void { @@ -85,7 +85,7 @@ export function run(log: Log.Log, id: rt.u32, arg: rt.u8): void { _380 = false; _379 = false; _378 = false; - const at: rt.u8 = rt.u8Rem(rt.u8Div(arg, 22), 8); + const at: rt.u8 = rt.u8Rem(rt.u8Div(arg, 23), 11); const guard: (a0: rt.u32) => Guard.Guard = (n: rt.u32): Guard.Guard => { return Guard.new(rt.u32Add(id, n), Log.clone$Clone(log)); }; @@ -95,8 +95,10 @@ export function run(log: Log.Log, id: rt.u32, arg: rt.u8): void { rt.panicFmt(["d", args18[0], " at ", args18[1]]); } }; - const _13: rt.u8 = rt.u8Rem(arg, 22); - if (_13 === 19) { + const _13: rt.u8 = rt.u8Rem(arg, 23); + if (_13 === 22) { + iterated(log, id, at); + } else if (_13 === 19) { scoped(log, id, at); } else if (_13 === 20) { discarded(log, id, at); @@ -134,23 +136,23 @@ export function run(log: Log.Log, id: rt.u32, arg: rt.u8): void { grown(log, id, at, false); } else if (_13 === 0) { v = []; - unwind = 219; + unwind = 220; const _19 = { tag: "One", _0: guard(1) } as Held.Held; v.push(_19); v.push({ tag: "Empty" } as Held.Held); _29 = guard(2); - unwind = 218; - const _32: Guard.Guard = guard(3); unwind = 219; + const _32: Guard.Guard = guard(3); + unwind = 220; v.push({ tag: "Two", _0: _29, _1: _32 } as Held.Held); - unwind = 217; + unwind = 218; held_ = v; check(1); arc = new rt.Arc({ tag: "One", _0: guard(4) } as Held.Held); - unwind = 238; + unwind = 239; _386 = true; shared = rt.arcClone(arc); - unwind = 216; + unwind = 217; _386 = false; rt.arcDrop(arc, drop$Held); const part4 = shared.strong; @@ -158,7 +160,7 @@ export function run(log: Log.Log, id: rt.u32, arg: rt.u8): void { Log.note(log, rt.fmtFormat(["arc ", args2[0]])); const part5 = shared.strong; cloned = rt.arcClone(shared); - unwind = 236; + unwind = 237; _385 = true; const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(part5, f)]; Log.note(log, rt.fmtFormat(["counted ", args4[0]])); @@ -166,22 +168,22 @@ export function run(log: Log.Log, id: rt.u32, arg: rt.u8): void { rt.arcDrop(cloned, drop$Held); check(2); v2 = []; - unwind = 215; + unwind = 216; const _85 = { tag: "One", _0: guard(5) } as Held.Held; v2.push(_85); - unwind = 236; + unwind = 237; mutex = new rt.Mutex(v2); - unwind = 234; + unwind = 235; _384 = true; _91 = guard(6); - unwind = 214; + unwind = 215; const _94: Guard.Guard = guard(7); - unwind = 234; + unwind = 235; boxed = { tag: "Two", _0: _91, _1: _94 } as Held.Held; - unwind = 232; + unwind = 233; _383 = true; const _98: Held.Held = { tag: "One", _0: guard(8) }; - unwind = 213; + unwind = 214; maybe = _98; check(3); const _112: rt.usize = held_.length; @@ -194,9 +196,9 @@ export function run(log: Log.Log, id: rt.u32, arg: rt.u8): void { _384 = false; rt.dropAll(mutex.value, drop$Held); check(5); - unwind = 232; + unwind = 233; drop$Option_Box_Held(maybe); - unwind = 238; + unwind = 239; _383 = false; _384 = false; _385 = false; @@ -207,57 +209,57 @@ export function run(log: Log.Log, id: rt.u32, arg: rt.u8): void { } else if (_13 === 1) { const _133: rt.u32 = rt.u32Add(id, 10); _135 = Log.clone$Clone(log); - unwind = 212; + unwind = 213; const _137: Guard.Guard = guard(11); - unwind = 211; + unwind = 212; wrapped = new Wrap.Wrap({ id: _133, log: _135, inner: { tag: "One", _0: _137 } as Held.Held }); const _141: rt.u32 = rt.u32Add(id, 20); _143 = Log.clone$Clone(log); - unwind = 210; + unwind = 211; const _144: Guard.Guard = guard(21); - unwind = 209; + unwind = 210; guarded = new Wrap.Wrap({ id: _141, log: _143, inner: _144 }); check(1); _152 = guard(31); - unwind = 208; + unwind = 209; const _155: Guard.Guard = guard(32); - unwind = 207; + unwind = 208; _151 = { tag: "Two", _0: _152, _1: _155 } as Held.Held; const _158: Guard.Guard = guard(33); - unwind = 230; + unwind = 231; _382 = true; pair = new Pair.Pair({ first: _151, second: _158 }); v3 = []; - unwind = 206; + unwind = 207; _166 = guard(41); - unwind = 205; - const _169: Guard.Guard = guard(42); unwind = 206; + const _169: Guard.Guard = guard(42); + unwind = 207; v3.push(new Pair.Pair({ first: _166, second: _169 })); _175 = guard(43); - unwind = 204; + unwind = 205; const _178: Guard.Guard = guard(44); - unwind = 206; + unwind = 207; v3.push(new Pair.Pair({ first: _175, second: _178 })); - unwind = 202; + unwind = 203; pairs = v3; _borrowed = new Named.Named({ tag: "Borrowed", _0: "text" } as Text.Text); const _186: Guard.Guard = guard(45); - unwind = 201; + unwind = 202; _owned = new Named.Named({ tag: "Owned", _0: _186 } as Text.Text); check(2); const _193: rt.u32 = rt.u32Add(id, 50); _195 = Log.clone$Clone(log); - unwind = 200; + unwind = 201; v4 = []; - unwind = 199; + unwind = 200; const _201: rt.u32 = rt.u32Add(id, 60); _203 = Log.clone$Clone(log); - unwind = 198; - const _205: Guard.Guard = guard(61); unwind = 199; + const _205: Guard.Guard = guard(61); + unwind = 200; v4.push(new Wrap.Wrap({ id: _201, log: _203, inner: { tag: "One", _0: _205 } as Held.Held })); - unwind = 197; + unwind = 198; nested = new Wrap.Wrap({ id: _193, log: _195, inner: v4 }); check(3); _382 = false; @@ -268,15 +270,15 @@ export function run(log: Log.Log, id: rt.u32, arg: rt.u8): void { const _228: rt.u32 = rt.u32Add(rt.u32Add(Guard.id(pairs[rt.idx(pairs, 1)].first), Guard.id(pairs[rt.idx(pairs, 0)].second)), nested.inner.length as rt.u32); const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(_222, f), (f: rt.Formatter) => rt.u32Display(_225, f), (f: rt.Formatter) => rt.u32Display(_228, f)]; Log.note(log, rt.fmtFormat(["wraps ", args8[0], " ", args8[1], " ", args8[2]])); - unwind = 201; - drop$Wrap_Vec_Wrap_Held(nested); unwind = 202; - rt.drop(_owned); + drop$Wrap_Vec_Wrap_Held(nested); unwind = 203; + rt.drop(_owned); + unwind = 204; rt.drop(_borrowed); - unwind = 230; + unwind = 231; rt.dropAll(pairs); - unwind = 211; + unwind = 212; _382 = false; drop$Wrap_Guard(guarded); unwind = 0; @@ -284,22 +286,22 @@ export function run(log: Log.Log, id: rt.u32, arg: rt.u8): void { } else if (_13 === 2) { const _251: rt.u32 = rt.u32Add(id, 70); _253 = Log.clone$Clone(log); - unwind = 196; + unwind = 197; const _256: Guard.Guard = guard(71); - unwind = 195; + unwind = 196; _255 = { tag: "One", _0: _256 } as Held.Held; const _259: Guard.Guard = guard(72); unwind = 0; shared2 = new rt.Arc(new Wrap.Wrap({ id: _251, log: _253, inner: new Pair.Pair({ first: _255, second: _259 }) })); - unwind = 228; + unwind = 229; _381 = true; v5 = []; - unwind = 194; + unwind = 195; const _266: rt.Arc>> = rt.arcClone(shared2); v5.push(_266); const _270: rt.Arc>> = rt.arcClone(shared2); v5.push(_270); - unwind = 193; + unwind = 194; clones = v5; check(1); _381 = false; @@ -311,36 +313,36 @@ export function run(log: Log.Log, id: rt.u32, arg: rt.u8): void { const part3 = !bail(log, id, at).ok; const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(part3, f)]; Log.note(log, rt.fmtFormat(["bailed ", args12[0]])); - unwind = 228; + unwind = 229; rt.dropAll(clones, drop$Arc_Wrap_Pair_Held); _381 = false; } else { _308 = guard(81); - unwind = 192; + unwind = 193; const _311: Guard.Guard = guard(82); unwind = 0; arc2 = new rt.Arc(new rt.Mutex({ tag: "Two", _0: _308, _1: _311 } as Held.Held)); - unwind = 226; + unwind = 227; _380 = true; other = rt.arcClone(arc2); - unwind = 191; + unwind = 192; check(1); _380 = false; rt.arcDrop(arc2, drop$Mutex_Held); check(2); const _327: rt.Mutex = other.value; - unwind = 190; - const held2: boolean = Held.isSome(_327.value); unwind = 191; + const held2: boolean = Held.isSome(_327.value); + unwind = 192; const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(held2, f)]; Log.note(log, rt.fmtFormat(["locked ", args14[0]])); lent = guard(83); - unwind = 189; + unwind = 190; borrowed = new rt.Arc(lent); - unwind = 224; + unwind = 225; _379 = true; again = rt.arcClone(borrowed); - unwind = 222; + unwind = 223; _378 = true; _379 = false; rt.arcDrop(borrowed); @@ -350,11 +352,11 @@ export function run(log: Log.Log, id: rt.u32, arg: rt.u8): void { const part = Guard.id(lent); const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(part, f)]; Log.note(log, rt.fmtFormat(["lent ", args16[0]])); - unwind = 191; + unwind = 192; _378 = false; _379 = false; rt.drop(lent); - unwind = 226; + unwind = 227; rt.arcDrop(other, drop$Mutex_Held); _380 = false; } @@ -384,136 +386,136 @@ export function run(log: Log.Log, id: rt.u32, arg: rt.u8): void { if (unwind === 0) { throw e; } - if (unwind === 189) { - break b4; - } if (unwind === 190) { - break b3; + break b4; } if (unwind === 191) { break b3; } if (unwind === 192) { + break b3; + } + if (unwind === 193) { rt.drop(_308); break b1; } - if (unwind === 193) { + if (unwind === 194) { rt.dropAll(clones, drop$Arc_Wrap_Pair_Held); break b5; } - if (unwind === 194) { + if (unwind === 195) { rt.dropAll(v5, drop$Arc_Wrap_Pair_Held); break b5; } - if (unwind === 195) { + if (unwind === 196) { drop$Held(_255); break b6; } - if (unwind === 196) { + if (unwind === 197) { break b6; } - if (unwind === 197) { + if (unwind === 198) { drop$Wrap_Vec_Wrap_Held(nested); break b12; } - if (unwind === 198) { + if (unwind === 199) { rt.drop(_203); break b14; } - if (unwind === 199) { + if (unwind === 200) { break b14; } - if (unwind === 200) { + if (unwind === 201) { break b13; } - if (unwind === 201) { + if (unwind === 202) { break b12; } - if (unwind === 202) { + if (unwind === 203) { break b11; } - if (unwind === 203) { + if (unwind === 204) { break b10; } - if (unwind === 204) { + if (unwind === 205) { rt.drop(_175); break b15; } - if (unwind === 205) { + if (unwind === 206) { rt.drop(_166); break b15; } - if (unwind === 206) { + if (unwind === 207) { break b15; } - if (unwind === 207) { + if (unwind === 208) { drop$Held(_151); break b8; } - if (unwind === 208) { + if (unwind === 209) { rt.drop(_152); break b8; } - if (unwind === 209) { + if (unwind === 210) { break b8; } - if (unwind === 210) { + if (unwind === 211) { rt.drop(_143); break b7; } - if (unwind === 211) { + if (unwind === 212) { break b7; } - if (unwind === 212) { + if (unwind === 213) { rt.drop(_135); break b1; } - if (unwind === 213) { + if (unwind === 214) { drop$Option_Box_Held(maybe); break b21; } - if (unwind === 214) { + if (unwind === 215) { rt.drop(_91); break b20; } - if (unwind === 215) { + if (unwind === 216) { rt.dropAll(v2, drop$Held); break b19; } - if (unwind === 216) { + if (unwind === 217) { break b18; } - if (unwind === 217) { + if (unwind === 218) { break b16; } - if (unwind === 218) { + if (unwind === 219) { rt.drop(_29); break b22; } - if (unwind === 219) { + if (unwind === 220) { break b22; } - if (unwind === 222) { + if (unwind === 223) { if (_378) { rt.arcDrop(again); } - } else if (unwind !== 224) { - if (unwind === 226) { + } else if (unwind !== 225) { + if (unwind === 227) { break b2; } - if (unwind === 228) { + if (unwind === 229) { break b5; } - if (unwind === 230) { + if (unwind === 231) { break b9; } - if (unwind === 232) { + if (unwind === 233) { break b21; } - if (unwind === 234) { + if (unwind === 235) { break b20; } - if (unwind === 236) { + if (unwind === 237) { break b19; } break b17; diff --git a/ts/fixtures/task/expected/drops/closures.ts b/ts/fixtures/task/expected/drops/closures.ts index d1fec3ee3..babab9f37 100644 --- a/ts/fixtures/task/expected/drops/closures.ts +++ b/ts/fixtures/task/expected/drops/closures.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rt from "../rt.ts"; -import { map$Option_u32_u32_blasted_closure3, map$Option_u32_u32_discarded_closure16, mapOr$Option_u32_u32_discarded_closure12 } from "../core/option.ts"; +import { map$Option_Guard_u32_iterated_closure16, map$Option_u32_u32_blasted_closure3, map$Option_u32_u32_discarded_closure16, mapOr$Option_u32_u32_discarded_closure12 } from "../core/option.ts"; import { map$Result_u32_u32_u32_discarded_closure4, mapErr$Result_u32_u32_u32_discarded_closure6, inspectErr$Result_u32_u32_discarded_closure10, andThen$Result_u32_u32_u32_discarded_closure8 } from "../core/result.ts"; import * as Holder from "../drops/closures.Holder.ts"; import * as Bomb from "../drops.Bomb.ts"; @@ -1045,6 +1045,960 @@ export function discarded(log: Log.Log, id: rt.u32, at: rt.u8): void { } } +/** + * What std's iterators and collections drop of a closure that owns a guard: an adaptor + * after the iterator it wraps, and a call that keeps nothing of it as it returns, with + * what each drops of its own before it, panicking at point `at`, if any, some inside a + * closure. + */ +export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { + let a!: Guard.Guard; + let mapped!: rt.Iter; + let v!: Guard.Guard[]; + let b!: Guard.Guard; + let v2!: Guard.Guard[]; + let iter!: rt.Iter; + let g!: Guard.Guard; + let c!: Guard.Guard; + let d!: Guard.Guard; + let e!: Guard.Guard; + let _100!: Guard.Guard; + let _103!: Guard.Guard; + let chained!: rt.Iter; + let v3!: Guard.Guard[]; + let f!: Guard.Guard; + let g2!: Guard.Guard; + let _169!: Guard.Guard; + let flat!: rt.Iter; + let w!: Guard.Guard; + let ended!: rt.Iter; + let h!: Guard.Guard; + let i!: Guard.Guard; + let j!: Guard.Guard; + let _245!: Guard.Guard; + let s!: Guard.Guard; + let chain!: rt.Iter; + let items!: Guard.Guard[]; + let v5!: Guard.Guard[]; + let k!: Guard.Guard; + let l!: Guard.Guard; + let m!: Guard.Guard; + let _321!: Guard.Guard; + let _324!: Guard.Guard; + let n!: Guard.Guard; + let o!: Guard.Guard; + let t!: Guard.Guard; + let u!: Guard.Guard; + let v6!: Guard.Guard; + let _394!: Guard.Guard; + let _397!: Guard.Guard; + let r!: Guard.Guard; + let map!: rt.BTreeMap; + let queue!: rt.VecDeque; + let _537!: boolean; + let _538!: boolean; + let _539!: boolean; + let _540!: boolean; + let _541!: boolean; + let _542!: boolean; + let _543!: boolean; + let _544!: boolean; + let _545!: boolean; + let _546!: boolean; + let _547!: boolean; + let _548!: boolean; + let _549!: boolean; + let _550!: boolean; + let _551!: boolean; + let _552!: boolean; + let _553!: boolean; + let _554!: boolean; + let _555!: boolean; + let _556!: boolean; + let _557!: boolean; + let _558!: boolean; + let _559!: boolean; + let _560!: boolean; + let _561!: boolean; + let _562!: boolean; + let unwind: number = 0; + try { + _562 = false; + _561 = false; + _560 = false; + _559 = false; + _558 = false; + _557 = false; + _556 = false; + _555 = false; + _554 = false; + _553 = false; + _552 = false; + _551 = false; + _550 = false; + _549 = false; + _548 = false; + _547 = false; + _546 = false; + _545 = false; + _544 = false; + _543 = false; + _542 = false; + _541 = false; + _540 = false; + _539 = false; + _538 = false; + _537 = false; + const guard: (a0: rt.u32) => Guard.Guard = (n3: rt.u32): Guard.Guard => { + return Guard.new(rt.u32Add(id, n3), Log.clone$Clone(log)); + }; + const check: (a0: rt.u8) => void = (point: rt.u8): void => { + if (point === at) { + const args28: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(id, f), (f: rt.Formatter) => rt.u8Display(point, f)]; + rt.panicFmt(["d", args28[0], " at ", args28[1]]); + } + }; + _562 = true; + a = guard(1); + unwind = 317; + v = []; + unwind = 272; + const _18: Guard.Guard = guard(2); + v.push(_18); + const _23: Guard.Guard = guard(3); + v.push(_23); + const _28: Guard.Guard = guard(4); + v.push(_28); + unwind = 317; + const _13: rt.Iter = rt.iterSlice(v, rt.drop); + _562 = false; + const captured = id; + const captured2 = check; + const captured3 = a; + mapped = rt.iterMap(_13, rt.closure((g3: Guard.Guard): rt.u32 => { + let unwind2: number = 0; + try { + unwind2 = 10; + if (Guard.id(g3) === rt.u32Add(captured, 3)) { + captured2(1); + } + const _16: rt.u32 = rt.u32Add(Guard.id(g3), Guard.id(captured3)); + unwind2 = 0; + rt.drop(g3); + return _16; + } catch (e3) { + if (unwind2 === 0) { + throw e3; + } + rt.drop(g3); + throw e3; + } + }, (): void => { + rt.drop(captured3); + })); + unwind = 315; + _561 = true; + const _38: rt.u32 | undefined = rt.iterToOption(mapped.next()); + const _41: rt.u32 | undefined = rt.iterToOption(mapped.next()); + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(_38, f, rt.u32Debug), (f: rt.Formatter) => rt.fmtOption(_41, f, rt.u32Debug)]; + Log.note(log, rt.fmtFormat(["map ", args2[0], " ", args2[1]])); + _561 = false; + rt.drop(mapped); + b = guard(5); + unwind = 313; + _560 = true; + v2 = []; + unwind = 271; + const _60: Guard.Guard = guard(6); + v2.push(_60); + const _65: Guard.Guard = guard(7); + v2.push(_65); + const _70: Guard.Guard = guard(8); + v2.push(_70); + unwind = 313; + const _55: rt.Iter = rt.iterSlice(v2, rt.drop); + _560 = false; + const captured4 = b; + iter = rt.iterFilter(_55, rt.closure((g4: Guard.Guard): boolean => { + return Guard.id(g4) !== rt.u32Add(Guard.id(captured4), 1); + }, (): void => { + rt.drop(captured4); + }), rt.drop); + while (true) { + unwind = 270; + const _75: Guard.Guard | rt.Done = iter.next(); + if (_75 === rt.DONE) { + break; + } + unwind = 269; + g = _75; + const part = Guard.id(g); + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(part, f)]; + Log.note(log, rt.fmtFormat(["filter ", args4[0]])); + if (!(Guard.id(g) === rt.u32Add(id, 7))) { + unwind = 270; + rt.drop(g); + } else { + unwind = 270; + rt.drop(g); + break; + } + } + unwind = 313; + rt.drop(iter); + _100 = guard(9); + unwind = 268; + _103 = guard(10); + unwind = 267; + const _106: Guard.Guard = guard(11); + unwind = 309; + _559 = true; + c = _100; + _558 = true; + d = _103; + _557 = true; + e = _106; + v3 = []; + unwind = 264; + const _117: Guard.Guard = guard(12); + v3.push(_117); + const _122: Guard.Guard = guard(13); + v3.push(_122); + const _127: Guard.Guard = guard(14); + v3.push(_127); + const _132: Guard.Guard = guard(15); + v3.push(_132); + unwind = 309; + const _112: rt.Iter = rt.iterSlice(v3, rt.drop); + _559 = false; + const captured5 = c; + const _111: rt.Iter = rt.iterSkipWhile(_112, rt.closure((g5: Guard.Guard): boolean => { + return Guard.id(g5) < rt.u32Add(Guard.id(captured5), 4); + }, (): void => { + rt.drop(captured5); + }), rt.drop); + _558 = false; + const captured6 = d; + const _110: rt.Iter = rt.iterTakeWhile(_111, rt.closure((g6: Guard.Guard): boolean => { + return Guard.id(g6) < rt.u32Add(Guard.id(captured6), 5); + }, (): void => { + rt.drop(captured6); + }), rt.drop); + _557 = false; + const captured7 = id; + const captured8 = check; + const captured9 = e; + chained = rt.iterInspect(_110, rt.closure((g7: Guard.Guard): void => { + if (Guard.id(g7) === rt.u32Add(captured7, 14)) { + captured8(2); + } + const _173: rt.u32 = Guard.id(g7); + const _192: rt.u32 = Guard.id(captured9); + const args30: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_173, f), (f: rt.Formatter) => rt.u32Display(_192, f)]; + Log.note(log, rt.fmtFormat(["inspect ", args30[0], " ", args30[1]])); + }, (): void => { + rt.drop(captured9); + }), rt.drop); + unwind = 307; + _556 = true; + const part2 = map$Option_Guard_u32_iterated_closure16(rt.iterToOption(chained.next()), (g8: Guard.Guard): rt.u32 => { + let unwind3: number = 0; + try { + unwind3 = 4; + const _06: rt.u32 = Guard.id(g8); + unwind3 = 0; + rt.drop(g8); + return _06; + } catch (e4) { + if (unwind3 === 0) { + throw e4; + } + rt.drop(g8); + throw e4; + } + }); + const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part2, f, rt.u32Debug)]; + Log.note(log, rt.fmtFormat(["chained ", args6[0]])); + const part3 = map$Option_Guard_u32_iterated_closure16(rt.iterToOption(chained.next()), (g9: Guard.Guard): rt.u32 => { + let unwind4: number = 0; + try { + unwind4 = 4; + const _07: rt.u32 = Guard.id(g9); + unwind4 = 0; + rt.drop(g9); + return _07; + } catch (e5) { + if (unwind4 === 0) { + throw e5; + } + rt.drop(g9); + throw e5; + } + }); + const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part3, f, rt.u32Debug)]; + Log.note(log, rt.fmtFormat(["chained ", args8[0]])); + _556 = false; + rt.drop(chained); + _169 = guard(16); + unwind = 263; + const _172: Guard.Guard = guard(17); + unwind = 304; + _555 = true; + f = _169; + _554 = true; + g2 = _172; + const v4: rt.u32[] = []; + unwind = 261; + v4.push(1); + v4.push(2); + v4.push(3); + unwind = 304; + const _177: rt.Iter = rt.iterSlice(v4); + _555 = false; + const captured10 = f; + const _176: rt.Iter = rt.iterFilterMap(_177, rt.closure((n4: rt.u32): rt.u32 | undefined => { + return rt.thenSome(n4 !== 2, rt.u32Add(n4, Guard.id(captured10))); + }, (): void => { + rt.drop(captured10); + })); + _554 = false; + const captured11 = g2; + flat = rt.iterFlatMap(_176, rt.closure((n5: rt.u32): rt.u32[] => { + const v7: rt.u32[] = []; + v7.push(n5); + const _83: rt.u32 = rt.u32Add(n5, Guard.id(captured11)); + v7.push(_83); + return v7; + }, (): void => { + rt.drop(captured11); + }), (value: rt.u32[]) => rt.iterSlice(value), true); + unwind = 302; + _553 = true; + const part4 = rt.iterToOption(flat.next()); + const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part4, f, rt.u32Debug)]; + Log.note(log, rt.fmtFormat(["flat ", args10[0]])); + check(3); + _553 = false; + rt.drop(flat); + w = guard(47); + unwind = 300; + _552 = true; + const _209: rt.Iter = rt.iterSlice([1]); + _552 = false; + const captured12 = w; + ended = rt.iterFlatMap(_209, rt.closure((_2: rt.u32): rt.u32[] => { + return [_2, Guard.id(captured12)]; + }, (): void => { + rt.drop(captured12); + }), (value: rt.u32[]) => rt.iterSlice(value), true); + _551 = true; + while (true) { + unwind = 298; + if (!((rt.iterToOption(ended.next()) !== undefined))) { + break; + } + } + Log.note(log, rt.fmtFormat(["flat_map ended"])); + _551 = false; + rt.drop(ended); + h = guard(18); + unwind = 296; + _550 = true; + const _228: rt.Iter = rt.iterSlice([1, 2, 3]); + _550 = false; + const captured13 = h; + const whiles: rt.u32[] = rt.iterToArray(rt.iterMapWhile(_228, rt.closure((_26: rt.u32): rt.u32 | undefined => { + const n7: rt.u32 = _26; + return rt.thenSome(n7 < 3, rt.u32Add(n7, Guard.id(captured13))); + }, (): void => { + rt.drop(captured13); + })), false, rt.drop); + unwind = 260; + const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(whiles, f, rt.u32Debug)]; + Log.note(log, rt.fmtFormat(["map_while ", args12[0]])); + _245 = guard(19); + unwind = 259; + const _248: Guard.Guard = guard(20); + unwind = 293; + _549 = true; + i = _245; + _548 = true; + j = _248; + _549 = false; + const captured14 = check; + const captured15 = i; + const made: rt.usize = rt.ownedCount(rt.iterTake(rt.iterFromFn(rt.closure((): rt.u32 | undefined => { + captured14(4); + return Guard.id(captured15); + }, (): void => { + rt.drop(captured15); + })), 2), rt.drop); + _548 = false; + const captured16 = j; + const walked: rt.u32 = rt.iterSum(rt.iterSuccessors(1, rt.closure((_27: rt.u32): rt.u32 | undefined => { + const n8: rt.u32 = _27; + return rt.thenSome(n8 < 3, rt.u32Sub(rt.u32Add(rt.u32Add(n8, 1), Guard.id(captured16)), Guard.id(captured16))); + }, (): void => { + rt.drop(captured16); + })), rt.u32Add, 0, rt.drop); + s = guard(43); + unwind = 291; + _547 = true; + const _263: Guard.Guard | undefined = guard(40); + _547 = false; + const captured17 = id; + const captured18 = check; + const captured19 = s; + chain = rt.iterSuccessors(_263, rt.closure((g10: Guard.Guard): Guard.Guard | undefined => { + if (Guard.id(g10) === rt.u32Add(captured17, 41)) { + captured18(8); + } + return rt.boolThen(rt.u32Add(Guard.id(g10), 1) < Guard.id(captured19), (): Guard.Guard => { + return Guard.new(rt.u32Add(Guard.id(g10), 1), Log.clone$Clone(log)); + }); + }, (): void => { + rt.drop(captured19); + }), rt.drop); + unwind = 289; + _546 = true; + const _274: rt.u32 | undefined = map$Option_Guard_u32_iterated_closure16(rt.iterToOption(chain.next()), (g11: Guard.Guard): rt.u32 => { + let unwind5: number = 0; + try { + unwind5 = 4; + const _016: rt.u32 = Guard.id(g11); + unwind5 = 0; + rt.drop(g11); + return _016; + } catch (e6) { + if (unwind5 === 0) { + throw e6; + } + rt.drop(g11); + throw e6; + } + }); + const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(made, f), (f: rt.Formatter) => rt.u32Display(walked, f), (f: rt.Formatter) => rt.fmtOption(_274, f, rt.u32Debug)]; + Log.note(log, rt.fmtFormat(["lazy ", args14[0], " ", args14[1], " ", args14[2]])); + const part5 = map$Option_Guard_u32_iterated_closure16(rt.iterToOption(chain.next()), (g12: Guard.Guard): rt.u32 => { + let unwind6: number = 0; + try { + unwind6 = 4; + const _017: rt.u32 = Guard.id(g12); + unwind6 = 0; + rt.drop(g12); + return _017; + } catch (e7) { + if (unwind6 === 0) { + throw e7; + } + rt.drop(g12); + throw e7; + } + }); + const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part5, f, rt.u32Debug)]; + Log.note(log, rt.fmtFormat(["successor ", args16[0]])); + _546 = false; + rt.drop(chain); + v5 = []; + unwind = 257; + const _304: Guard.Guard = guard(21); + v5.push(_304); + const _309: Guard.Guard = guard(22); + v5.push(_309); + const _314: Guard.Guard = guard(23); + v5.push(_314); + unwind = 256; + items = v5; + _321 = guard(24); + unwind = 255; + _324 = guard(25); + unwind = 254; + const _327: Guard.Guard = guard(26); + unwind = 285; + _545 = true; + k = _321; + _544 = true; + l = _324; + _543 = true; + m = _327; + const _332: rt.Iter = rt.iterSlice(items); + _545 = false; + const captured20 = id; + const captured21 = check; + const captured22 = k; + const _335: (a0: Guard.Guard) => boolean = rt.closure((g13: Guard.Guard): boolean => { + if (Guard.id(g13) === rt.u32Add(captured20, 22)) { + captured21(5); + } + return Guard.id(g13) === Guard.id(captured22); + }, (): void => { + rt.drop(captured22); + }); + const any: boolean = rt.dropAfter(_335, () => rt.iterAny(_332, _335)); + const _339: rt.Iter = rt.iterSlice(items); + _544 = false; + const captured23 = l; + const _342: (a0: Guard.Guard) => boolean = rt.closure((g14: Guard.Guard): boolean => { + return Guard.id(g14) === rt.u32Sub(Guard.id(captured23), 3); + }, (): void => { + rt.drop(captured23); + }); + const found: rt.u32 | undefined = map$Option_Guard_u32_iterated_closure16(rt.dropAfter(_342, () => rt.iterFind(_339, _342)), (g15: Guard.Guard): rt.u32 => { + return Guard.id(g15); + }); + const _345: rt.Iter = rt.iterSlice(items); + _543 = false; + const captured24 = m; + const _348: (a0: Guard.Guard) => boolean = rt.closure((g16: Guard.Guard): boolean => { + return rt.u32Add(Guard.id(g16), 2) === Guard.id(captured24); + }, (): void => { + rt.drop(captured24); + }); + const atPos: rt.usize | undefined = rt.dropAfter(_348, () => rt.iterPosition(_345, _348)); + const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(any, f), (f: rt.Formatter) => rt.fmtOption(found, f, rt.u32Debug), (f: rt.Formatter) => rt.fmtOption(atPos, f, rt.usizeDebug)]; + Log.note(log, rt.fmtFormat(["found ", args18[0], " ", args18[1], " ", args18[2]])); + n = guard(27); + unwind = 283; + _542 = true; + const _368: rt.Iter = rt.iterSlice([1, 2, 3]); + _542 = false; + const captured25 = n; + const sum: rt.u32 = rt.iterSum(rt.iterMap(_368, rt.closure((_214: rt.u32): rt.u32 => { + return rt.u32Add(_214, Guard.id(captured25)); + }, (): void => { + rt.drop(captured25); + })), rt.u32Add, 0, rt.drop); + o = guard(28); + unwind = 281; + _541 = true; + const _376: rt.Iter = rt.iterSlice([1, 2]); + _541 = false; + const captured26 = o; + const _379: (a0: rt.u32) => void = rt.closure((_216: rt.u32): void => { + const part6 = rt.u32Add(_216, Guard.id(captured26)); + const args32: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(part6, f)]; + Log.note(log, rt.fmtFormat(["each ", args32[0]])); + }, (): void => { + rt.drop(captured26); + }); + rt.dropAfter(_379, () => rt.iterForEach(_376, _379)); + const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(sum, f)]; + Log.note(log, rt.fmtFormat(["sum ", args20[0]])); + _394 = guard(44); + unwind = 251; + _397 = guard(45); + unwind = 250; + const _400: Guard.Guard = guard(46); + unwind = 277; + _540 = true; + t = _394; + _539 = true; + u = _397; + _538 = true; + v6 = _400; + const _406: rt.Iter = rt.iterSlice([1, 2]); + _540 = false; + const captured27 = t; + const peeked: rt.usize = rt.ownedCount(rt.iterPeekable(rt.iterMap(_406, rt.closure((_217: rt.u32): rt.u32 => { + return rt.u32Add(_217, Guard.id(captured27)); + }, (): void => { + rt.drop(captured27); + }))), rt.drop); + const _413: rt.Iter = rt.iterSlice([1, 2, 3]); + _539 = false; + const captured28 = u; + const skipped: rt.usize = rt.ownedCount(rt.iterSkip(rt.iterMap(_413, rt.closure((_221: rt.u32): rt.u32 => { + return rt.u32Add(_221, Guard.id(captured28)); + }, (): void => { + rt.drop(captured28); + })), 1), rt.drop); + const _420: rt.Iter = rt.iterSlice([1, 2]); + _538 = false; + const captured29 = v6; + const last: rt.u32 | undefined = rt.ownedLast(rt.iterSkip(rt.iterMap(_420, rt.closure((_223: rt.u32): rt.u32 => { + return rt.u32Add(_223, Guard.id(captured29)); + }, (): void => { + rt.drop(captured29); + })), 1), rt.drop); + const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(peeked, f), (f: rt.Formatter) => rt.usizeDisplay(skipped, f), (f: rt.Formatter) => rt.fmtOption(last, f, rt.u32Debug)]; + Log.note(log, rt.fmtFormat(["counted ", args22[0], " ", args22[1], " ", args22[2]])); + r = guard(36); + unwind = 275; + _537 = true; + const _442: rt.Iter = rt.iterMap(rt.iterSlice([1, 2, 3]), (_224: rt.u32): Guard.Guard => { + return guard(rt.u32Add(36, _224)); + }); + _537 = false; + const captured30 = id; + const captured31 = check; + const captured32 = r; + const _448: (a0: Guard.Guard) => rt.u32 = rt.closure((g17: Guard.Guard): rt.u32 => { + if (Guard.id(g17) === rt.u32Add(captured30, 38)) { + captured31(7); + } + return rt.u32Add(rt.u32Rem(Guard.id(g17), 2), Guard.id(captured32)); + }, (): void => { + rt.drop(captured32); + }); + const part8 = map$Option_Guard_u32_iterated_closure16(rt.dropAfter(_448, () => rt.iterMaxByKey(_442, _448, undefined, rt.drop)), (g18: Guard.Guard): rt.u32 => { + let unwind7: number = 0; + try { + unwind7 = 4; + const _028: rt.u32 = Guard.id(g18); + unwind7 = 0; + rt.drop(g18); + return _028; + } catch (e8) { + if (unwind7 === 0) { + throw e8; + } + rt.drop(g18); + throw e8; + } + }); + const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part8, f, rt.u32Debug)]; + Log.note(log, rt.fmtFormat(["best ", args24[0]])); + map = rt.btreeNew(rt.cmp) as rt.BTreeMap; + unwind = 247; + const iter2: rt.Iter<[rt.u32, rt.u32]> = rt.iterSlice([[1, 29] as [rt.u32, rt.u32], [2, 30] as [rt.u32, rt.u32], [3, 31] as [rt.u32, rt.u32]]); + while (true) { + unwind = 246; + const _467: [rt.u32, rt.u32] | rt.Done = iter2.next(); + if (_467 === rt.DONE) { + break; + } + const k2: rt.u32 = _467[0]; + const _474: Guard.Guard = guard(_467[1]); + rt.drop(rt.btreeInsert(map, k2, _474, undefined, rt.drop)); + } + unwind = 247; + const p: Guard.Guard = guard(32); + const captured33 = check; + const captured34 = p; + const captured35 = id; + const _482: (a0: rt.u32, a1: Guard.Guard) => boolean = rt.closure((_226: rt.u32, _328: Guard.Guard): boolean => { + const k3: rt.u32 = _226; + if (k3 === 2) { + captured33(6); + } + return rt.u32Add(k3, Guard.id(captured34)) !== rt.u32Add(captured35, 34); + }, (): void => { + rt.drop(captured34); + }); + rt.dropAfter(_482, () => rt.btreeRetain(map, _482, undefined, rt.drop)); + queue = rt.dequeNew() as rt.VecDeque; + unwind = 245; + const _486: Guard.Guard = guard(33); + rt.dequePushBack(queue, _486); + const _491: Guard.Guard = guard(34); + rt.dequePushBack(queue, _491); + const captured36 = guard(35); + const _499: (a0: Guard.Guard) => boolean = rt.closure((g19: Guard.Guard): boolean => { + return rt.u32Add(Guard.id(g19), 2) !== Guard.id(captured36); + }, (): void => { + rt.drop(captured36); + }); + rt.dropAfter(_499, () => rt.dequeRetain(queue, _499, rt.drop)); + const _506: rt.usize = rt.btreeLen(map); + const _509: rt.usize = queue.n; + const args26: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(_506, f), (f: rt.Formatter) => rt.usizeDisplay(_509, f)]; + Log.note(log, rt.fmtFormat(["retained ", args26[0], " ", args26[1]])); + unwind = 247; + rt.dequeDrop(queue, rt.drop); + unwind = 275; + rt.btreeDrop(map, undefined, rt.drop); + unwind = 289; + _537 = false; + _538 = false; + _539 = false; + _540 = false; + _541 = false; + _542 = false; + _543 = false; + _544 = false; + _545 = false; + rt.dropAll(items); + _546 = false; + _547 = false; + _548 = false; + _549 = false; + _550 = false; + _551 = false; + _552 = false; + _553 = false; + _554 = false; + _555 = false; + _556 = false; + _557 = false; + _558 = false; + _559 = false; + _560 = false; + _561 = false; + _562 = false; + } catch (e2) { + b6: { + b7: { + b8: { + b9: { + b10: { + b11: { + b12: { + b13: { + b14: { + b15: { + b16: { + b17: { + b18: { + b19: { + b20: { + b21: { + b22: { + b23: { + b24: { + b25: { + b26: { + b27: { + b28: { + b29: { + if (unwind === 0) { + throw e2; + } + if (unwind === 245) { + rt.dequeDrop(queue, rt.drop); + break b26; + } + if (unwind === 246) { + break b26; + } + if (unwind === 247) { + break b26; + } + if (unwind === 250) { + rt.drop(_397); + break b27; + } + if (unwind === 251) { + break b27; + } + if (unwind === 254) { + rt.drop(_324); + break b28; + } + if (unwind === 255) { + break b28; + } + if (unwind === 256) { + break b20; + } + if (unwind === 257) { + rt.dropAll(v5); + break b19; + } + if (unwind === 259) { + rt.drop(_245); + break b16; + } + if (unwind === 260) { + break b16; + } + if (unwind === 261) { + break b11; + } + if (unwind === 263) { + rt.drop(_169); + break b10; + } + if (unwind === 264) { + rt.dropAll(v3); + break b9; + } + if (unwind === 267) { + rt.drop(_103); + break b29; + } + if (unwind === 268) { + break b29; + } + if (unwind === 269) { + rt.drop(g); + } else if (unwind !== 270) { + if (unwind === 271) { + rt.dropAll(v2); + break b8; + } + if (unwind === 272) { + rt.dropAll(v); + break b6; + } + if (unwind === 275) { + break b25; + } + if (unwind === 277) { + break b24; + } + if (unwind === 281) { + break b23; + } + if (unwind === 283) { + break b22; + } + if (unwind === 285) { + break b21; + } + if (unwind === 289) { + break b19; + } + if (unwind === 291) { + break b18; + } + if (unwind === 293) { + break b17; + } + if (unwind === 296) { + break b15; + } + if (unwind === 298) { + break b14; + } + if (unwind === 300) { + break b13; + } + if (unwind === 302) { + break b12; + } + if (unwind === 304) { + break b11; + } + if (unwind === 307) { + break b10; + } + if (unwind === 309) { + break b9; + } + if (unwind === 313) { + break b8; + } + if (unwind === 315) { + break b7; + } + break b6; + } + rt.drop(iter); + break b8; + } + rt.drop(_100); + break b8; + } + rt.drop(_321); + break b20; + } + rt.drop(_394); + break b23; + } + rt.btreeDrop(map, undefined, rt.drop); + } + if (_537) { + rt.drop(r); + } + } + if (_538) { + rt.drop(v6); + } + if (_539) { + rt.drop(u); + } + if (_540) { + rt.drop(t); + } + } + if (_541) { + rt.drop(o); + } + } + if (_542) { + rt.drop(n); + } + } + if (_543) { + rt.drop(m); + } + if (_544) { + rt.drop(l); + } + if (_545) { + rt.drop(k); + } + } + rt.dropAll(items); + } + if (_546) { + rt.drop(chain); + } + } + if (_547) { + rt.drop(s); + } + } + if (_548) { + rt.drop(j); + } + if (_549) { + rt.drop(i); + } + } + } + if (_550) { + rt.drop(h); + } + } + if (_551) { + rt.drop(ended); + } + } + if (_552) { + rt.drop(w); + } + } + if (_553) { + rt.drop(flat); + } + } + if (_554) { + rt.drop(g2); + } + if (_555) { + rt.drop(f); + } + } + if (_556) { + rt.drop(chained); + } + } + if (_557) { + rt.drop(e); + } + if (_558) { + rt.drop(d); + } + if (_559) { + rt.drop(c); + } + } + if (_560) { + rt.drop(b); + } + } + if (_561) { + rt.drop(mapped); + } + } + if (_562) { + rt.drop(a); + } + throw e2; + } +} + /** * What drops of a closure's captures when one's `Drop` panics: the rest still drop, in * order, and the panic goes on. diff --git a/ts/fixtures/task/src/drops.rs b/ts/fixtures/task/src/drops.rs index 2c7534315..8c4a1c572 100644 --- a/ts/fixtures/task/src/drops.rs +++ b/ts/fixtures/task/src/drops.rs @@ -64,17 +64,18 @@ pub struct Named<'a>(Text<'a>); /// order, the second after the first panics. pub struct Entries(Vec<(K, V)>); -/// Run scenario `arg % 22`, panicking at the point `arg / 22 % 8` names, if any: what +/// Run scenario `arg % 23`, panicking at the point `arg / 23 % 11` names, if any: what /// every value std holds drops, where Rust drops it, and in Rust's order. pub fn run(log: &Log, id: u32, arg: u8) { - let at = arg / 22 % 8; + let at = arg / 23 % 11; let guard = |n: u32| Guard::new(id + n, log.clone()); let check = |point: u8| { if point == at { panic!("d{id} at {point}"); } }; - match arg % 22 { + match arg % 23 { + 22 => closures::iterated(log, id, at), 19 => closures::scoped(log, id, at), 20 => closures::discarded(log, id, at), 21 => closures::blasted(log, id, at), diff --git a/ts/fixtures/task/src/drops/closures.rs b/ts/fixtures/task/src/drops/closures.rs index e773f30ef..0479cbe0e 100644 --- a/ts/fixtures/task/src/drops/closures.rs +++ b/ts/fixtures/task/src/drops/closures.rs @@ -1,5 +1,8 @@ //! What a closure drops of the values it owns: where it goes out of scope, where std -//! discards it uncalled, and where a call consumes it, a panic included. +//! discards it uncalled, where a call consumes it, and where std's iterators and +//! collections are done with it, a panic included. + +use std::collections::{BTreeMap, VecDeque}; use super::Bomb; use crate::log::Log; @@ -178,6 +181,148 @@ pub(super) fn discarded(log: &Log, id: u32, at: u8) { check(7); } +/// What std's iterators and collections drop of a closure that owns a guard: an adaptor +/// after the iterator it wraps, and a call that keeps nothing of it as it returns, with +/// what each drops of its own before it, panicking at point `at`, if any, some inside a +/// closure. +pub(super) fn iterated(log: &Log, id: u32, at: u8) { + let guard = |n: u32| Guard::new(id + n, log.clone()); + let check = |point: u8| { + if point == at { + panic!("d{id} at {point}"); + } + }; + // Adaptors, read in part and dropped, or ended by a `for`. + let a = guard(1); + let mut mapped = list![guard(2), guard(3), guard(4)].into_iter().map(move |g| { + if g.id() == id + 3 { + check(1); + } + g.id() + a.id() + }); + log.note(format!("map {:?} {:?}", mapped.next(), mapped.next())); + drop(mapped); + let b = guard(5); + for g in list![guard(6), guard(7), guard(8)] + .into_iter() + .filter(move |g| g.id() != b.id() + 1) + { + log.note(format!("filter {}", g.id())); + if g.id() == id + 7 { + break; + } + } + let (c, d, e) = (guard(9), guard(10), guard(11)); + let mut chained = list![guard(12), guard(13), guard(14), guard(15)] + .into_iter() + .skip_while(move |g| g.id() < c.id() + 4) + .take_while(move |g| g.id() < d.id() + 5) + .inspect(move |g| { + if g.id() == id + 14 { + check(2); + } + log.note(format!("inspect {} {}", g.id(), e.id())); + }); + log.note(format!("chained {:?}", chained.next().map(|g| g.id()))); + log.note(format!("chained {:?}", chained.next().map(|g| g.id()))); + drop(chained); + let (f, g) = (guard(16), guard(17)); + let mut flat = list![1u32, 2, 3] + .into_iter() + .filter_map(move |n| (n != 2).then_some(n + f.id())) + .flat_map(move |n| list![n, n + g.id()]); + log.note(format!("flat {:?}", flat.next())); + check(3); + drop(flat); + // Ended, it keeps its closure, since the source it maps is fused. + let w = guard(47); + let mut ended = [1u32].iter().flat_map(move |&n| [n, w.id()]); + while ended.next().is_some() {} + log.note(format!("flat_map ended")); + drop(ended); + let h = guard(18); + let whiles: Vec = [1u32, 2, 3] + .iter() + .map_while(move |&n| (n < 3).then_some(n + h.id())) + .collect(); + log.note(format!("map_while {whiles:?}")); + // Lazy sources, which hold their closure. + let (i, j) = (guard(19), guard(20)); + let made = std::iter::from_fn(move || { + check(4); + Some(i.id()) + }) + .take(2) + .count(); + let walked: u32 = std::iter::successors(Some(1u32), move |&n| (n < 3).then_some(n + 1 + j.id() - j.id())).sum(); + // One of guards, which holds the next, made by a closure that owns one and may panic, + // and drops the one it holds before its closure. + let s = guard(43); + let mut chain = std::iter::successors(Some(guard(40)), move |g| { + if g.id() == id + 41 { + check(8); + } + (g.id() + 1 < s.id()).then(|| Guard::new(g.id() + 1, log.clone())) + }); + log.note(format!("lazy {made} {walked} {:?}", chain.next().map(|g| g.id()))); + log.note(format!("successor {:?}", chain.next().map(|g| g.id()))); + drop(chain); + // Consumers that borrow the iterator, which drop the closure as they return. + let items = list![guard(21), guard(22), guard(23)]; + let (k, l, m) = (guard(24), guard(25), guard(26)); + let any = items.iter().any(move |g| { + if g.id() == id + 22 { + check(5); + } + g.id() == k.id() + }); + let found = items.iter().find(move |g| g.id() == l.id() - 3).map(|g| g.id()); + let at_pos = items.iter().position(move |g| g.id() + 2 == m.id()); + log.note(format!("found {any} {found:?} {at_pos:?}")); + // One that drops nothing else by value, folded. + let n = guard(27); + let sum: u32 = [1u32, 2, 3].iter().map(move |&x| x + n.id()).sum(); + let o = guard(28); + [1u32, 2] + .iter() + .for_each(move |&x| log.note(format!("each {}", x + o.id()))); + log.note(format!("sum {sum}")); + // Consumers that count or end an adaptor through what it wraps, which drop its closure + // once. + let (t, u, v) = (guard(44), guard(45), guard(46)); + let peeked = [1u32, 2].iter().map(move |&x| x + t.id()).peekable().count(); + let skipped = [1u32, 2, 3].iter().map(move |&x| x + u.id()).skip(1).count(); + let last = [1u32, 2].iter().map(move |&x| x + v.id()).skip(1).last(); + log.note(format!("counted {peeked} {skipped} {last:?}")); + // Items made as it goes, which it drops but for the best, before its key's closure. + let r = guard(36); + let best = [1u32, 2, 3].iter().map(|&n| guard(36 + n)).max_by_key(move |g| { + if g.id() == id + 38 { + check(7); + } + g.id() % 2 + r.id() + }); + log.note(format!("best {:?}", best.map(|g| g.id()))); + // What `retain` drops of its own before the closure. + let mut map = BTreeMap::new(); + for (k, n) in [(1u32, 29), (2, 30), (3, 31)] { + map.insert(k, guard(n)); + } + let p = guard(32); + map.retain(move |&k, _| { + if k == 2 { + check(6); + } + k + p.id() != id + 34 + }); + let mut queue = VecDeque::new(); + queue.push_back(guard(33)); + queue.push_back(guard(34)); + let q = guard(35); + queue.retain(move |g| g.id() + 2 != q.id()); + log.note(format!("retained {} {}", map.len(), queue.len())); +} + /// What drops of a closure's captures when one's `Drop` panics: the rest still drop, in /// order, and the panic goes on. pub(super) fn blasted(log: &Log, id: u32, at: u8) { diff --git a/ts/runtime/rt/iter.ts b/ts/runtime/rt/iter.ts index 543bc034d..99261cc1a 100644 --- a/ts/runtime/rt/iter.ts +++ b/ts/runtime/rt/iter.ts @@ -101,6 +101,29 @@ abstract class Adaptor extends Iter implements Disposable { } } +/** + * An adaptor of `inner` that calls `f`, which drops after it, as std's fields do, once: + * a consumer may drop `inner` before dropping the adaptor that holds it. + */ +abstract class Calling extends Adaptor { + protected readonly f: F; + private dropped = false; + + constructor(inner: Iter, f: F) { + super(inner); + this.f = f; + } + + override [Symbol.dispose](): void { + if (this.dropped) return; + this.dropped = true; + both( + () => dispose(this.inner), + () => dispose(this.f), + ); + } +} + /** Run `a`, then `b` even if `a` panics, as glue drops each field after one panics. */ function both(a: () => void, b: () => void): void { try { @@ -148,22 +171,17 @@ export function iterEmpty(): Iter { return new OptionIter(undefined, false); } -/** `iter::from_fn`, whose closure returns an `Option`. */ +/** `iter::from_fn`, whose closure returns an `Option`, and drops with it. */ export function iterFromFn(f: () => T | undefined): Iter { - return new FromNext(f, (f) => iterFromOption(f())); + return new FromNext(f, (f) => iterFromOption(f()), dispose); } -/** `iter::successors`: `first`, then `succ` of each item, called as that item is yielded. */ -export function iterSuccessors(first: T | undefined, succ: (item: T) => T | undefined): Iter { - let next = first; - return iterFromFn(() => { - const item = next; - if (item === undefined) return undefined; - // Taken before `succ` runs, so a panic in it leaves the iterator done, as std's. - next = undefined; - next = succ(item); - return item; - }); +/** + * `iter::successors`: `first`, then `succ` of each item, called as that item is yielded. + * The item it holds next drops by `drop`, and then `succ`, as std's fields drop. + */ +export function iterSuccessors(first: T | undefined, succ: (item: T) => T | undefined, drop?: Drop): Iter { + return new SuccessorsIter(first, succ, drop); } /** An `impl Iterator` of the translated crate, which `next` calls the `next` of, and `drop` drops. */ @@ -383,7 +401,7 @@ function rfindItem(it: Iter, f: (item: T) => boolean, drop?: Drop): T | } /** `f(item)`, dropping `item` by `drop` if it panics. */ -function test(f: (item: T) => boolean, item: T, drop: Drop): boolean { +function test(f: (item: T) => R, item: T, drop: Drop): R { try { return f(item); } catch (e) { @@ -996,6 +1014,44 @@ class FromNext extends Iter implements Disposable { } } +/** `Successors`, holding the item it yields next, which drops once, as `Calling` does. */ +class SuccessorsIter extends Iter implements Disposable { + private item: T | undefined; + private readonly succ: (item: T) => T | undefined; + private readonly drop: Drop | undefined; + private dropped = false; + + constructor(first: T | undefined, succ: (item: T) => T | undefined, drop?: Drop) { + super(); + this.item = first; + this.succ = succ; + this.drop = drop; + } + + next(): T | Done { + const item = this.item; + if (item === undefined) return DONE; + // Taken before `succ` runs, so a panic in it leaves the iterator done, as std's. + this.item = undefined; + if (this.drop === undefined) this.item = this.succ(item); + else this.item = test(this.succ, item, this.drop); + return item; + } + + [Symbol.dispose](): void { + if (this.dropped) return; + this.dropped = true; + const item = this.item; + this.item = undefined; + both( + () => { + if (item !== undefined) this.drop?.(item); + }, + () => dispose(this.succ), + ); + } +} + /** * An iterator borrowed by `&mut`, which forwards only what std's `impl Iterator for &mut * I` does, and which dropping drops nothing. @@ -1037,12 +1093,10 @@ class Borrowed extends Iter { } } -class MapIter extends Adaptor { - readonly f: (item: T) => U; +class MapIter extends Calling U> { constructor(inner: Iter, f: (item: T) => U) { - super(inner); - this.f = f; + super(inner, f); } next(): U | Done { @@ -1076,13 +1130,11 @@ class CopiedIter extends MapIter { } } -class FilterIter extends Adaptor { - private readonly f: (item: T) => boolean; +class FilterIter extends Calling boolean> { private readonly drop: Drop | undefined; constructor(inner: Iter, f: (item: T) => boolean, drop?: Drop) { - super(inner); - this.f = f; + super(inner, f); this.drop = drop; } @@ -1095,12 +1147,10 @@ class FilterIter extends Adaptor { } } -class FilterMapIter extends Adaptor { - private readonly f: (item: T) => U | undefined; +class FilterMapIter extends Calling U | undefined> { constructor(inner: Iter, f: (item: T) => U | undefined) { - super(inner); - this.f = f; + super(inner, f); } next(): U | Done { @@ -1527,14 +1577,12 @@ class TakeIter extends Adaptor { } } -class SkipWhileIter extends Adaptor { - private readonly f: (item: T) => boolean; +class SkipWhileIter extends Calling boolean> { private readonly drop: Drop | undefined; private flag = false; constructor(inner: Iter, f: (item: T) => boolean, drop?: Drop) { - super(inner); - this.f = f; + super(inner, f); this.drop = drop; } @@ -1553,14 +1601,12 @@ class SkipWhileIter extends Adaptor { } } -class TakeWhileIter extends Adaptor { - private readonly f: (item: T) => boolean; +class TakeWhileIter extends Calling boolean> { private readonly drop: Drop | undefined; private flag = false; constructor(inner: Iter, f: (item: T) => boolean, drop?: Drop) { - super(inner); - this.f = f; + super(inner, f); this.drop = drop; } @@ -1576,12 +1622,10 @@ class TakeWhileIter extends Adaptor { } /** `MapWhile`, which reads on after `f` returns `None` if called again, as std's does. */ -class MapWhileIter extends Adaptor { - private readonly f: (item: T) => U | undefined; +class MapWhileIter extends Calling U | undefined> { constructor(inner: Iter, f: (item: T) => U | undefined) { - super(inner); - this.f = f; + super(inner, f); } next(): U | Done { @@ -1668,13 +1712,11 @@ class StepByIter extends Adaptor { } } -class InspectIter extends Adaptor { - private readonly f: (item: T) => void; +class InspectIter extends Calling void> { private readonly drop: Drop | undefined; constructor(inner: Iter, f: (item: T) => void, drop?: Drop) { - super(inner); - this.f = f; + super(inner, f); this.drop = drop; } diff --git a/ts/runtime/rt/task.ts b/ts/runtime/rt/task.ts index f87b0df2b..14d520737 100644 --- a/ts/runtime/rt/task.ts +++ b/ts/runtime/rt/task.ts @@ -52,6 +52,18 @@ export function callOnce(f: (...args: A) => R, ...args: } } +/** + * `call()`, then `f` drops, a panic included: a std function that calls `f` and keeps + * nothing of it drops it as it returns. + */ +export function dropAfter(f: unknown, call: () => R): R { + try { + return call(); + } finally { + drop(f); + } +} + /** A closure that `Fn` or `FnMut` call, as one `FnOnce` calls: a call drops it after. */ export function once(f: (...args: A) => R): ((...args: A) => R) & Disposable { return closure((...args: A) => callOnce(f, ...args), () => drop(f)); diff --git a/ts/src/lower/drop.rs b/ts/src/lower/drop.rs index f5a335a50..13672c5c6 100644 --- a/ts/src/lower/drop.rs +++ b/ts/src/lower/drop.rs @@ -78,7 +78,7 @@ impl<'a, 'tcx> Translator<'a, 'tcx> { /// Whether `ty` is one of std's iterators, or a type they are built of, which an `rt.Iter` /// stands for: it drops what it owns, of its fields or, with a `Drop` impl, its items. - fn std_iter(&self, ty: Ty<'tcx>) -> bool { + pub(super) fn std_iter(&self, ty: Ty<'tcx>) -> bool { let ty::Adt(adt, _) = ty.kind() else { return false; }; @@ -118,11 +118,8 @@ impl<'a, 'tcx> Translator<'a, 'tcx> { Some(Std::Arc | Std::Mutex | Std::Option | Std::Box | Std::Pin) => { self.disposable(args.type_at(0), span) } - // An `rt.Iter` drops what it was given to, but not a closure's captures. - None | Some(Std::Peekable) if self.std_iter(ty) => !ty - .walk() - .filter_map(|arg| arg.as_type()) - .any(|t| matches!(t.kind(), ty::Closure(..)) && self.drops(t)), + // An `rt.Iter` drops what it was given to. + None | Some(Std::Peekable) if self.std_iter(ty) => self.closures_held(ty), Some(_) => false, // A generic `Drop` impl has an instance per type, which one class's glue can't call. None if adt.is_struct() && !self.generic_dtor(*adt) => { @@ -141,6 +138,19 @@ impl<'a, 'tcx> Translator<'a, 'tcx> { } } + /// Whether each closure that drops in `ty`, one of std's iterators, is one an adaptor's + /// `rt.Iter` drops, as `iter::holds_closure` says. + fn closures_held(&mut self, ty: Ty<'tcx>) -> bool { + let ty::Adt(adt, args) = ty.kind() else { + return true; + }; + let holds = super::iter::holds_closure(self.tcx, adt.did()); + args.types().all(|t| match t.kind() { + ty::Closure(..) => holds || !self.drops(t), + _ => self.closures_held(t), + }) + } + /// Whether dropping a `ty` may run a `Drop` impl of the crate's, which may panic: std's /// own drops never do, and a waker's is its host's. `seen` holds the types it is /// deciding, one of which reached again panics through another path if at all. diff --git a/ts/src/lower/iter.rs b/ts/src/lower/iter.rs index 697543a88..351972bb9 100644 --- a/ts/src/lower/iter.rs +++ b/ts/src/lower/iter.rs @@ -270,16 +270,10 @@ pub fn call<'tcx>( // A closure that owns a value that drops is refused as any std mapping refuses one // it calls but never drops. ["iter", "sources", "from_fn", "from_fn"] => return Some(Expr::rt("iterFromFn", args)), + // What drops the item it holds next. ["iter", "sources", "successors", "successors"] => { - // `rt.iterSuccessors` would leave the item it holds next undropped. - let item = targ(0)?; - if b.t.drops(item) { - b.t.err( - span, - format!("an iterator that owns `{item}`, which drops, which is not supported yet"), - ); - } - return Some(Expr::rt("iterSuccessors", args)); + let dropper = b.t.dropper(targ(0)?, span); + return Some(Expr::rt("iterSuccessors", tail(args, vec![dropper]))); } _ => {} } @@ -380,7 +374,7 @@ pub fn call<'tcx>( method(&camel, tail(rest, vec![dropper])) } "fuse" => { - let fused = fused(b, self_ty); + let fused = fused(b, self_ty, None); method(name, tail(rest, vec![fused])) } "count" => { @@ -486,14 +480,14 @@ pub fn call<'tcx>( let inner = iter_of(b.t, targ(1)?)?; flattens(b, inner, span); let into = into_fn(b, targ(1)?, span)?.unwrap_or_else(Expr::undefined); - let fused = fused(b, self_ty); + let fused = fused(b, self_ty, Some(targ(2)?)); method("flatMap", tail(rest, vec![into, fused])) } "flatten" => { let inner = iter_of(b.t, item)?; flattens(b, inner, span); let into = into_fn(b, item, span)?.unwrap_or_else(Expr::undefined); - let fused = fused(b, self_ty); + let fused = fused(b, self_ty, None); method("flatten", tail(Vec::new(), vec![into, fused])) } "copied" | "cloned" => { @@ -544,10 +538,11 @@ fn undefined(e: &Expr) -> bool { matches!(e, Expr::Lit(l) if l == "undefined") } -/// Whether an iterator of type `ty` that drops is a `FusedIterator`, which std's `fuse` and -/// `flatten` keep once it ends rather than drop: `true` or `false`. -fn fused<'tcx>(b: &mut Body<'_, '_, 'tcx>, ty: Ty<'tcx>) -> Expr { - Expr::lit(match b.t.drops(ty) && implements(b.t, ty, "FusedIterator") { +/// Whether an iterator of type `ty`, with `held` beside it, drops and is a `FusedIterator`, +/// which std's `fuse` and `flatten` keep once it ends rather than drop: `true` or `false`. +fn fused<'tcx>(b: &mut Body<'_, '_, 'tcx>, ty: Ty<'tcx>, held: Option>) -> Expr { + let drops = b.t.drops(ty) || held.is_some_and(|held| b.t.drops(held)); + Expr::lit(match drops && implements(b.t, ty, "FusedIterator") { true => "true", false => "false", }) @@ -561,6 +556,24 @@ fn std_iter_path(tcx: ty::TyCtxt<'_>, ty: Ty<'_>) -> Option> { Some(library::std_path(tcx, adt.did())).filter(|p| !p.is_empty()) } +/// Whether std's iterator `did` holds a closure that its `rt.Iter` drops after the iterator +/// it wraps, as std's fields order them. +pub(super) fn holds_closure(tcx: ty::TyCtxt<'_>, did: DefId) -> bool { + let path = library::std_path(tcx, did); + let path: Vec<&str> = path.iter().map(String::as_str).collect(); + matches!( + path.as_slice(), + [ + "iter", + "adapters", + _, + "Map" | "Filter" | "FilterMap" | "SkipWhile" | "TakeWhile" | "MapWhile" | "Inspect" + ] | ["iter", "adapters", "flatten", "FlatMap"] + | ["iter", "sources", "from_fn", "FromFn"] + | ["iter", "sources", "successors", "Successors"] + ) +} + /// Refuse a `flatten` or `flat_map` of `inner` iterators that drop and may hold what drops /// once they end: std's `try_fold` drops each such one only as it reads the next, where /// `next` drops it as it ends. What std's collections' and `Option`'s `into_iter` make @@ -593,9 +606,21 @@ fn flattens<'tcx>(b: &mut Body<'_, '_, 'tcx>, inner: Ty<'tcx>, span: Span) { /// Refuse std's `name` folding `ty` through a `flatten` or `flat_map` whose source and /// iterators both drop: a panic in `fold` drops the iterator it took before the source, -/// as a panic in `next` does not. +/// as a panic in `next` does not. Refuse it too where `ty` holds a closure that drops and +/// anything else that does: `fold` drops an adaptor's closure as its own ends, before the +/// rest of it, where dropping the adaptor drops it after. pub(super) fn folds<'tcx>(b: &mut Body<'_, '_, 'tcx>, ty: Ty<'tcx>, name: &str, span: Span) { let tcx = b.t.tcx; + let mut closures = 0; + if (held(b.t, ty, &mut closures) && closures > 0) || closures > 1 { + b.t.err( + span, + format!( + "`{name}` of `{ty}`, which folds a closure that drops beside what else drops, which is not supported yet" + ), + ); + return; + } let flattens: Vec> = ty .walk() .filter_map(|arg| arg.as_type()) @@ -632,6 +657,34 @@ pub(super) fn folds<'tcx>(b: &mut Body<'_, '_, 'tcx>, ty: Ty<'tcx>, name: &str, } } +/// Whether `ty`, which an iterator holds, drops other than through a closure, counting +/// each closure that drops in `closures`: through what an adaptor holds, which is all it +/// drops, but for what owns items, which drops them itself. +fn held<'tcx>(t: &mut Translator<'_, 'tcx>, ty: Ty<'tcx>, closures: &mut usize) -> bool { + let tcx = t.tcx; + match ty.kind() { + ty::Closure(..) => { + *closures += usize::from(t.drops(ty)); + false + } + ty::Tuple(tys) => tys.iter().fold(false, |any, ty| held(t, ty, closures) | any), + ty::Adt(adt, args) if Std::of(tcx, adt.did()) == Some(Std::Option) => held(t, args.type_at(0), closures), + ty::Adt(adt, args) if t.std_iter(ty) && !adt.has_dtor(tcx) => { + let env = t.typing_env_pub(); + let mut drops = false; + for field in adt.all_fields() { + let field = ty::EarlyBinder::bind(tcx, tcx.type_of(field.did).instantiate_identity().skip_norm_wip()); + let ty = tcx + .try_instantiate_and_normalize_erasing_regions(args, env, field) + .unwrap_or_else(|_| field.instantiate(tcx, args).skip_norm_wip()); + drops |= held(t, ty, closures); + } + drops + } + _ => t.drops(ty), + } +} + /// Whether std's `Zip` of `a` and `b` reads both by index, never past the shorter: when /// both are `TrustedRandomAccess`. Refuse one that `fold` reads that way but `next` does /// not, where the first calls a closure that would see the difference. diff --git a/ts/src/lower/library.rs b/ts/src/lower/library.rs index 15896e753..63dfb439b 100644 --- a/ts/src/lower/library.rs +++ b/ts/src/lower/library.rs @@ -536,22 +536,36 @@ fn sentinel_option<'tcx>(t: &Translator<'_, 'tcx>, call: &Call<'tcx>) -> Option< .find(|&inner| t.erases_to(inner).undefined) } -/// The first closure `call` calls that owns a value that drops, of those its mapping does -/// not drop where std would: not in `discarded`, the types it may drop by their index among -/// the call's type arguments. A closure that `Fn` or `FnMut` call, given to one that calls -/// it through `FnOnce`, becomes `rt.once` of it, which drops it after the call, as rustc's -/// shim does. +/// What a std function does with the closures it calls that own a value that drops. +#[derive(Default)] +struct Closures<'tcx> { + /// The first it would neither drop where std's does nor keep: refused. + leaked: Option>, + /// Those it drops as it returns or unwinds, having kept nothing of them, in the order + /// their parameters are declared. + spent: Vec, +} + +/// The closures `call` calls that own a value that drops, by what its mapping does with +/// each: kept by the iterator it returns, if `iter::holds_closure`; dropped as it returns, if +/// `Fn` or `FnMut` call it and nothing else it takes by value drops, as then nothing it +/// drops is ordered against it; dropped where `discarded` says, by the type's index among +/// the call's type arguments; or else leaked. A closure that `Fn` or `FnMut` call, given to +/// one that calls it through `FnOnce`, becomes `rt.once` of it, which drops it after the +/// call, as rustc's shim does. fn called_closures<'tcx>( b: &mut Body<'_, '_, 'tcx>, call: &Call<'tcx>, discarded: Option<&[usize]>, args: &mut [Expr], -) -> Option> { +) -> Closures<'tcx> { let tcx = b.t.tcx; + let mut closures = Closures::default(); let sig = tcx.fn_sig(call.def_id).instantiate_identity().skip_norm_wip(); - let inputs = tcx.instantiate_bound_regions_with_erased(sig).inputs().to_vec(); - let bounds = tcx.param_env(call.def_id).caller_bounds(); - for (i, input) in inputs.into_iter().enumerate() { + let sig = tcx.instantiate_bound_regions_with_erased(sig); + let inputs = sig.inputs().to_vec(); + let output = sig.output(); + for (i, &input) in inputs.iter().enumerate() { let ty::Param(param) = *input.kind() else { continue; }; @@ -559,29 +573,36 @@ fn called_closures<'tcx>( let ty::Closure(_, closure) = ty.kind() else { continue; }; - // The trait it is called by: `Fn`, then `FnMut`, whichever it is bound by, or else `FnOnce`. - let Some(bound) = bounds - .clone() - .filter_map(|p| p.as_trait_clause()) - .filter(|t| t.self_ty().skip_binder() == input) - .filter_map(|t| tcx.fn_trait_kind_from_def_id(t.def_id())) - .min_by_key(|kind| match kind { - ty::ClosureKind::Fn => 0, - ty::ClosureKind::FnMut => 1, - ty::ClosureKind::FnOnce => 2, - }) - else { + let Some(bound) = called_by(tcx, call.def_id, input) else { continue; }; if !b.t.drops(ty) { continue; } + let mentions = |t: Ty<'tcx>| t.walk().any(|a| a.as_type() == Some(input)); + if mentions(output) { + let held = matches!(output.kind(), ty::Adt(adt, args) + if super::iter::holds_closure(tcx, adt.did()) && args.types().any(|a| a == input)); + if !held { + closures.leaked = closures.leaked.or(Some(ty)); + } + continue; + } + let kept = inputs.iter().enumerate().any(|(j, &t)| j != i && mentions(t)); + if bound != ty::ClosureKind::FnOnce && !kept && i < args.len() { + match dropping_operand(b, call) { + None => closures.spent.push(args[i].clone()), + Some(_) => closures.leaked = closures.leaked.or(Some(ty)), + } + continue; + } let index = call.args[..param.index as usize] .iter() .filter(|a| a.as_type().is_some()) .count(); if !discarded.is_some_and(|d| d.contains(&index)) { - return Some(ty); + closures.leaked = closures.leaked.or(Some(ty)); + continue; } if bound == ty::ClosureKind::FnOnce && closure.as_closure().kind() != ty::ClosureKind::FnOnce && i < args.len() { @@ -589,12 +610,30 @@ fn called_closures<'tcx>( args[i] = Expr::rt("once", vec![f]); } } - None + closures +} + +/// The trait `def_id` calls its parameter of type `input` by: `Fn`, then `FnMut`, +/// whichever it is bound by, or else `FnOnce`, or `None` if no function trait bounds it. +fn called_by<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, input: Ty<'tcx>) -> Option { + tcx.param_env(def_id) + .caller_bounds() + .filter_map(|p| p.as_trait_clause()) + .filter(|t| t.self_ty().skip_binder() == input) + .filter_map(|t| tcx.fn_trait_kind_from_def_id(t.def_id())) + .min_by_key(|kind| match kind { + ty::ClosureKind::Fn => 0, + ty::ClosureKind::FnMut => 1, + ty::ClosureKind::FnOnce => 2, + }) } -/// The first type `call` takes by value that drops. +/// The first type `call` takes by value that drops, but for a closure a function trait +/// bounds, which `called_closures` decides. fn dropping_operand<'tcx>(b: &mut Body<'_, '_, 'tcx>, call: &Call<'tcx>) -> Option> { let tcx = b.t.tcx; + let generic = tcx.fn_sig(call.def_id).instantiate_identity().skip_norm_wip(); + let generic = tcx.instantiate_bound_regions_with_erased(generic).inputs().to_vec(); let sig = tcx.fn_sig(call.def_id).instantiate(tcx, call.args).skip_norm_wip(); let env = b.t.typing_env_pub(); // A census's call over type parameters may leave a projection unnormalized. @@ -607,7 +646,14 @@ fn dropping_operand<'tcx>(b: &mut Body<'_, '_, 'tcx>, call: &Call<'tcx>) -> Opti .unwrap_or(ty) }) .collect(); - inputs.into_iter().find(|&ty| b.t.drops(ty)) + let called = |i: usize, ty: Ty<'tcx>| { + matches!(ty.kind(), ty::Closure(..)) && called_by(tcx, call.def_id, generic[i]).is_some() + }; + inputs + .into_iter() + .enumerate() + .find(|&(i, ty)| !called(i, ty) && b.t.drops(ty)) + .map(|(_, ty)| ty) } /// `owner::name` for a standard library function. @@ -661,9 +707,9 @@ pub fn call<'tcx>(b: &mut Body<'_, '_, 'tcx>, call: &Call<'tcx>, args: Vec } let discarded = discards(&owner, &name); let mut args = args; - let leaked = called_closures(b, call, discarded, &mut args); - let e = mapping(b, call, owner.clone(), name.clone(), discarded, args, out)?; - if let Some(ty) = leaked { + let closures = called_closures(b, call, discarded, &mut args); + let mut e = mapping(b, call, owner.clone(), name.clone(), discarded, args, out)?; + if let Some(ty) = closures.leaked { return Some(b.err( call.span, format!( @@ -671,6 +717,10 @@ pub fn call<'tcx>(b: &mut Body<'_, '_, 'tcx>, call: &Call<'tcx>, args: Vec ), )); } + // The last parameter drops first, as a function's do. + for f in closures.spent.into_iter().rev() { + e = Expr::rt("dropAfter", vec![f, Expr::Lambda(Vec::new(), Box::new(e))]); + } Some(e) } diff --git a/ts/tests/task.ts b/ts/tests/task.ts index f9d314f30..d8c6a2e62 100644 --- a/ts/tests/task.ts +++ b/ts/tests/task.ts @@ -281,5 +281,5 @@ export const cases: Uint8Array[] = [ [0, 0, 12, 0, 6, 0, 3, 5, 6, 0], [0, 0, 12, 0, 12, 1, 6, 0, 9, 1, 9, 0], // Each scenario of values std holds that drop, panicking at each point or none. - ...Array.from({ length: 176 }, (_, arg) => [11, arg]), + ...Array.from({ length: 253 }, (_, arg) => [11, arg]), ].map((script) => Uint8Array.from(script));