From 89c550976a8d8edff2f233df91d31c0c5894d7bb Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Tue, 27 Oct 2026 17:13:57 -0700 Subject: [PATCH 1/7] chore(quest): claim quest/m2/ts-drop.md Quest-Claim: caa8b83e2a77590c From cd8fed0f567bbfc470f3f740743b862ccdeaeefb Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Tue, 27 Oct 2026 19:09:37 -0700 Subject: [PATCH 2/7] feat(ts): drop the closures std's iterators and collections are done with A closure that owns a value that drops, given to a std iterator adaptor (`map`, `filter`, `filter_map`, `skip_while`, `take_while`, `map_while`, `inspect`, `flat_map`, `from_fn`, `successors`), drops after the iterator it wraps, as std's fields order them. Given to a function that calls it by `Fn` or `FnMut`, keeps nothing of it, and takes nothing else that drops by value (`any`, `find`, `position`, a collection's `retain`), it drops as the call returns or unwinds (`rt.dropAfter`). A consumer that std folds still refuses an iterator holding such a closure beside anything else that drops, since `fold` drops the closure before the source. Co-Authored-By: Claude Opus 5.5 --- quest/m2/ts-drop.md | 18 +- ts/README.md | 5 +- ts/fixtures/reject/census.md | 432 ++++++------ ts/fixtures/reject/expected.txt | 140 ++-- ts/fixtures/reject/src/lib.rs | 31 +- ts/fixtures/task/expected/core/option.ts | 7 + ts/fixtures/task/expected/drops.ts | 202 +++--- ts/fixtures/task/expected/drops/closures.ts | 707 +++++++++++++++++++- ts/fixtures/task/src/drops.rs | 7 +- ts/fixtures/task/src/drops/closures.rs | 115 +++- ts/runtime/rt/iter.ts | 75 ++- ts/runtime/rt/task.ts | 12 + ts/src/lower/drop.rs | 22 +- ts/src/lower/iter.rs | 60 +- ts/src/lower/library.rs | 70 +- ts/tests/task.ts | 2 +- 16 files changed, 1420 insertions(+), 485 deletions(-) diff --git a/quest/m2/ts-drop.md b/quest/m2/ts-drop.md index bfcccf4d6..e13ec9d35 100644 --- a/quest/m2/ts-drop.md +++ b/quest/m2/ts-drop.md @@ -19,15 +19,21 @@ blocks of `-C panic=unwind` MIR, which a function runs from a `catch`. A value w 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. +after a call through `FnOnce` (`rt.callOnce`, and `rt.once` for std's). Given to std, an +iterator adaptor holds it and drops it after its iterator, as std's fields do +(`iter::holds_closure`), and a function that calls it by `Fn` or `FnMut`, keeps nothing +of it, and takes nothing else that drops by value drops it as it returns or unwinds +(`rt.dropAfter`). 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); +a consumer that std folds, 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), and a closure that owns a value that +drops given to a function that takes another value that drops by value, such as +`for_each` of items that drop, or that keeps it outside an adaptor, or that calls it +through `FnOnce` other than where `discards` in `library.rs` says (`or_insert_with`); `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 diff --git a/ts/README.md b/ts/README.md index 03c6410ae..315404f31 100644 --- a/ts/README.md +++ b/ts/README.md @@ -422,8 +422,9 @@ to hand-written TS ([bindings](#bindings)). ## Not yet These fail translation: floats, 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](/quest/m2/ts-drop.md)), a `Cow` of other than `str`, a collection holding a type that can be `undefined`, as `()` and `Option` can, a collection's `capacity`, looking up a key by another type it borrows as through the crate's own `Borrow`, a `&mut` to a value JS copies that std makes, other than a map's, or hands a closure, as `iter_mut` and diff --git a/ts/fixtures/reject/census.md b/ts/fixtures/reject/census.md index 846a14f13..5d2b4f070 100644 --- a/ts/fixtures/reject/census.md +++ b/ts/fixtures/reject/census.md @@ -1,60 +1,60 @@ # Census of `reject-fixture` -- Refusals: 86 -- Function instances: 73 +- Refusals: 80 +- Function instances: 72 - Generic functions no instance reached, lowered over their type parameters: 2 ## By construct | Count | Construct | First | | ---: | --- | --- | -| 10 | unsupported call to `_` | fixtures/reject/src/lib.rs:28:4 | +| 9 | unsupported call to `_` | fixtures/reject/src/lib.rs:28:4 | | 6 | `_` is not supported: its `None` and `Some` would both be `undefined` | fixtures/reject/src/lib.rs:23:15 | -| 5 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | fixtures/reject/src/lib.rs:45:11 | -| 4 | a variant of `_`, which is not supported: either is the same JS string | fixtures/reject/src/lib.rs:397:2 | -| 4 | an assignment through a reference to `_` | fixtures/reject/src/lib.rs:109:2 | +| 4 | a variant of `_`, which is not supported: either is the same JS string | fixtures/reject/src/lib.rs:390:2 | +| 4 | an assignment through a reference to `_` | fixtures/reject/src/lib.rs:111: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:45:18 | -| 3 | replacing the value behind a reference to `_` | fixtures/reject/src/lib.rs:93:2 | -| 2 | `_` is not supported: it would be pending two ways with one value | fixtures/reject/src/lib.rs:113:20 | -| 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:265:16 | -| 2 | a field of `_` | fixtures/reject/src/lib.rs:281:7 | -| 2 | an iterator of the crate implementing `_`, which is not supported yet | fixtures/reject/src/lib.rs:172:1 | -| 2 | constructing `_` from another crate | fixtures/reject/src/lib.rs:158:23 | -| 2 | overriding `_`, which std's adaptors call in place of `next` or beside it | fixtures/reject/src/lib.rs:152:2 | -| 1 | `Binary` formatting, as in `{:b}`, is not supported | fixtures/reject/src/lib.rs:70:3 | -| 1 | `LowerExp` formatting, as in `{:e}`, is not supported | fixtures/reject/src/lib.rs:72:3 | -| 1 | `Octal` formatting, as in `{:o}`, is not supported | fixtures/reject/src/lib.rs:71:3 | -| 1 | `Pointer` formatting, as in `{:p}`, is not supported | fixtures/reject/src/lib.rs:75:3 | -| 1 | `_` holds `_`, which is `undefined` as `None` is, which is not supported | fixtures/reject/src/lib.rs:286:6 | -| 1 | `_` is not supported yet | fixtures/reject/src/lib.rs:408:18 | -| 1 | `_` of `_` by `_`, which is not supported yet | fixtures/reject/src/lib.rs:309:6 | -| 1 | `_` of `_`, which drops `_`, which is not supported yet | fixtures/reject/src/lib.rs:51:13 | -| 1 | `_` through a held type's own, which is not supported yet | fixtures/reject/src/lib.rs:341:2 | -| 1 | `_`, which is not supported yet | fixtures/reject/src/lib.rs:317:9 | -| 1 | `fold` of `_`, which folds a `flatten` whose source and iterators both drop, which is not supported yet | fixtures/reject/src/lib.rs:234:26 | -| 1 | a `_` cast from `_` to `_` | fixtures/reject/src/lib.rs:104: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:239:30 | -| 1 | a `zip` of `_`, whose closures std calls one item further through `next` than through `fold` | fixtures/reject/src/lib.rs:185:51 | -| 1 | a coercion to `_` | fixtures/reject/src/lib.rs:364:2 | -| 1 | a constant of type `_` | fixtures/reject/src/lib.rs:88:2 | -| 1 | a copy of a closure that changes what it captured | fixtures/reject/src/lib.rs:275:14 | -| 1 | a mutable borrow of a subslice of `_`, which JS would copy, having no views | fixtures/reject/src/lib.rs:244:13 | -| 1 | a mutable reference into a `Result`'s payload, passed on or kept | fixtures/reject/src/lib.rs:446:12 | -| 1 | a precision, as in `{:.2}`, is not supported | fixtures/reject/src/lib.rs:67:3 | -| 1 | a printable type must implement `Display` or `Debug` | fixtures/reject/src/lib.rs:100:1 | +| 3 | replacing the value behind a reference to `_` | fixtures/reject/src/lib.rs:95:2 | +| 2 | `_` is not supported: it would be pending two ways with one value | fixtures/reject/src/lib.rs:115:20 | +| 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:267:16 | +| 2 | a field of `_` | fixtures/reject/src/lib.rs:283:7 | +| 2 | an iterator of the crate implementing `_`, which is not supported yet | fixtures/reject/src/lib.rs:174:1 | +| 2 | constructing `_` from another crate | fixtures/reject/src/lib.rs:160:23 | +| 2 | overriding `_`, which std's adaptors call in place of `next` or beside it | fixtures/reject/src/lib.rs:154:2 | +| 2 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | fixtures/reject/src/lib.rs:379:13 | +| 1 | `Binary` formatting, as in `{:b}`, is not supported | fixtures/reject/src/lib.rs:72:3 | +| 1 | `LowerExp` formatting, as in `{:e}`, is not supported | fixtures/reject/src/lib.rs:74:3 | +| 1 | `Octal` formatting, as in `{:o}`, is not supported | fixtures/reject/src/lib.rs:73:3 | +| 1 | `Pointer` formatting, as in `{:p}`, is not supported | fixtures/reject/src/lib.rs:77:3 | +| 1 | `_` holds `_`, which is `undefined` as `None` is, which is not supported | fixtures/reject/src/lib.rs:288:6 | +| 1 | `_` is not supported yet | fixtures/reject/src/lib.rs:401:18 | +| 1 | `_` of `_` by `_`, which is not supported yet | fixtures/reject/src/lib.rs:311:6 | +| 1 | `_` of `_`, which drops `_`, which is not supported yet | fixtures/reject/src/lib.rs:53:13 | +| 1 | `_` of `_`, which folds a closure that drops beside what else drops, which is not supported yet | fixtures/reject/src/lib.rs:47:23 | +| 1 | `_` through a held type's own, which is not supported yet | fixtures/reject/src/lib.rs:343:2 | +| 1 | `_`, which is not supported yet | fixtures/reject/src/lib.rs:319:9 | +| 1 | `fold` of `_`, which folds a `flatten` whose source and iterators both drop, which is not supported yet | fixtures/reject/src/lib.rs:236:26 | +| 1 | a `_` cast from `_` to `_` | fixtures/reject/src/lib.rs:106: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:241:30 | +| 1 | a `zip` of `_`, whose closures std calls one item further through `next` than through `fold` | fixtures/reject/src/lib.rs:187:51 | +| 1 | a coercion to `_` | fixtures/reject/src/lib.rs:366:2 | +| 1 | a constant of type `_` | fixtures/reject/src/lib.rs:90:2 | +| 1 | a copy of a closure that changes what it captured | fixtures/reject/src/lib.rs:277:14 | +| 1 | a mutable borrow of a subslice of `_`, which JS would copy, having no views | fixtures/reject/src/lib.rs:246:13 | +| 1 | a mutable reference into a `Result`'s payload, passed on or kept | fixtures/reject/src/lib.rs:439:12 | +| 1 | a precision, as in `{:.2}`, is not supported | fixtures/reject/src/lib.rs:69:3 | +| 1 | a printable type must implement `Display` or `Debug` | fixtures/reject/src/lib.rs:102:1 | | 1 | a scalar constant of type `_` | fixtures/reject/src/lib.rs:8:2 | -| 1 | a width or precision from an argument, as in `{:1$}`, is not supported | fixtures/reject/src/lib.rs:74:3 | -| 1 | a zero-sized constant of type `_` | fixtures/reject/src/lib.rs:60:2 | -| 1 | an iterator that owns `_`, which drops, which is not supported yet | fixtures/reject/src/lib.rs:391:13 | +| 1 | a width or precision from an argument, as in `{:1$}`, is not supported | fixtures/reject/src/lib.rs:76:3 | +| 1 | a zero-sized constant of type `_` | fixtures/reject/src/lib.rs:62:2 | +| 1 | an iterator that owns `_`, which drops, which is not supported yet | fixtures/reject/src/lib.rs:385:2 | | 1 | arithmetic on `_` | fixtures/reject/src/lib.rs:8:2 | -| 1 | comparing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:291:52 | -| 1 | constructing `_` | fixtures/reject/src/lib.rs:415:53 | -| 1 | hashing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:291:52 | -| 1 | hex `Debug`, as in `{:x?}`, is not supported | fixtures/reject/src/lib.rs:73:3 | -| 1 | the `+` flag of a format spec is not supported | fixtures/reject/src/lib.rs:68:3 | -| 1 | the `-` flag of a format spec is not supported | fixtures/reject/src/lib.rs:69:3 | +| 1 | comparing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:293:52 | +| 1 | constructing `_` | fixtures/reject/src/lib.rs:408:53 | +| 1 | hashing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:293:52 | +| 1 | hex `Debug`, as in `{:x?}`, is not supported | fixtures/reject/src/lib.rs:75:3 | +| 1 | the `+` flag of a format spec is not supported | fixtures/reject/src/lib.rs:70:3 | +| 1 | the `-` flag of a format spec is not supported | fixtures/reject/src/lib.rs:71:3 | ## By API @@ -62,132 +62,123 @@ The type or module each refused type or path belongs to. | Count | API | First | | ---: | --- | --- | -| 7 | `std::borrow::Cow` | fixtures/reject/src/lib.rs:397:2 | +| 7 | `std::borrow::Cow` | fixtures/reject/src/lib.rs:390:2 | | 6 | `Option` | fixtures/reject/src/lib.rs:23:15 | | 6 | `f64` | fixtures/reject/src/lib.rs:7:14 | -| 5 | `{closure}` | fixtures/reject/src/lib.rs:45:11 | -| 4 | `Iterator` | fixtures/reject/src/lib.rs:45:11 | -| 3 | `std::collections::HashMap` | fixtures/reject/src/lib.rs:51:13 | -| 3 | `std::iter::Map` | fixtures/reject/src/lib.rs:45:18 | +| 3 | `Iterator` | fixtures/reject/src/lib.rs:154:2 | +| 3 | `std::collections::HashMap` | fixtures/reject/src/lib.rs:53:13 | +| 3 | `std::iter::Map` | fixtures/reject/src/lib.rs:47:23 | | 3 | `std::slice` | fixtures/reject/src/lib.rs:28:4 | -| 3 | `std::sync::Arc` | fixtures/reject/src/lib.rs:109:2 | -| 2 | `Meters` | fixtures/reject/src/lib.rs:93:2 | -| 2 | `Noisy` | fixtures/reject/src/lib.rs:51:13 | -| 2 | `Poll` | fixtures/reject/src/lib.rs:113:20 | -| 2 | `std::iter::Iterator` | fixtures/reject/src/lib.rs:265:16 | -| 2 | `std::iter::Take` | fixtures/reject/src/lib.rs:389:79 | -| 2 | `std::ops::Range` | fixtures/reject/src/lib.rs:193:8 | -| 2 | `std::option::Option` | fixtures/reject/src/lib.rs:286:6 | -| 2 | `std::pin::Pin` | fixtures/reject/src/lib.rs:129:2 | -| 2 | `std::vec::Vec` | fixtures/reject/src/lib.rs:291:52 | -| 2 | `u8` | fixtures/reject/src/lib.rs:88:2 | -| 1 | `DoubleEndedIterator` | fixtures/reject/src/lib.rs:172:1 | -| 1 | `Entry` | fixtures/reject/src/lib.rs:380:13 | -| 1 | `FusedIterator` | fixtures/reject/src/lib.rs:226:1 | -| 1 | `HashMap` | fixtures/reject/src/lib.rs:309:6 | -| 1 | `Hasher` | fixtures/reject/src/lib.rs:317:9 | -| 1 | `IntToFloat` | fixtures/reject/src/lib.rs:104:2 | -| 1 | `[u16; 1]` | fixtures/reject/src/lib.rs:258:22 | +| 3 | `std::sync::Arc` | fixtures/reject/src/lib.rs:111:2 | +| 2 | `Meters` | fixtures/reject/src/lib.rs:95:2 | +| 2 | `Noisy` | fixtures/reject/src/lib.rs:53:13 | +| 2 | `Poll` | fixtures/reject/src/lib.rs:115:20 | +| 2 | `std::iter::Iterator` | fixtures/reject/src/lib.rs:267:16 | +| 2 | `std::ops::Range` | fixtures/reject/src/lib.rs:195:8 | +| 2 | `std::option::Option` | fixtures/reject/src/lib.rs:288:6 | +| 2 | `std::pin::Pin` | fixtures/reject/src/lib.rs:131:2 | +| 2 | `std::vec::Vec` | fixtures/reject/src/lib.rs:293:52 | +| 2 | `u8` | fixtures/reject/src/lib.rs:90:2 | +| 2 | `{closure}` | fixtures/reject/src/lib.rs:379:13 | +| 1 | `DoubleEndedIterator` | fixtures/reject/src/lib.rs:174:1 | +| 1 | `Entry` | fixtures/reject/src/lib.rs:379:13 | +| 1 | `FusedIterator` | fixtures/reject/src/lib.rs:228:1 | +| 1 | `HashMap` | fixtures/reject/src/lib.rs:311:6 | +| 1 | `Hasher` | fixtures/reject/src/lib.rs:319:9 | +| 1 | `IntToFloat` | fixtures/reject/src/lib.rs:106:2 | +| 1 | `[u16; 1]` | fixtures/reject/src/lib.rs:260:22 | +| 1 | `count` | fixtures/reject/src/lib.rs:47:23 | | 1 | `dyn std::ops::Fn(u8) -> u8` | fixtures/reject/src/lib.rs:11:16 | -| 1 | `from_fn` | fixtures/reject/src/lib.rs:390:13 | -| 1 | `into_keys` | fixtures/reject/src/lib.rs:51:13 | -| 1 | `std::collections::hash_map::Entry` | fixtures/reject/src/lib.rs:436:15 | -| 1 | `std::iter::Chain` | fixtures/reject/src/lib.rs:185:51 | -| 1 | `std::iter::Flatten` | fixtures/reject/src/lib.rs:234:26 | +| 1 | `into_keys` | fixtures/reject/src/lib.rs:53:13 | +| 1 | `std::collections::hash_map::Entry` | fixtures/reject/src/lib.rs:429:15 | +| 1 | `std::iter::Chain` | fixtures/reject/src/lib.rs:187:51 | +| 1 | `std::iter::Flatten` | fixtures/reject/src/lib.rs:236:26 | | 1 | `std::iter::IntoIterator` | fixtures/reject/src/lib.rs:17:2 | -| 1 | `std::iter::Rev` | fixtures/reject/src/lib.rs:179:14 | -| 1 | `std::mem` | fixtures/reject/src/lib.rs:44:29 | -| 1 | `std::ops::RangeFrom` | fixtures/reject/src/lib.rs:281:48 | -| 1 | `std::ops::RangeTo` | fixtures/reject/src/lib.rs:281:7 | -| 1 | `std::slice::Iter` | fixtures/reject/src/lib.rs:139:11 | -| 1 | `std::str` | fixtures/reject/src/lib.rs:370:4 | -| 1 | `std::string::String` | fixtures/reject/src/lib.rs:82:10 | -| 1 | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:134:2 | -| 1 | `std::time::Duration` | fixtures/reject/src/lib.rs:423:2 | -| 1 | `successors` | fixtures/reject/src/lib.rs:389:15 | -| 1 | `u32` | fixtures/reject/src/lib.rs:244:13 | -| 1 | `u64` | fixtures/reject/src/lib.rs:104:2 | -| 1 | `{async closure}` | fixtures/reject/src/lib.rs:60:2 | +| 1 | `std::iter::Rev` | fixtures/reject/src/lib.rs:181:14 | +| 1 | `std::ops::RangeFrom` | fixtures/reject/src/lib.rs:283:48 | +| 1 | `std::ops::RangeTo` | fixtures/reject/src/lib.rs:283:7 | +| 1 | `std::slice::Iter` | fixtures/reject/src/lib.rs:141:11 | +| 1 | `std::str` | fixtures/reject/src/lib.rs:372:4 | +| 1 | `std::string::String` | fixtures/reject/src/lib.rs:84:10 | +| 1 | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:136:2 | +| 1 | `std::time::Duration` | fixtures/reject/src/lib.rs:416:2 | +| 1 | `u32` | fixtures/reject/src/lib.rs:246:13 | +| 1 | `u64` | fixtures/reject/src/lib.rs:106:2 | +| 1 | `{async closure}` | fixtures/reject/src/lib.rs:62:2 | ## By type or path | Count | Construct | Type or path | First | | ---: | --- | --- | --- | | 6 | `_` is not supported: its `None` and `Some` would both be `undefined` | `Option` | fixtures/reject/src/lib.rs:23:15 | -| 4 | a variant of `_`, which is not supported: either is the same JS string | `std::borrow::Cow` | fixtures/reject/src/lib.rs:397:2 | +| 4 | a variant of `_`, which is not supported: either is the same JS string | `std::borrow::Cow` | fixtures/reject/src/lib.rs:390: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:113:20 | -| 2 | an assignment through a reference to `_` | `std::pin::Pin` | fixtures/reject/src/lib.rs:129:2 | -| 2 | dropping `_`, which is not supported yet | `std::iter::Take` | fixtures/reject/src/lib.rs:389:79 | -| 2 | replacing the value behind a reference to `_` | `Meters` | fixtures/reject/src/lib.rs:93:2 | -| 1 | `_` holds `_`, which is `undefined` as `None` is, which is not supported | `std::collections::HashMap`, `std::option::Option` | fixtures/reject/src/lib.rs:286:6 | -| 1 | `_` is not supported yet | `std::borrow::Cow` | fixtures/reject/src/lib.rs:408:18 | -| 1 | `_` of `_` by `_`, which is not supported yet | `HashMap::contains_key`, `std::collections::HashMap`, `u8` | fixtures/reject/src/lib.rs:309:6 | -| 1 | `_` of `_`, which drops `_`, which is not supported yet | `into_keys`, `std::collections::HashMap`, `Noisy` | fixtures/reject/src/lib.rs:51:13 | -| 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:265: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:265:16 | -| 1 | `_` through a held type's own, which is not supported yet | `::ne` | fixtures/reject/src/lib.rs:341: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:436:15 | +| 2 | `_` is not supported: it would be pending two ways with one value | `Poll` | fixtures/reject/src/lib.rs:115:20 | +| 2 | an assignment through a reference to `_` | `std::pin::Pin` | fixtures/reject/src/lib.rs:131:2 | +| 2 | replacing the value behind a reference to `_` | `Meters` | fixtures/reject/src/lib.rs:95:2 | +| 1 | `_` holds `_`, which is `undefined` as `None` is, which is not supported | `std::collections::HashMap`, `std::option::Option` | fixtures/reject/src/lib.rs:288:6 | +| 1 | `_` is not supported yet | `std::borrow::Cow` | fixtures/reject/src/lib.rs:401:18 | +| 1 | `_` of `_` by `_`, which is not supported yet | `HashMap::contains_key`, `std::collections::HashMap`, `u8` | fixtures/reject/src/lib.rs:311:6 | +| 1 | `_` of `_`, which drops `_`, which is not supported yet | `into_keys`, `std::collections::HashMap`, `Noisy` | fixtures/reject/src/lib.rs:53: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:47:23 | +| 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:267: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:267:16 | +| 1 | `_` through a held type's own, which is not supported yet | `::ne` | fixtures/reject/src/lib.rs:343: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:429: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:429:21 | -| 1 | `_`, which is not supported yet | `Hasher::write` | fixtures/reject/src/lib.rs:317: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:234:26 | -| 1 | a `_` cast from `_` to `_` | `IntToFloat`, `u64`, `f64` | fixtures/reject/src/lib.rs:104: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:239: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:185:51 | -| 1 | a coercion to `_` | `std::sync::Arc` | fixtures/reject/src/lib.rs:364:2 | -| 1 | a constant of type `_` | `&u8` | fixtures/reject/src/lib.rs:88:2 | -| 1 | a field of `_` | `std::ops::RangeFrom` | fixtures/reject/src/lib.rs:281:48 | -| 1 | a field of `_` | `std::ops::RangeTo` | fixtures/reject/src/lib.rs:281:7 | -| 1 | a mutable borrow of a subslice of `_`, which JS would copy, having no views | `u32` | fixtures/reject/src/lib.rs:244: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:422:21 | +| 1 | `_`, which is not supported yet | `Hasher::write` | fixtures/reject/src/lib.rs:319: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:236:26 | +| 1 | a `_` cast from `_` to `_` | `IntToFloat`, `u64`, `f64` | fixtures/reject/src/lib.rs:106: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:241: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:187:51 | +| 1 | a coercion to `_` | `std::sync::Arc` | fixtures/reject/src/lib.rs:366:2 | +| 1 | a constant of type `_` | `&u8` | fixtures/reject/src/lib.rs:90:2 | +| 1 | a field of `_` | `std::ops::RangeFrom` | fixtures/reject/src/lib.rs:283:48 | +| 1 | a field of `_` | `std::ops::RangeTo` | fixtures/reject/src/lib.rs:283:7 | +| 1 | a mutable borrow of a subslice of `_`, which JS would copy, having no views | `u32` | fixtures/reject/src/lib.rs:246: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:60:2 | -| 1 | an assignment through a reference to `_` | `std::sync::Arc` | fixtures/reject/src/lib.rs:109:2 | -| 1 | an assignment through a reference to `_` | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:134:2 | -| 1 | an iterator of the crate implementing `_`, which is not supported yet | `DoubleEndedIterator` | fixtures/reject/src/lib.rs:172:1 | -| 1 | an iterator of the crate implementing `_`, which is not supported yet | `FusedIterator` | fixtures/reject/src/lib.rs:226:1 | -| 1 | an iterator that owns `_`, which drops, which is not supported yet | `Noisy` | fixtures/reject/src/lib.rs:391:13 | +| 1 | a zero-sized constant of type `_` | `{async closure}` | fixtures/reject/src/lib.rs:62:2 | +| 1 | an assignment through a reference to `_` | `std::sync::Arc` | fixtures/reject/src/lib.rs:111:2 | +| 1 | an assignment through a reference to `_` | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:136:2 | +| 1 | an iterator of the crate implementing `_`, which is not supported yet | `DoubleEndedIterator` | fixtures/reject/src/lib.rs:174:1 | +| 1 | an iterator of the crate implementing `_`, which is not supported yet | `FusedIterator` | fixtures/reject/src/lib.rs:228:1 | +| 1 | an iterator that owns `_`, which drops, which is not supported yet | `Noisy` | fixtures/reject/src/lib.rs:385:2 | | 1 | arithmetic on `_` | `f64` | fixtures/reject/src/lib.rs:8:2 | -| 1 | comparing `_` as a key, which is not supported yet | `std::vec::Vec` | fixtures/reject/src/lib.rs:291:52 | -| 1 | constructing `_` | `std::borrow::Cow` | fixtures/reject/src/lib.rs:415:53 | -| 1 | constructing `_` from another crate | `std::iter::Map` | fixtures/reject/src/lib.rs:158:23 | -| 1 | constructing `_` from another crate | `std::iter::Rev` | fixtures/reject/src/lib.rs:179:14 | -| 1 | dropping `_`, which is not supported yet | `std::iter::Map` | fixtures/reject/src/lib.rs:45:18 | -| 1 | hashing `_` as a key, which is not supported yet | `std::vec::Vec` | fixtures/reject/src/lib.rs:291:52 | -| 1 | overriding `_`, which std's adaptors call in place of `next` or beside it | `Iterator::fold` | fixtures/reject/src/lib.rs:152:2 | -| 1 | overriding `_`, which std's adaptors call in place of `next` or beside it | `Iterator::size_hint` | fixtures/reject/src/lib.rs:206: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::any` | fixtures/reject/src/lib.rs:381: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:45: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:390: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:389:15 | -| 1 | replacing the value behind a reference to `_` | `[u16; 1]` | fixtures/reject/src/lib.rs:258:22 | -| 1 | unsupported call to `_` | `::deref` | fixtures/reject/src/lib.rs:409:2 | -| 1 | unsupported call to `_` | `::eq` | fixtures/reject/src/lib.rs:453:2 | -| 1 | unsupported call to `_` | `::cycle` | fixtures/reject/src/lib.rs:139:11 | -| 1 | unsupported call to `_` | `::write_fmt` | fixtures/reject/src/lib.rs:82:10 | -| 1 | unsupported call to `_` | `::add_assign` | fixtures/reject/src/lib.rs:423:2 | -| 1 | unsupported call to `_` | `std::mem::size_of_val` | fixtures/reject/src/lib.rs:44:29 | -| 1 | unsupported call to `_` | `std::ops::Range::contains` | fixtures/reject/src/lib.rs:193:8 | -| 1 | unsupported call to `_` | `std::slice::copy_within` | fixtures/reject/src/lib.rs:359:4 | +| 1 | comparing `_` as a key, which is not supported yet | `std::vec::Vec` | fixtures/reject/src/lib.rs:293:52 | +| 1 | constructing `_` | `std::borrow::Cow` | fixtures/reject/src/lib.rs:408:53 | +| 1 | constructing `_` from another crate | `std::iter::Map` | fixtures/reject/src/lib.rs:160:23 | +| 1 | constructing `_` from another crate | `std::iter::Rev` | fixtures/reject/src/lib.rs:181:14 | +| 1 | hashing `_` as a key, which is not supported yet | `std::vec::Vec` | fixtures/reject/src/lib.rs:293:52 | +| 1 | overriding `_`, which std's adaptors call in place of `next` or beside it | `Iterator::fold` | fixtures/reject/src/lib.rs:154:2 | +| 1 | overriding `_`, which std's adaptors call in place of `next` or beside it | `Iterator::size_hint` | fixtures/reject/src/lib.rs:208: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:379: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:380:16 | +| 1 | replacing the value behind a reference to `_` | `[u16; 1]` | fixtures/reject/src/lib.rs:260:22 | +| 1 | unsupported call to `_` | `::deref` | fixtures/reject/src/lib.rs:402:2 | +| 1 | unsupported call to `_` | `::eq` | fixtures/reject/src/lib.rs:446:2 | +| 1 | unsupported call to `_` | `::cycle` | fixtures/reject/src/lib.rs:141:11 | +| 1 | unsupported call to `_` | `::write_fmt` | fixtures/reject/src/lib.rs:84:10 | +| 1 | unsupported call to `_` | `::add_assign` | fixtures/reject/src/lib.rs:416:2 | +| 1 | unsupported call to `_` | `std::ops::Range::contains` | fixtures/reject/src/lib.rs:195:8 | +| 1 | unsupported call to `_` | `std::slice::copy_within` | fixtures/reject/src/lib.rs:361: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:370:4 | +| 1 | unsupported call to `_` | `std::str::split` | fixtures/reject/src/lib.rs:372:4 | | 1 | unsupported type `_` | `dyn std::ops::Fn(u8) -> u8` | fixtures/reject/src/lib.rs:11:16 | ## Spans -
unsupported call to `_` (10) +
unsupported call to `_` (9) - fixtures/reject/src/lib.rs:28:4: unsupported call to `std::slice::::sort` -- fixtures/reject/src/lib.rs:44:29: unsupported call to `std::mem::size_of_val::` -- fixtures/reject/src/lib.rs:82:10: unsupported call to `::write_fmt` -- fixtures/reject/src/lib.rs:139:11: unsupported call to ` as std::iter::Iterator>::cycle` -- fixtures/reject/src/lib.rs:193:8: unsupported call to `std::ops::Range::::contains::` -- fixtures/reject/src/lib.rs:359:4: unsupported call to `core::slice::::copy_within::>` -- fixtures/reject/src/lib.rs:370:4: unsupported call to `core::str::::split::<[char; 2]>` -- fixtures/reject/src/lib.rs:409:2: unsupported call to ` as std::ops::Deref>::deref` -- fixtures/reject/src/lib.rs:423:2: unsupported call to `::add_assign` -- fixtures/reject/src/lib.rs:453:2: unsupported call to ` as std::cmp::PartialEq>::eq` +- fixtures/reject/src/lib.rs:84:10: unsupported call to `::write_fmt` +- fixtures/reject/src/lib.rs:141:11: unsupported call to ` as std::iter::Iterator>::cycle` +- fixtures/reject/src/lib.rs:195:8: unsupported call to `std::ops::Range::::contains::` +- fixtures/reject/src/lib.rs:361:4: unsupported call to `core::slice::::copy_within::>` +- fixtures/reject/src/lib.rs:372:4: unsupported call to `core::str::::split::<[char; 2]>` +- fixtures/reject/src/lib.rs:402:2: unsupported call to ` as std::ops::Deref>::deref` +- fixtures/reject/src/lib.rs:416:2: unsupported call to `::add_assign` +- fixtures/reject/src/lib.rs:446:2: unsupported call to ` as std::cmp::PartialEq>::eq`
@@ -197,36 +188,26 @@ The type or module each refused type or path belongs to. - fixtures/reject/src/lib.rs:24:2: `Option>` is not supported: its `None` and `Some` would both be `undefined` - fixtures/reject/src/lib.rs:32:2: `Option>` is not supported: its `None` and `Some` would both be `undefined` - fixtures/reject/src/lib.rs:32:42: `Option>` is not supported: its `None` and `Some` would both be `undefined` -- fixtures/reject/src/lib.rs:118:19: `Option>` is not supported: its `None` and `Some` would both be `undefined` -- fixtures/reject/src/lib.rs:286:2: `Option<&std::option::Option>` is not supported: its `None` and `Some` would both be `undefined` - -
- -
passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet (5) - -- fixtures/reject/src/lib.rs:45:11: passing `{closure@fixtures/reject/src/lib.rs:44:10: 44:23}`, a closure that owns a value that drops, to `Iterator::map`, which is not supported yet -- 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:11: passing `{closure@fixtures/reject/src/lib.rs:381:15: 381:24}`, a closure that owns a value that drops, to `Iterator::any`, which is not supported yet -- fixtures/reject/src/lib.rs:389:15: passing `{closure@fixtures/reject/src/lib.rs:389:48: 389:56}`, a closure that owns a value that drops, to `successors::successors`, which is not supported yet -- fixtures/reject/src/lib.rs:390:13: passing `{closure@fixtures/reject/src/lib.rs:390:32: 390:39}`, a closure that owns a value that drops, to `from_fn::from_fn`, which is not supported yet +- fixtures/reject/src/lib.rs:120:19: `Option>` is not supported: its `None` and `Some` would both be `undefined` +- fixtures/reject/src/lib.rs:288:2: `Option<&std::option::Option>` is not supported: its `None` and `Some` would both be `undefined`
a variant of `_`, which is not supported: either is the same JS string (4) +- fixtures/reject/src/lib.rs:390:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +- fixtures/reject/src/lib.rs:391:30: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +- fixtures/reject/src/lib.rs:392:27: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string - fixtures/reject/src/lib.rs:397:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string -- fixtures/reject/src/lib.rs:398:30: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string -- fixtures/reject/src/lib.rs:399:27: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string -- fixtures/reject/src/lib.rs:404: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:109:2: an assignment through a reference to `std::sync::Arc` -- fixtures/reject/src/lib.rs:129:2: an assignment through a reference to `std::pin::Pin>` -- fixtures/reject/src/lib.rs:134:2: an assignment through a reference to `std::sync::MutexGuard<'_, u8>` -- fixtures/reject/src/lib.rs:252:2: an assignment through a reference to `std::pin::Pin<&mut Noisy>` +- fixtures/reject/src/lib.rs:111:2: an assignment through a reference to `std::sync::Arc` +- fixtures/reject/src/lib.rs:131:2: an assignment through a reference to `std::pin::Pin>` +- fixtures/reject/src/lib.rs:136:2: an assignment through a reference to `std::sync::MutexGuard<'_, u8>` +- fixtures/reject/src/lib.rs:254:2: an assignment through a reference to `std::pin::Pin<&mut Noisy>`
@@ -235,199 +216,204 @@ 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:102:51: unsupported type `f64` +- fixtures/reject/src/lib.rs:104: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:429:21: `core::slice::::last_mut` with a mutable reference to a value JS copies, which its mapping would copy -- fixtures/reject/src/lib.rs:436: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:45:18: dropping `std::iter::Map, {closure@fixtures/reject/src/lib.rs:44:10: 44:23}>`, which is not supported yet -- fixtures/reject/src/lib.rs:389:79: dropping `std::iter::Take>`, which is not supported yet -- fixtures/reject/src/lib.rs:390:62: dropping `std::iter::Take>`, which is not supported yet +- fixtures/reject/src/lib.rs:422:21: `core::slice::::last_mut` with a mutable reference to a value JS copies, which its mapping would copy +- fixtures/reject/src/lib.rs:429: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:93:2: replacing the value behind a reference to `Meters` -- fixtures/reject/src/lib.rs:97:2: replacing the value behind a reference to `Meters` -- fixtures/reject/src/lib.rs:258:22: replacing the value behind a reference to `[u16; 1]` +- fixtures/reject/src/lib.rs:95:2: replacing the value behind a reference to `Meters` +- fixtures/reject/src/lib.rs:99:2: replacing the value behind a reference to `Meters` +- fixtures/reject/src/lib.rs:260: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:113:20: `Poll>>` is not supported: it would be pending two ways with one value -- fixtures/reject/src/lib.rs:123:54: `Poll>` is not supported: it would be pending two ways with one value +- fixtures/reject/src/lib.rs:115:20: `Poll>>` is not supported: it would be pending two ways with one value +- fixtures/reject/src/lib.rs:125:54: `Poll>` is not supported: it would be pending two ways with one value
`_` 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:265: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:265: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:267: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:267: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:281:7: a field of `std::ops::RangeTo` -- fixtures/reject/src/lib.rs:281:48: a field of `std::ops::RangeFrom` +- fixtures/reject/src/lib.rs:283:7: a field of `std::ops::RangeTo` +- fixtures/reject/src/lib.rs:283:48: a field of `std::ops::RangeFrom`
an iterator of the crate implementing `_`, which is not supported yet (2) -- fixtures/reject/src/lib.rs:172:1: an iterator of the crate implementing `DoubleEndedIterator`, which is not supported yet -- fixtures/reject/src/lib.rs:226:1: an iterator of the crate implementing `FusedIterator`, which is not supported yet +- fixtures/reject/src/lib.rs:174:1: an iterator of the crate implementing `DoubleEndedIterator`, which is not supported yet +- fixtures/reject/src/lib.rs:228:1: an iterator of the crate implementing `FusedIterator`, which is not supported yet
constructing `_` from another crate (2) -- fixtures/reject/src/lib.rs:158:23: constructing `std::iter::Map` from another crate -- fixtures/reject/src/lib.rs:179:14: constructing `std::iter::Rev` from another crate +- fixtures/reject/src/lib.rs:160:23: constructing `std::iter::Map` from another crate +- fixtures/reject/src/lib.rs:181: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:152:2: overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it -- fixtures/reject/src/lib.rs:206:2: overriding `Iterator::size_hint`, which std's adaptors call in place of `next` or beside it +- fixtures/reject/src/lib.rs:154:2: overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it +- fixtures/reject/src/lib.rs:208: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:379:13: passing `{closure@fixtures/reject/src/lib.rs:379:28: 379:35}`, a closure that owns a value that drops, to `Entry::or_insert_with`, which is not supported yet +- fixtures/reject/src/lib.rs:380:16: passing `{closure@fixtures/reject/src/lib.rs:380:25: 380:33}`, a closure that owns a value that drops, to `Iterator::for_each`, which is not supported yet
`Binary` formatting, as in `{:b}`, is not supported (1) -- fixtures/reject/src/lib.rs:70:3: `Binary` formatting, as in `{:b}`, is not supported +- fixtures/reject/src/lib.rs:72:3: `Binary` formatting, as in `{:b}`, is not supported
`LowerExp` formatting, as in `{:e}`, is not supported (1) -- fixtures/reject/src/lib.rs:72:3: `LowerExp` formatting, as in `{:e}`, is not supported +- fixtures/reject/src/lib.rs:74:3: `LowerExp` formatting, as in `{:e}`, is not supported
`Octal` formatting, as in `{:o}`, is not supported (1) -- fixtures/reject/src/lib.rs:71:3: `Octal` formatting, as in `{:o}`, is not supported +- fixtures/reject/src/lib.rs:73:3: `Octal` formatting, as in `{:o}`, is not supported
`Pointer` formatting, as in `{:p}`, is not supported (1) -- fixtures/reject/src/lib.rs:75:3: `Pointer` formatting, as in `{:p}`, is not supported +- fixtures/reject/src/lib.rs:77:3: `Pointer` formatting, as in `{:p}`, is not supported
`_` holds `_`, which is `undefined` as `None` is, which is not supported (1) -- fixtures/reject/src/lib.rs:286:6: `std::collections::HashMap>` holds `std::option::Option`, which is `undefined` as `None` is, which is not supported +- fixtures/reject/src/lib.rs:288:6: `std::collections::HashMap>` holds `std::option::Option`, which is `undefined` as `None` is, which is not supported
`_` is not supported yet (1) -- fixtures/reject/src/lib.rs:408:18: `std::borrow::Cow<'_, [u8]>` is not supported yet +- fixtures/reject/src/lib.rs:401:18: `std::borrow::Cow<'_, [u8]>` is not supported yet
`_` of `_` by `_`, which is not supported yet (1) -- fixtures/reject/src/lib.rs:309:6: `HashMap::contains_key` of `std::collections::HashMap` by `u8`, which is not supported yet +- fixtures/reject/src/lib.rs:311: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:51:13: `into_keys` of `std::collections::HashMap`, which drops `Noisy`, which is not supported yet +- fixtures/reject/src/lib.rs:53: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:47:23: `count` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:46:10: 46: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:341:2: ` as PartialEq>::ne` through a held type's own, which is not supported yet +- fixtures/reject/src/lib.rs:343: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:317:9: `Hasher::write`, which is not supported yet +- fixtures/reject/src/lib.rs:319: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:234: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:236: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:104:2: a `IntToFloat` cast from `u64` to `f64` +- fixtures/reject/src/lib.rs:106: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:239:30: a `zip` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:239:15: 239:19}>` and `std::ops::Range`, which std reads by index, of items that drop, which is not supported yet +- fixtures/reject/src/lib.rs:241:30: a `zip` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:241:15: 241: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:185:51: a `zip` of `std::iter::Chain, {closure@fixtures/reject/src/lib.rs:185:15: 185:18}>, std::iter::Copied>>`, whose closures std calls one item further through `next` than through `fold` +- fixtures/reject/src/lib.rs:187:51: a `zip` of `std::iter::Chain, {closure@fixtures/reject/src/lib.rs:187:15: 187: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:364:2: a coercion to `std::sync::Arc<[u8]>` +- fixtures/reject/src/lib.rs:366:2: a coercion to `std::sync::Arc<[u8]>`
a constant of type `_` (1) -- fixtures/reject/src/lib.rs:88:2: a constant of type `&u8` +- fixtures/reject/src/lib.rs:90:2: a constant of type `&u8`
a copy of a closure that changes what it captured (1) -- fixtures/reject/src/lib.rs:275:14: a copy of a closure that changes what it captured +- fixtures/reject/src/lib.rs:277: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:244:13: a mutable borrow of a subslice of `u32`, which JS would copy, having no views +- fixtures/reject/src/lib.rs:246: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:446:12: a mutable reference into a `Result`'s payload, passed on or kept +- fixtures/reject/src/lib.rs:439:12: a mutable reference into a `Result`'s payload, passed on or kept
a precision, as in `{:.2}`, is not supported (1) -- fixtures/reject/src/lib.rs:67:3: a precision, as in `{:.2}`, is not supported +- fixtures/reject/src/lib.rs:69:3: a precision, as in `{:.2}`, is not supported
a printable type must implement `Display` or `Debug` (1) -- fixtures/reject/src/lib.rs:100:1: a printable type must implement `Display` or `Debug` +- fixtures/reject/src/lib.rs:102:1: a printable type must implement `Display` or `Debug`
@@ -439,19 +425,19 @@ The type or module each refused type or path belongs to.
a width or precision from an argument, as in `{:1$}`, is not supported (1) -- fixtures/reject/src/lib.rs:74:3: a width or precision from an argument, as in `{:1$}`, is not supported +- fixtures/reject/src/lib.rs:76:3: a width or precision from an argument, as in `{:1$}`, is not supported
a zero-sized constant of type `_` (1) -- fixtures/reject/src/lib.rs:60:2: a zero-sized constant of type `{async closure@fixtures/reject/src/lib.rs:59:10: 59:18}` +- fixtures/reject/src/lib.rs:62:2: a zero-sized constant of type `{async closure@fixtures/reject/src/lib.rs:61:10: 61:18}`
an iterator that owns `_`, which drops, which is not supported yet (1) -- fixtures/reject/src/lib.rs:391:13: an iterator that owns `Noisy`, which drops, which is not supported yet +- fixtures/reject/src/lib.rs:385:2: an iterator that owns `Noisy`, which drops, which is not supported yet
@@ -463,36 +449,36 @@ 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:291:52: comparing `std::vec::Vec` as a key, which is not supported yet +- fixtures/reject/src/lib.rs:293:52: comparing `std::vec::Vec` as a key, which is not supported yet
constructing `_` (1) -- fixtures/reject/src/lib.rs:415:53: constructing `std::borrow::Cow<'_, std::sync::Arc>` +- fixtures/reject/src/lib.rs:408:53: constructing `std::borrow::Cow<'_, std::sync::Arc>`
hashing `_` as a key, which is not supported yet (1) -- fixtures/reject/src/lib.rs:291:52: hashing `std::vec::Vec` as a key, which is not supported yet +- fixtures/reject/src/lib.rs:293:52: hashing `std::vec::Vec` as a key, which is not supported yet
hex `Debug`, as in `{:x?}`, is not supported (1) -- fixtures/reject/src/lib.rs:73:3: hex `Debug`, as in `{:x?}`, is not supported +- fixtures/reject/src/lib.rs:75:3: hex `Debug`, as in `{:x?}`, is not supported
the `+` flag of a format spec is not supported (1) -- fixtures/reject/src/lib.rs:68:3: the `+` flag of a format spec is not supported +- fixtures/reject/src/lib.rs:70:3: the `+` flag of a format spec is not supported
the `-` flag of a format spec is not supported (1) -- fixtures/reject/src/lib.rs:69:3: the `-` flag of a format spec is not supported +- fixtures/reject/src/lib.rs:71:3: the `-` flag of a format spec is not supported
diff --git a/ts/fixtures/reject/expected.txt b/ts/fixtures/reject/expected.txt index 6a5d50716..e4f312a25 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:102:1 +a root must not be generic at fixtures/reject/src/lib.rs:104:1 no item `missing` in the crate -a printable type must implement `Display` or `Debug` at fixtures/reject/src/lib.rs:100:1 +a printable type must implement `Display` or `Debug` at fixtures/reject/src/lib.rs:102: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 @@ -12,75 +12,69 @@ unsupported type `dyn std::ops::Fn(u8) -> u8` at fixtures/reject/src/lib.rs:11:1 unsupported call to `std::slice::::sort` at fixtures/reject/src/lib.rs:28:4 `Option>` is not supported: its `None` and `Some` would both be `undefined` at fixtures/reject/src/lib.rs:32:2 `Option>` is not supported: its `None` and `Some` would both be `undefined` at fixtures/reject/src/lib.rs:32:42 -unsupported call to `std::mem::size_of_val::` at fixtures/reject/src/lib.rs:44:29 -passing `{closure@fixtures/reject/src/lib.rs:44:10: 44:23}`, a closure that owns a value that drops, to `Iterator::map`, which is not supported yet at fixtures/reject/src/lib.rs:45:11 -dropping `std::iter::Map, {closure@fixtures/reject/src/lib.rs:44:10: 44:23}>`, which is not supported yet at fixtures/reject/src/lib.rs:45:18 -`into_keys` of `std::collections::HashMap`, which drops `Noisy`, which is not supported yet at fixtures/reject/src/lib.rs:51:13 -a zero-sized constant of type `{async closure@fixtures/reject/src/lib.rs:59:10: 59:18}` at fixtures/reject/src/lib.rs:60:2 -a precision, as in `{:.2}`, is not supported at fixtures/reject/src/lib.rs:67:3 -the `+` flag of a format spec is not supported at fixtures/reject/src/lib.rs:68:3 -the `-` flag of a format spec is not supported at fixtures/reject/src/lib.rs:69:3 -`Binary` formatting, as in `{:b}`, is not supported at fixtures/reject/src/lib.rs:70:12 -`Octal` formatting, as in `{:o}`, is not supported at fixtures/reject/src/lib.rs:71:12 -`LowerExp` formatting, as in `{:e}`, is not supported at fixtures/reject/src/lib.rs:72:12 -hex `Debug`, as in `{:x?}`, is not supported at fixtures/reject/src/lib.rs:73:3 -a width or precision from an argument, as in `{:1$}`, is not supported at fixtures/reject/src/lib.rs:74:15 -a width or precision from an argument, as in `{:1$}`, is not supported at fixtures/reject/src/lib.rs:74:3 -`Pointer` formatting, as in `{:p}`, is not supported at fixtures/reject/src/lib.rs:75:12 -unsupported call to `::write_fmt` at fixtures/reject/src/lib.rs:82:10 -a constant of type `&u8` at fixtures/reject/src/lib.rs:88:2 -replacing the value behind a reference to `Meters` at fixtures/reject/src/lib.rs:93:2 -replacing the value behind a reference to `Meters` at fixtures/reject/src/lib.rs:97:2 -an assignment through a reference to `std::sync::Arc` at fixtures/reject/src/lib.rs:109:2 -`Poll>>` is not supported: it would be pending two ways with one value at fixtures/reject/src/lib.rs:113:20 -`Option>` is not supported: its `None` and `Some` would both be `undefined` at fixtures/reject/src/lib.rs:118:19 -`Poll>` is not supported: it would be pending two ways with one value at fixtures/reject/src/lib.rs:123:54 -an assignment through a reference to `std::pin::Pin>` at fixtures/reject/src/lib.rs:129:2 -an assignment through a reference to `std::sync::MutexGuard<'_, u8>` at fixtures/reject/src/lib.rs:134:2 -unsupported call to ` as std::iter::Iterator>::cycle` at fixtures/reject/src/lib.rs:139:11 -constructing `std::iter::Map` from another crate at fixtures/reject/src/lib.rs:158:23 -constructing `std::iter::Rev` from another crate at fixtures/reject/src/lib.rs:179:14 -a `zip` of `std::iter::Chain, {closure@fixtures/reject/src/lib.rs:185:15: 185:18}>, std::iter::Copied>>`, whose closures std calls one item further through `next` than through `fold` at fixtures/reject/src/lib.rs:185:51 -unsupported call to `std::ops::Range::::contains::` at fixtures/reject/src/lib.rs:193: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:234:26 -a `zip` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:239:15: 239: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:239:30 -a mutable borrow of a subslice of `u32`, which JS would copy, having no views at fixtures/reject/src/lib.rs:244:13 -an assignment through a reference to `std::pin::Pin<&mut Noisy>` at fixtures/reject/src/lib.rs:252:2 -replacing the value behind a reference to `[u16; 1]` at fixtures/reject/src/lib.rs:258: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:265: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:265:38 -a copy of a closure that changes what it captured at fixtures/reject/src/lib.rs:275:14 -a field of `std::ops::RangeTo` at fixtures/reject/src/lib.rs:281:7 -a field of `std::ops::RangeFrom` at fixtures/reject/src/lib.rs:281:48 -`Option<&std::option::Option>` is not supported: its `None` and `Some` would both be `undefined` at fixtures/reject/src/lib.rs:286:2 -`std::collections::HashMap>` holds `std::option::Option`, which is `undefined` as `None` is, which is not supported at fixtures/reject/src/lib.rs:286:6 -hashing `std::vec::Vec` as a key, which is not supported yet at fixtures/reject/src/lib.rs:291:52 -comparing `std::vec::Vec` as a key, which is not supported yet at fixtures/reject/src/lib.rs:291:52 -`HashMap::contains_key` of `std::collections::HashMap` by `u8`, which is not supported yet at fixtures/reject/src/lib.rs:309:6 -unsupported call to `core::slice::::copy_within::>` at fixtures/reject/src/lib.rs:359:4 -a coercion to `std::sync::Arc<[u8]>` at fixtures/reject/src/lib.rs:364:2 +`count` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:46:10: 46:25}>`, which folds a closure that drops beside what else drops, which is not supported yet at fixtures/reject/src/lib.rs:47:23 +`into_keys` of `std::collections::HashMap`, which drops `Noisy`, which is not supported yet at fixtures/reject/src/lib.rs:53:13 +a zero-sized constant of type `{async closure@fixtures/reject/src/lib.rs:61:10: 61:18}` at fixtures/reject/src/lib.rs:62:2 +a precision, as in `{:.2}`, is not supported at fixtures/reject/src/lib.rs:69:3 +the `+` flag of a format spec is not supported at fixtures/reject/src/lib.rs:70:3 +the `-` flag of a format spec is not supported at fixtures/reject/src/lib.rs:71:3 +`Binary` formatting, as in `{:b}`, is not supported at fixtures/reject/src/lib.rs:72:12 +`Octal` formatting, as in `{:o}`, is not supported at fixtures/reject/src/lib.rs:73:12 +`LowerExp` formatting, as in `{:e}`, is not supported at fixtures/reject/src/lib.rs:74:12 +hex `Debug`, as in `{:x?}`, is not supported at fixtures/reject/src/lib.rs:75:3 +a width or precision from an argument, as in `{:1$}`, is not supported at fixtures/reject/src/lib.rs:76:15 +a width or precision from an argument, as in `{:1$}`, is not supported at fixtures/reject/src/lib.rs:76:3 +`Pointer` formatting, as in `{:p}`, is not supported at fixtures/reject/src/lib.rs:77:12 +unsupported call to `::write_fmt` at fixtures/reject/src/lib.rs:84:10 +a constant of type `&u8` at fixtures/reject/src/lib.rs:90:2 +replacing the value behind a reference to `Meters` at fixtures/reject/src/lib.rs:95:2 +replacing the value behind a reference to `Meters` at fixtures/reject/src/lib.rs:99:2 +an assignment through a reference to `std::sync::Arc` at fixtures/reject/src/lib.rs:111:2 +`Poll>>` is not supported: it would be pending two ways with one value at fixtures/reject/src/lib.rs:115:20 +`Option>` is not supported: its `None` and `Some` would both be `undefined` at fixtures/reject/src/lib.rs:120:19 +`Poll>` is not supported: it would be pending two ways with one value at fixtures/reject/src/lib.rs:125:54 +an assignment through a reference to `std::pin::Pin>` at fixtures/reject/src/lib.rs:131:2 +an assignment through a reference to `std::sync::MutexGuard<'_, u8>` at fixtures/reject/src/lib.rs:136:2 +unsupported call to ` as std::iter::Iterator>::cycle` at fixtures/reject/src/lib.rs:141:11 +constructing `std::iter::Map` from another crate at fixtures/reject/src/lib.rs:160:23 +constructing `std::iter::Rev` from another crate at fixtures/reject/src/lib.rs:181:14 +a `zip` of `std::iter::Chain, {closure@fixtures/reject/src/lib.rs:187:15: 187:18}>, std::iter::Copied>>`, whose closures std calls one item further through `next` than through `fold` at fixtures/reject/src/lib.rs:187:51 +unsupported call to `std::ops::Range::::contains::` at fixtures/reject/src/lib.rs:195: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:236:26 +a `zip` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:241:15: 241: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:241:30 +a mutable borrow of a subslice of `u32`, which JS would copy, having no views at fixtures/reject/src/lib.rs:246:13 +an assignment through a reference to `std::pin::Pin<&mut Noisy>` at fixtures/reject/src/lib.rs:254:2 +replacing the value behind a reference to `[u16; 1]` at fixtures/reject/src/lib.rs:260: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:267: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:267:38 +a copy of a closure that changes what it captured at fixtures/reject/src/lib.rs:277:14 +a field of `std::ops::RangeTo` at fixtures/reject/src/lib.rs:283:7 +a field of `std::ops::RangeFrom` at fixtures/reject/src/lib.rs:283:48 +`Option<&std::option::Option>` is not supported: its `None` and `Some` would both be `undefined` at fixtures/reject/src/lib.rs:288:2 +`std::collections::HashMap>` holds `std::option::Option`, which is `undefined` as `None` is, which is not supported at fixtures/reject/src/lib.rs:288:6 +hashing `std::vec::Vec` as a key, which is not supported yet at fixtures/reject/src/lib.rs:293:52 +comparing `std::vec::Vec` as a key, which is not supported yet at fixtures/reject/src/lib.rs:293:52 +`HashMap::contains_key` of `std::collections::HashMap` by `u8`, which is not supported yet at fixtures/reject/src/lib.rs:311:6 +unsupported call to `core::slice::::copy_within::>` at fixtures/reject/src/lib.rs:361:4 +a coercion to `std::sync::Arc<[u8]>` at fixtures/reject/src/lib.rs:366:2 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:390:2 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:392:27 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:391:30 a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:397:2 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:399:27 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:398:30 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:404:2 -`std::borrow::Cow<'_, [u8]>` is not supported yet at fixtures/reject/src/lib.rs:408:18 -unsupported call to ` as std::ops::Deref>::deref` at fixtures/reject/src/lib.rs:409:2 -constructing `std::borrow::Cow<'_, std::sync::Arc>` at fixtures/reject/src/lib.rs:415:53 -unsupported call to `core::str::::split::<[char; 2]>` at fixtures/reject/src/lib.rs:370: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:15: 381:24}`, a closure that owns a value that drops, to `Iterator::any`, which is not supported yet at fixtures/reject/src/lib.rs:381:11 -passing `{closure@fixtures/reject/src/lib.rs:389:48: 389:56}`, a closure that owns a value that drops, to `successors::successors`, which is not supported yet at fixtures/reject/src/lib.rs:389:15 -dropping `std::iter::Take>`, which is not supported yet at fixtures/reject/src/lib.rs:389:79 -passing `{closure@fixtures/reject/src/lib.rs:390:32: 390: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:390:13 -dropping `std::iter::Take>`, which is not supported yet at fixtures/reject/src/lib.rs:390:62 -an iterator that owns `Noisy`, which drops, which is not supported yet at fixtures/reject/src/lib.rs:391:13 -unsupported call to `::add_assign` at fixtures/reject/src/lib.rs:423:2 -`core::slice::::last_mut` with a mutable reference to a value JS copies, which its mapping would copy at fixtures/reject/src/lib.rs:429: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:436:15 -a mutable reference into a `Result`'s payload, passed on or kept at fixtures/reject/src/lib.rs:446:12 -unsupported call to ` as std::cmp::PartialEq>::eq` at fixtures/reject/src/lib.rs:453:2 -overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:152:2 -an iterator of the crate implementing `DoubleEndedIterator`, which is not supported yet at fixtures/reject/src/lib.rs:172:1 -overriding `Iterator::size_hint`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:206:2 -an iterator of the crate implementing `FusedIterator`, which is not supported yet at fixtures/reject/src/lib.rs:226:1 -`Hasher::write`, which is not supported yet at fixtures/reject/src/lib.rs:317:9 +`std::borrow::Cow<'_, [u8]>` is not supported yet at fixtures/reject/src/lib.rs:401:18 +unsupported call to ` as std::ops::Deref>::deref` at fixtures/reject/src/lib.rs:402:2 +constructing `std::borrow::Cow<'_, std::sync::Arc>` at fixtures/reject/src/lib.rs:408:53 +unsupported call to `core::str::::split::<[char; 2]>` at fixtures/reject/src/lib.rs:372:4 +passing `{closure@fixtures/reject/src/lib.rs:379:28: 379: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:379:13 +passing `{closure@fixtures/reject/src/lib.rs:380:25: 380:33}`, a closure that owns a value that drops, to `Iterator::for_each`, which is not supported yet at fixtures/reject/src/lib.rs:380:16 +an iterator that owns `Noisy`, which drops, which is not supported yet at fixtures/reject/src/lib.rs:385:2 +unsupported call to `::add_assign` at fixtures/reject/src/lib.rs:416:2 +`core::slice::::last_mut` with a mutable reference to a value JS copies, which its mapping would copy at fixtures/reject/src/lib.rs:422: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:429:15 +a mutable reference into a `Result`'s payload, passed on or kept at fixtures/reject/src/lib.rs:439:12 +unsupported call to ` as std::cmp::PartialEq>::eq` at fixtures/reject/src/lib.rs:446:2 +overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:154:2 +an iterator of the crate implementing `DoubleEndedIterator`, which is not supported yet at fixtures/reject/src/lib.rs:174:1 +overriding `Iterator::size_hint`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:208:2 +an iterator of the crate implementing `FusedIterator`, which is not supported yet at fixtures/reject/src/lib.rs:228:1 +`Hasher::write`, which is not supported yet at fixtures/reject/src/lib.rs:319:9 diff --git a/ts/fixtures/reject/src/lib.rs b/ts/fixtures/reject/src/lib.rs index 68cdbd1e6..2e34023bc 100644 --- a/ts/fixtures/reject/src/lib.rs +++ b/ts/fixtures/reject/src/lib.rs @@ -38,11 +38,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. @@ -370,26 +372,17 @@ 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)) + v.into_iter().for_each(move |x| assert!(x.0 != (&a).0)); } -/// Each drops its closure, and the `Noisy` it owns, when it is done with it, as -/// `successors` does the item it holds next. +/// `successors` holds the item it yields next, which `rt.iterSuccessors` would not drop. 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 + std::iter::successors(Some(Noisy(4)), |_| None).count() } /// A `Cow` is a JS string, which keeps no variant to match on or ask about. diff --git a/ts/fixtures/task/expected/core/option.ts b/ts/fixtures/task/expected/core/option.ts index 8ab57220e..226ff2e89 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_closure14(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 3f3c53038..feb8c54cd 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 % 8` 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), 8); 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 ece40ccd6..7a17e8d3b 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_closure14, 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,711 @@ 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 h!: Guard.Guard; + let i!: Guard.Guard; + let j!: Guard.Guard; + let _227!: Guard.Guard; + let items!: Guard.Guard[]; + let v5!: Guard.Guard[]; + let k!: Guard.Guard; + let l!: Guard.Guard; + let m!: Guard.Guard; + let _274!: Guard.Guard; + let _277!: Guard.Guard; + let n!: Guard.Guard; + let o!: Guard.Guard; + let map!: rt.BTreeMap; + let queue!: rt.VecDeque; + let _417!: boolean; + let _418!: boolean; + let _419!: boolean; + let _420!: boolean; + let _421!: boolean; + let _422!: boolean; + let _423!: boolean; + let _424!: boolean; + let _425!: boolean; + let _426!: boolean; + let _427!: boolean; + let _428!: boolean; + let _429!: boolean; + let _430!: boolean; + let _431!: boolean; + let _432!: boolean; + let _433!: boolean; + let _434!: boolean; + let unwind: number = 0; + try { + _434 = false; + _433 = false; + _432 = false; + _431 = false; + _430 = false; + _429 = false; + _428 = false; + _427 = false; + _426 = false; + _425 = false; + _424 = false; + _423 = false; + _422 = false; + _421 = false; + _420 = false; + _419 = false; + _418 = false; + _417 = 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 args22: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(id, f), (f: rt.Formatter) => rt.u8Display(point, f)]; + rt.panicFmt(["d", args22[0], " at ", args22[1]]); + } + }; + _434 = true; + a = guard(1); + unwind = 242; + v = []; + unwind = 211; + 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 = 242; + const _13: rt.Iter = rt.iterSlice(v, rt.drop); + _434 = 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 = 240; + _433 = 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.u32Display), (f: rt.Formatter) => rt.fmtOption(_41, f, rt.u32Display)]; + Log.note(log, rt.fmtFormat(["map ", args2[0], " ", args2[1]])); + _433 = false; + rt.drop(mapped); + b = guard(5); + unwind = 238; + _432 = true; + v2 = []; + unwind = 210; + 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 = 238; + const _55: rt.Iter = rt.iterSlice(v2, rt.drop); + _432 = 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 = 209; + const _75: Guard.Guard | rt.Done = iter.next(); + if (_75 === rt.DONE) { + break; + } + unwind = 208; + 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 = 209; + rt.drop(g); + } else { + unwind = 209; + rt.drop(g); + break; + } + } + unwind = 238; + rt.drop(iter); + _100 = guard(9); + unwind = 207; + _103 = guard(10); + unwind = 206; + const _106: Guard.Guard = guard(11); + unwind = 234; + _431 = true; + c = _100; + _430 = true; + d = _103; + _429 = true; + e = _106; + v3 = []; + unwind = 203; + 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 = 234; + const _112: rt.Iter = rt.iterSlice(v3, rt.drop); + _431 = 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); + _430 = 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); + _429 = 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 args24: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_173, f), (f: rt.Formatter) => rt.u32Display(_192, f)]; + Log.note(log, rt.fmtFormat(["inspect ", args24[0], " ", args24[1]])); + }, (): void => { + rt.drop(captured9); + }), rt.drop); + unwind = 232; + _428 = true; + const part2 = map$Option_Guard_u32_iterated_closure14(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.u32Display)]; + Log.note(log, rt.fmtFormat(["chained ", args6[0]])); + const part3 = map$Option_Guard_u32_iterated_closure14(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.u32Display)]; + Log.note(log, rt.fmtFormat(["chained ", args8[0]])); + _428 = false; + rt.drop(chained); + _169 = guard(16); + unwind = 202; + const _172: Guard.Guard = guard(17); + unwind = 229; + _427 = true; + f = _169; + _426 = true; + g2 = _172; + const v4: rt.u32[] = []; + unwind = 200; + v4.push(1); + v4.push(2); + v4.push(3); + unwind = 229; + const _177: rt.Iter = rt.iterSlice(v4); + _427 = 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); + })); + _426 = false; + const captured11 = g2; + flat = rt.iterFlatMap(_176, rt.closure((n5: rt.u32): rt.u32[] => { + const v6: rt.u32[] = []; + v6.push(n5); + const _83: rt.u32 = rt.u32Add(n5, Guard.id(captured11)); + v6.push(_83); + return v6; + }, (): void => { + rt.drop(captured11); + }), (value: rt.u32[]) => rt.iterSlice(value), true); + unwind = 227; + _425 = true; + const part4 = rt.iterToOption(flat.next()); + const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part4, f, rt.u32Display)]; + Log.note(log, rt.fmtFormat(["flat ", args10[0]])); + check(3); + _425 = false; + rt.drop(flat); + h = guard(18); + unwind = 225; + _424 = true; + const _210: rt.Iter = rt.iterSlice([1, 2, 3]); + _424 = false; + const captured12 = h; + const whiles: rt.u32[] = rt.iterToArray(rt.iterMapWhile(_210, rt.closure((_2: rt.u32): rt.u32 | undefined => { + const n6: rt.u32 = _2; + return rt.thenSome(n6 < 3, rt.u32Add(n6, Guard.id(captured12))); + }, (): void => { + rt.drop(captured12); + })), false, rt.drop); + unwind = 199; + const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(whiles, f, rt.u32Display)]; + Log.note(log, rt.fmtFormat(["map_while ", args12[0]])); + _227 = guard(19); + unwind = 198; + const _230: Guard.Guard = guard(20); + unwind = 222; + _423 = true; + i = _227; + _422 = true; + j = _230; + _423 = false; + const captured13 = check; + const captured14 = i; + const made: rt.usize = rt.ownedCount(rt.iterTake(rt.iterFromFn(rt.closure((): rt.u32 | undefined => { + captured13(4); + return Guard.id(captured14); + }, (): void => { + rt.drop(captured14); + })), 2), rt.drop); + _422 = false; + const captured15 = j; + const walked: rt.u32 = rt.iterSum(rt.iterSuccessors(1, rt.closure((_26: rt.u32): rt.u32 | undefined => { + const n7: rt.u32 = _26; + return rt.thenSome(n7 < 3, rt.u32Sub(rt.u32Add(rt.u32Add(n7, 1), Guard.id(captured15)), Guard.id(captured15))); + }, (): void => { + rt.drop(captured15); + })), rt.u32Add, 0, rt.drop); + const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(made, f), (f: rt.Formatter) => rt.u32Display(walked, f)]; + Log.note(log, rt.fmtFormat(["lazy ", args14[0], " ", args14[1]])); + v5 = []; + unwind = 196; + const _257: Guard.Guard = guard(21); + v5.push(_257); + const _262: Guard.Guard = guard(22); + v5.push(_262); + const _267: Guard.Guard = guard(23); + v5.push(_267); + unwind = 195; + items = v5; + _274 = guard(24); + unwind = 194; + _277 = guard(25); + unwind = 193; + const _280: Guard.Guard = guard(26); + unwind = 218; + _421 = true; + k = _274; + _420 = true; + l = _277; + _419 = true; + m = _280; + const _285: rt.Iter = rt.iterSlice(items); + _421 = false; + const captured16 = id; + const captured17 = check; + const captured18 = k; + const _288: (a0: Guard.Guard) => boolean = rt.closure((g10: Guard.Guard): boolean => { + if (Guard.id(g10) === rt.u32Add(captured16, 22)) { + captured17(5); + } + return Guard.id(g10) === Guard.id(captured18); + }, (): void => { + rt.drop(captured18); + }); + const any: boolean = rt.dropAfter(_288, () => rt.iterAny(_285, _288)); + const _292: rt.Iter = rt.iterSlice(items); + _420 = false; + const captured19 = l; + const _295: (a0: Guard.Guard) => boolean = rt.closure((g11: Guard.Guard): boolean => { + return Guard.id(g11) === rt.u32Sub(Guard.id(captured19), 3); + }, (): void => { + rt.drop(captured19); + }); + const found: rt.u32 | undefined = map$Option_Guard_u32_iterated_closure14(rt.dropAfter(_295, () => rt.iterFind(_292, _295)), (g12: Guard.Guard): rt.u32 => { + return Guard.id(g12); + }); + const _298: rt.Iter = rt.iterSlice(items); + _419 = false; + const captured20 = m; + const _301: (a0: Guard.Guard) => boolean = rt.closure((g13: Guard.Guard): boolean => { + return rt.u32Add(Guard.id(g13), 2) === Guard.id(captured20); + }, (): void => { + rt.drop(captured20); + }); + const atPos: rt.usize | undefined = rt.dropAfter(_301, () => rt.iterPosition(_298, _301)); + const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(any, f), (f: rt.Formatter) => rt.fmtOption(found, f, rt.u32Display), (f: rt.Formatter) => rt.fmtOption(atPos, f, rt.usizeDisplay)]; + Log.note(log, rt.fmtFormat(["found ", args16[0], " ", args16[1], " ", args16[2]])); + n = guard(27); + unwind = 216; + _418 = true; + const _321: rt.Iter = rt.iterSlice([1, 2, 3]); + _418 = false; + const captured21 = n; + const sum: rt.u32 = rt.iterSum(rt.iterMap(_321, rt.closure((_27: rt.u32): rt.u32 => { + return rt.u32Add(_27, Guard.id(captured21)); + }, (): void => { + rt.drop(captured21); + })), rt.u32Add, 0, rt.drop); + o = guard(28); + unwind = 214; + _417 = true; + const _329: rt.Iter = rt.iterSlice([1, 2]); + _417 = false; + const captured22 = o; + const _332: (a0: rt.u32) => void = rt.closure((_29: rt.u32): void => { + const part5 = rt.u32Add(_29, Guard.id(captured22)); + const args26: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(part5, f)]; + Log.note(log, rt.fmtFormat(["each ", args26[0]])); + }, (): void => { + rt.drop(captured22); + }); + rt.dropAfter(_332, () => rt.iterForEach(_329, _332)); + const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(sum, f)]; + Log.note(log, rt.fmtFormat(["sum ", args18[0]])); + map = rt.btreeNew(rt.cmp) as rt.BTreeMap; + unwind = 190; + 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 = 189; + const _350: [rt.u32, rt.u32] | rt.Done = iter2.next(); + if (_350 === rt.DONE) { + break; + } + const k2: rt.u32 = _350[0]; + const _357: Guard.Guard = guard(_350[1]); + rt.drop(rt.btreeInsert(map, k2, _357, undefined, rt.drop)); + } + unwind = 190; + const p: Guard.Guard = guard(32); + const captured23 = check; + const captured24 = p; + const captured25 = id; + const _365: (a0: rt.u32, a1: Guard.Guard) => boolean = rt.closure((_214: rt.u32, _326: Guard.Guard): boolean => { + const k3: rt.u32 = _214; + if (k3 === 2) { + captured23(6); + } + return rt.u32Add(k3, Guard.id(captured24)) !== rt.u32Add(captured25, 34); + }, (): void => { + rt.drop(captured24); + }); + rt.dropAfter(_365, () => rt.btreeRetain(map, _365, undefined, rt.drop)); + queue = rt.dequeNew() as rt.VecDeque; + unwind = 188; + const _369: Guard.Guard = guard(33); + rt.dequePushBack(queue, _369); + const _374: Guard.Guard = guard(34); + rt.dequePushBack(queue, _374); + const captured26 = guard(35); + const _382: (a0: Guard.Guard) => boolean = rt.closure((g14: Guard.Guard): boolean => { + return rt.u32Add(Guard.id(g14), 2) !== Guard.id(captured26); + }, (): void => { + rt.drop(captured26); + }); + rt.dropAfter(_382, () => rt.dequeRetain(queue, _382, rt.drop)); + const _389: rt.usize = rt.btreeLen(map); + const _392: rt.usize = queue.n; + const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(_389, f), (f: rt.Formatter) => rt.usizeDisplay(_392, f)]; + Log.note(log, rt.fmtFormat(["retained ", args20[0], " ", args20[1]])); + check(7); + unwind = 190; + rt.dequeDrop(queue, rt.drop); + unwind = 214; + rt.btreeDrop(map, undefined, rt.drop); + unwind = 222; + _417 = false; + _418 = false; + _419 = false; + _420 = false; + _421 = false; + rt.dropAll(items); + _422 = false; + _423 = false; + _424 = false; + _425 = false; + _426 = false; + _427 = false; + _428 = false; + _429 = false; + _430 = false; + _431 = false; + _432 = false; + _433 = false; + _434 = false; + } catch (e2) { + b4: { + b5: { + b6: { + b7: { + b8: { + b9: { + b10: { + b11: { + b12: { + b13: { + b14: { + b15: { + b16: { + b17: { + b18: { + b19: { + b20: { + if (unwind === 0) { + throw e2; + } + if (unwind === 188) { + rt.dequeDrop(queue, rt.drop); + break b18; + } + if (unwind === 189) { + break b18; + } + if (unwind === 190) { + break b18; + } + if (unwind === 193) { + rt.drop(_277); + break b19; + } + if (unwind === 194) { + break b19; + } + if (unwind === 195) { + break b14; + } + if (unwind === 196) { + rt.dropAll(v5); + break b13; + } + if (unwind === 198) { + rt.drop(_227); + break b12; + } + if (unwind === 199) { + break b12; + } + if (unwind === 200) { + break b9; + } + if (unwind === 202) { + rt.drop(_169); + break b8; + } + if (unwind === 203) { + rt.dropAll(v3); + break b7; + } + if (unwind === 206) { + rt.drop(_103); + break b20; + } + if (unwind === 207) { + break b20; + } + if (unwind === 208) { + rt.drop(g); + } else if (unwind !== 209) { + if (unwind === 210) { + rt.dropAll(v2); + break b6; + } + if (unwind === 211) { + rt.dropAll(v); + break b4; + } + if (unwind === 214) { + break b17; + } + if (unwind === 216) { + break b16; + } + if (unwind === 218) { + break b15; + } + if (unwind === 222) { + break b13; + } + if (unwind === 225) { + break b11; + } + if (unwind === 227) { + break b10; + } + if (unwind === 229) { + break b9; + } + if (unwind === 232) { + break b8; + } + if (unwind === 234) { + break b7; + } + if (unwind === 238) { + break b6; + } + if (unwind === 240) { + break b5; + } + break b4; + } + rt.drop(iter); + break b6; + } + rt.drop(_100); + break b6; + } + rt.drop(_274); + break b14; + } + rt.btreeDrop(map, undefined, rt.drop); + } + if (_417) { + rt.drop(o); + } + } + if (_418) { + rt.drop(n); + } + } + if (_419) { + rt.drop(m); + } + if (_420) { + rt.drop(l); + } + if (_421) { + rt.drop(k); + } + } + rt.dropAll(items); + } + if (_422) { + rt.drop(j); + } + if (_423) { + rt.drop(i); + } + } + } + if (_424) { + rt.drop(h); + } + } + if (_425) { + rt.drop(flat); + } + } + if (_426) { + rt.drop(g2); + } + if (_427) { + rt.drop(f); + } + } + if (_428) { + rt.drop(chained); + } + } + if (_429) { + rt.drop(e); + } + if (_430) { + rt.drop(d); + } + if (_431) { + rt.drop(c); + } + } + if (_432) { + rt.drop(b); + } + } + if (_433) { + rt.drop(mapped); + } + } + if (_434) { + 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..94cc23563 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 % 8` 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 % 8; 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..21e303cb8 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,116 @@ 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); + 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(); + log.note(format!("lazy {made} {walked}")); + // 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}")); + // 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())); + check(7); +} + /// 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 96a292a87..1dba77ff3 100644 --- a/ts/runtime/rt/iter.ts +++ b/ts/runtime/rt/iter.ts @@ -82,6 +82,23 @@ abstract class Adaptor extends Iter implements Disposable { } } +/** An adaptor of `inner` that calls `f`, which drops after it, as std's fields do. */ +abstract class Calling extends Adaptor { + protected readonly f: F; + + constructor(inner: Iter, f: F) { + super(inner); + this.f = f; + } + + override [Symbol.dispose](): void { + 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 { @@ -123,22 +140,26 @@ 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. */ +/** + * `iter::successors`: `first`, then `succ` of each item, called as that item is yielded. + * `succ` drops with it, and the item it holds next, of a type that drops nothing, needn't. + */ export function iterSuccessors(first: T | undefined, succ: (item: T) => T | undefined): Iter { let next = first; - return iterFromFn(() => { + const step = (succ: (item: T) => T | undefined): T | Done => { const item = next; - if (item === undefined) return undefined; + if (item === undefined) return DONE; // Taken before `succ` runs, so a panic in it leaves the iterator done, as std's. next = undefined; next = succ(item); return item; - }); + }; + return new FromNext(succ, step, dispose); } /** An `impl Iterator` of the translated crate, which `next` calls the `next` of, and `drop` drops. */ @@ -1313,12 +1334,10 @@ class Borrowed extends Iter { } } -class MapIter extends Adaptor { - private 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 { @@ -1336,13 +1355,11 @@ class MapIter extends Adaptor { } } -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; } @@ -1355,12 +1372,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 { @@ -1690,14 +1705,12 @@ class OwnedTake extends TakeIter { } } -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; } @@ -1716,14 +1729,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; } @@ -1739,12 +1750,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 { @@ -1810,13 +1819,11 @@ class OwnedStepBy extends StepByIter { } } -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 b7c3b2828..96f8573c2 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 1931aa134..a1cbf600e 100644 --- a/ts/src/lower/iter.rs +++ b/ts/src/lower/iter.rs @@ -563,6 +563,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 @@ -595,9 +613,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()) @@ -634,6 +664,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 f8da3d846..9d2038e35 100644 --- a/ts/src/lower/library.rs +++ b/ts/src/lower/library.rs @@ -475,22 +475,37 @@ fn discards(owner: &str, name: &str) -> Option<&'static [usize]> { }) } -/// 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 sig = tcx.instantiate_bound_regions_with_erased(sig); + let inputs = sig.inputs().to_vec(); + let output = sig.output(); let bounds = tcx.param_env(call.def_id).caller_bounds(); - for (i, input) in inputs.into_iter().enumerate() { + for (i, &input) in inputs.iter().enumerate() { let ty::Param(param) = *input.kind() else { continue; }; @@ -515,12 +530,30 @@ fn called_closures<'tcx>( 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() { @@ -528,10 +561,11 @@ fn called_closures<'tcx>( args[i] = Expr::rt("once", vec![f]); } } - None + closures } -/// The first type `call` takes by value that drops. +/// The first type `call` takes by value that drops, but for a closure, which +/// `called_closures` decides. fn dropping_operand<'tcx>(b: &mut Body<'_, '_, 'tcx>, call: &Call<'tcx>) -> Option> { let tcx = b.t.tcx; let sig = tcx.fn_sig(call.def_id).instantiate(tcx, call.args).skip_norm_wip(); @@ -546,7 +580,9 @@ 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)) + inputs + .into_iter() + .find(|&ty| !matches!(ty.kind(), ty::Closure(..)) && b.t.drops(ty)) } /// `owner::name` for a standard library function. @@ -592,9 +628,9 @@ pub fn call<'tcx>(b: &mut Body<'_, '_, 'tcx>, call: &Call<'tcx>, args: Vec let (owner, name) = key(tcx, call.def_id)?; 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!( @@ -602,6 +638,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..b8b2603b3 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: 184 }, (_, arg) => [11, arg]), ].map((script) => Uint8Array.from(script)); From a754a95121793b2ccff4d778d7f958241222501d Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Tue, 27 Oct 2026 19:26:09 -0700 Subject: [PATCH 3/7] test(ts): drop a max_by_key's closure after the items it made Co-Authored-By: Claude Opus 5.5 --- ts/fixtures/task/expected/drops/closures.ts | 585 +++++++++++--------- ts/fixtures/task/src/drops/closures.rs | 10 +- 2 files changed, 325 insertions(+), 270 deletions(-) diff --git a/ts/fixtures/task/expected/drops/closures.ts b/ts/fixtures/task/expected/drops/closures.ts index 7a17e8d3b..80c6133db 100644 --- a/ts/fixtures/task/expected/drops/closures.ts +++ b/ts/fixtures/task/expected/drops/closures.ts @@ -1083,69 +1083,72 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { let _277!: Guard.Guard; let n!: Guard.Guard; let o!: Guard.Guard; + let r!: Guard.Guard; let map!: rt.BTreeMap; let queue!: rt.VecDeque; - let _417!: boolean; - let _418!: boolean; - let _419!: boolean; - let _420!: boolean; - let _421!: boolean; - let _422!: boolean; - let _423!: boolean; - let _424!: boolean; - let _425!: boolean; - let _426!: boolean; - let _427!: boolean; - let _428!: boolean; - let _429!: boolean; - let _430!: boolean; - let _431!: boolean; - let _432!: boolean; - let _433!: boolean; - let _434!: boolean; + let _437!: boolean; + let _438!: boolean; + let _439!: boolean; + let _440!: boolean; + let _441!: boolean; + let _442!: boolean; + let _443!: boolean; + let _444!: boolean; + let _445!: boolean; + let _446!: boolean; + let _447!: boolean; + let _448!: boolean; + let _449!: boolean; + let _450!: boolean; + let _451!: boolean; + let _452!: boolean; + let _453!: boolean; + let _454!: boolean; + let _455!: boolean; let unwind: number = 0; try { - _434 = false; - _433 = false; - _432 = false; - _431 = false; - _430 = false; - _429 = false; - _428 = false; - _427 = false; - _426 = false; - _425 = false; - _424 = false; - _423 = false; - _422 = false; - _421 = false; - _420 = false; - _419 = false; - _418 = false; - _417 = false; + _455 = false; + _454 = false; + _453 = false; + _452 = false; + _451 = false; + _450 = false; + _449 = false; + _448 = false; + _447 = false; + _446 = false; + _445 = false; + _444 = false; + _443 = false; + _442 = false; + _441 = false; + _440 = false; + _439 = false; + _438 = false; + _437 = 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 args22: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(id, f), (f: rt.Formatter) => rt.u8Display(point, f)]; - rt.panicFmt(["d", args22[0], " at ", args22[1]]); + const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(id, f), (f: rt.Formatter) => rt.u8Display(point, f)]; + rt.panicFmt(["d", args24[0], " at ", args24[1]]); } }; - _434 = true; + _455 = true; a = guard(1); - unwind = 242; + unwind = 253; v = []; - unwind = 211; + unwind = 220; 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 = 242; + unwind = 253; const _13: rt.Iter = rt.iterSlice(v, rt.drop); - _434 = false; + _455 = false; const captured = id; const captured2 = check; const captured3 = a; @@ -1170,28 +1173,28 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured3); })); - unwind = 240; - _433 = true; + unwind = 251; + _454 = 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.u32Display), (f: rt.Formatter) => rt.fmtOption(_41, f, rt.u32Display)]; Log.note(log, rt.fmtFormat(["map ", args2[0], " ", args2[1]])); - _433 = false; + _454 = false; rt.drop(mapped); b = guard(5); - unwind = 238; - _432 = true; + unwind = 249; + _453 = true; v2 = []; - unwind = 210; + unwind = 219; 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 = 238; + unwind = 249; const _55: rt.Iter = rt.iterSlice(v2, rt.drop); - _432 = false; + _453 = false; const captured4 = b; iter = rt.iterFilter(_55, rt.closure((g4: Guard.Guard): boolean => { return Guard.id(g4) !== rt.u32Add(Guard.id(captured4), 1); @@ -1199,41 +1202,41 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { rt.drop(captured4); }), rt.drop); while (true) { - unwind = 209; + unwind = 218; const _75: Guard.Guard | rt.Done = iter.next(); if (_75 === rt.DONE) { break; } - unwind = 208; + unwind = 217; 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 = 209; + unwind = 218; rt.drop(g); } else { - unwind = 209; + unwind = 218; rt.drop(g); break; } } - unwind = 238; + unwind = 249; rt.drop(iter); _100 = guard(9); - unwind = 207; + unwind = 216; _103 = guard(10); - unwind = 206; + unwind = 215; const _106: Guard.Guard = guard(11); - unwind = 234; - _431 = true; + unwind = 245; + _452 = true; c = _100; - _430 = true; + _451 = true; d = _103; - _429 = true; + _450 = true; e = _106; v3 = []; - unwind = 203; + unwind = 212; const _117: Guard.Guard = guard(12); v3.push(_117); const _122: Guard.Guard = guard(13); @@ -1242,23 +1245,23 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { v3.push(_127); const _132: Guard.Guard = guard(15); v3.push(_132); - unwind = 234; + unwind = 245; const _112: rt.Iter = rt.iterSlice(v3, rt.drop); - _431 = false; + _452 = 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); - _430 = false; + _451 = 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); - _429 = false; + _450 = false; const captured7 = id; const captured8 = check; const captured9 = e; @@ -1268,13 +1271,13 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { } const _173: rt.u32 = Guard.id(g7); const _192: rt.u32 = Guard.id(captured9); - const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_173, f), (f: rt.Formatter) => rt.u32Display(_192, f)]; - Log.note(log, rt.fmtFormat(["inspect ", args24[0], " ", args24[1]])); + const args26: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_173, f), (f: rt.Formatter) => rt.u32Display(_192, f)]; + Log.note(log, rt.fmtFormat(["inspect ", args26[0], " ", args26[1]])); }, (): void => { rt.drop(captured9); }), rt.drop); - unwind = 232; - _428 = true; + unwind = 243; + _449 = true; const part2 = map$Option_Guard_u32_iterated_closure14(rt.iterToOption(chained.next()), (g8: Guard.Guard): rt.u32 => { let unwind3: number = 0; try { @@ -1311,31 +1314,31 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }); const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part3, f, rt.u32Display)]; Log.note(log, rt.fmtFormat(["chained ", args8[0]])); - _428 = false; + _449 = false; rt.drop(chained); _169 = guard(16); - unwind = 202; + unwind = 211; const _172: Guard.Guard = guard(17); - unwind = 229; - _427 = true; + unwind = 240; + _448 = true; f = _169; - _426 = true; + _447 = true; g2 = _172; const v4: rt.u32[] = []; - unwind = 200; + unwind = 209; v4.push(1); v4.push(2); v4.push(3); - unwind = 229; + unwind = 240; const _177: rt.Iter = rt.iterSlice(v4); - _427 = false; + _448 = 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); })); - _426 = false; + _447 = false; const captured11 = g2; flat = rt.iterFlatMap(_176, rt.closure((n5: rt.u32): rt.u32[] => { const v6: rt.u32[] = []; @@ -1346,19 +1349,19 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured11); }), (value: rt.u32[]) => rt.iterSlice(value), true); - unwind = 227; - _425 = true; + unwind = 238; + _446 = true; const part4 = rt.iterToOption(flat.next()); const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part4, f, rt.u32Display)]; Log.note(log, rt.fmtFormat(["flat ", args10[0]])); check(3); - _425 = false; + _446 = false; rt.drop(flat); h = guard(18); - unwind = 225; - _424 = true; + unwind = 236; + _445 = true; const _210: rt.Iter = rt.iterSlice([1, 2, 3]); - _424 = false; + _445 = false; const captured12 = h; const whiles: rt.u32[] = rt.iterToArray(rt.iterMapWhile(_210, rt.closure((_2: rt.u32): rt.u32 | undefined => { const n6: rt.u32 = _2; @@ -1366,18 +1369,18 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured12); })), false, rt.drop); - unwind = 199; + unwind = 208; const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(whiles, f, rt.u32Display)]; Log.note(log, rt.fmtFormat(["map_while ", args12[0]])); _227 = guard(19); - unwind = 198; + unwind = 207; const _230: Guard.Guard = guard(20); - unwind = 222; - _423 = true; + unwind = 233; + _444 = true; i = _227; - _422 = true; + _443 = true; j = _230; - _423 = false; + _444 = false; const captured13 = check; const captured14 = i; const made: rt.usize = rt.ownedCount(rt.iterTake(rt.iterFromFn(rt.closure((): rt.u32 | undefined => { @@ -1386,7 +1389,7 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured14); })), 2), rt.drop); - _422 = false; + _443 = false; const captured15 = j; const walked: rt.u32 = rt.iterSum(rt.iterSuccessors(1, rt.closure((_26: rt.u32): rt.u32 | undefined => { const n7: rt.u32 = _26; @@ -1397,29 +1400,29 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(made, f), (f: rt.Formatter) => rt.u32Display(walked, f)]; Log.note(log, rt.fmtFormat(["lazy ", args14[0], " ", args14[1]])); v5 = []; - unwind = 196; + unwind = 205; const _257: Guard.Guard = guard(21); v5.push(_257); const _262: Guard.Guard = guard(22); v5.push(_262); const _267: Guard.Guard = guard(23); v5.push(_267); - unwind = 195; + unwind = 204; items = v5; _274 = guard(24); - unwind = 194; + unwind = 203; _277 = guard(25); - unwind = 193; + unwind = 202; const _280: Guard.Guard = guard(26); - unwind = 218; - _421 = true; + unwind = 229; + _442 = true; k = _274; - _420 = true; + _441 = true; l = _277; - _419 = true; + _440 = true; m = _280; const _285: rt.Iter = rt.iterSlice(items); - _421 = false; + _442 = false; const captured16 = id; const captured17 = check; const captured18 = k; @@ -1433,7 +1436,7 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }); const any: boolean = rt.dropAfter(_288, () => rt.iterAny(_285, _288)); const _292: rt.Iter = rt.iterSlice(items); - _420 = false; + _441 = false; const captured19 = l; const _295: (a0: Guard.Guard) => boolean = rt.closure((g11: Guard.Guard): boolean => { return Guard.id(g11) === rt.u32Sub(Guard.id(captured19), 3); @@ -1444,7 +1447,7 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { return Guard.id(g12); }); const _298: rt.Iter = rt.iterSlice(items); - _419 = false; + _440 = false; const captured20 = m; const _301: (a0: Guard.Guard) => boolean = rt.closure((g13: Guard.Guard): boolean => { return rt.u32Add(Guard.id(g13), 2) === Guard.id(captured20); @@ -1455,10 +1458,10 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(any, f), (f: rt.Formatter) => rt.fmtOption(found, f, rt.u32Display), (f: rt.Formatter) => rt.fmtOption(atPos, f, rt.usizeDisplay)]; Log.note(log, rt.fmtFormat(["found ", args16[0], " ", args16[1], " ", args16[2]])); n = guard(27); - unwind = 216; - _418 = true; + unwind = 227; + _439 = true; const _321: rt.Iter = rt.iterSlice([1, 2, 3]); - _418 = false; + _439 = false; const captured21 = n; const sum: rt.u32 = rt.iterSum(rt.iterMap(_321, rt.closure((_27: rt.u32): rt.u32 => { return rt.u32Add(_27, Guard.id(captured21)); @@ -1466,91 +1469,127 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { rt.drop(captured21); })), rt.u32Add, 0, rt.drop); o = guard(28); - unwind = 214; - _417 = true; + unwind = 225; + _438 = true; const _329: rt.Iter = rt.iterSlice([1, 2]); - _417 = false; + _438 = false; const captured22 = o; const _332: (a0: rt.u32) => void = rt.closure((_29: rt.u32): void => { const part5 = rt.u32Add(_29, Guard.id(captured22)); - const args26: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(part5, f)]; - Log.note(log, rt.fmtFormat(["each ", args26[0]])); + const args28: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(part5, f)]; + Log.note(log, rt.fmtFormat(["each ", args28[0]])); }, (): void => { rt.drop(captured22); }); rt.dropAfter(_332, () => rt.iterForEach(_329, _332)); const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(sum, f)]; Log.note(log, rt.fmtFormat(["sum ", args18[0]])); + r = guard(36); + unwind = 223; + _437 = true; + const _347: rt.Iter = rt.iterMap(rt.iterSlice([1, 2, 3]), (_214: rt.u32): Guard.Guard => { + return guard(rt.u32Add(36, _214)); + }); + _437 = false; + const captured23 = id; + const captured24 = check; + const captured25 = r; + const _353: (a0: Guard.Guard) => rt.u32 = rt.closure((g14: Guard.Guard): rt.u32 => { + if (Guard.id(g14) === rt.u32Add(captured23, 38)) { + captured24(7); + } + return rt.u32Add(rt.u32Rem(Guard.id(g14), 2), Guard.id(captured25)); + }, (): void => { + rt.drop(captured25); + }); + const part7 = map$Option_Guard_u32_iterated_closure14(rt.dropAfter(_353, () => rt.iterMaxByKey(_347, _353, undefined, rt.drop)), (g15: Guard.Guard): rt.u32 => { + let unwind5: number = 0; + try { + unwind5 = 4; + const _020: rt.u32 = Guard.id(g15); + unwind5 = 0; + rt.drop(g15); + return _020; + } catch (e6) { + if (unwind5 === 0) { + throw e6; + } + rt.drop(g15); + throw e6; + } + }); + const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part7, f, rt.u32Display)]; + Log.note(log, rt.fmtFormat(["best ", args20[0]])); map = rt.btreeNew(rt.cmp) as rt.BTreeMap; - unwind = 190; + unwind = 199; 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 = 189; - const _350: [rt.u32, rt.u32] | rt.Done = iter2.next(); - if (_350 === rt.DONE) { + unwind = 198; + const _372: [rt.u32, rt.u32] | rt.Done = iter2.next(); + if (_372 === rt.DONE) { break; } - const k2: rt.u32 = _350[0]; - const _357: Guard.Guard = guard(_350[1]); - rt.drop(rt.btreeInsert(map, k2, _357, undefined, rt.drop)); + const k2: rt.u32 = _372[0]; + const _379: Guard.Guard = guard(_372[1]); + rt.drop(rt.btreeInsert(map, k2, _379, undefined, rt.drop)); } - unwind = 190; + unwind = 199; const p: Guard.Guard = guard(32); - const captured23 = check; - const captured24 = p; - const captured25 = id; - const _365: (a0: rt.u32, a1: Guard.Guard) => boolean = rt.closure((_214: rt.u32, _326: Guard.Guard): boolean => { - const k3: rt.u32 = _214; + const captured26 = check; + const captured27 = p; + const captured28 = id; + const _387: (a0: rt.u32, a1: Guard.Guard) => boolean = rt.closure((_218: rt.u32, _328: Guard.Guard): boolean => { + const k3: rt.u32 = _218; if (k3 === 2) { - captured23(6); + captured26(6); } - return rt.u32Add(k3, Guard.id(captured24)) !== rt.u32Add(captured25, 34); + return rt.u32Add(k3, Guard.id(captured27)) !== rt.u32Add(captured28, 34); }, (): void => { - rt.drop(captured24); + rt.drop(captured27); }); - rt.dropAfter(_365, () => rt.btreeRetain(map, _365, undefined, rt.drop)); + rt.dropAfter(_387, () => rt.btreeRetain(map, _387, undefined, rt.drop)); queue = rt.dequeNew() as rt.VecDeque; - unwind = 188; - const _369: Guard.Guard = guard(33); - rt.dequePushBack(queue, _369); - const _374: Guard.Guard = guard(34); - rt.dequePushBack(queue, _374); - const captured26 = guard(35); - const _382: (a0: Guard.Guard) => boolean = rt.closure((g14: Guard.Guard): boolean => { - return rt.u32Add(Guard.id(g14), 2) !== Guard.id(captured26); + unwind = 197; + const _391: Guard.Guard = guard(33); + rt.dequePushBack(queue, _391); + const _396: Guard.Guard = guard(34); + rt.dequePushBack(queue, _396); + const captured29 = guard(35); + const _404: (a0: Guard.Guard) => boolean = rt.closure((g16: Guard.Guard): boolean => { + return rt.u32Add(Guard.id(g16), 2) !== Guard.id(captured29); }, (): void => { - rt.drop(captured26); + rt.drop(captured29); }); - rt.dropAfter(_382, () => rt.dequeRetain(queue, _382, rt.drop)); - const _389: rt.usize = rt.btreeLen(map); - const _392: rt.usize = queue.n; - const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(_389, f), (f: rt.Formatter) => rt.usizeDisplay(_392, f)]; - Log.note(log, rt.fmtFormat(["retained ", args20[0], " ", args20[1]])); - check(7); - unwind = 190; + rt.dropAfter(_404, () => rt.dequeRetain(queue, _404, rt.drop)); + const _411: rt.usize = rt.btreeLen(map); + const _414: rt.usize = queue.n; + const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(_411, f), (f: rt.Formatter) => rt.usizeDisplay(_414, f)]; + Log.note(log, rt.fmtFormat(["retained ", args22[0], " ", args22[1]])); + unwind = 199; rt.dequeDrop(queue, rt.drop); - unwind = 214; + unwind = 223; rt.btreeDrop(map, undefined, rt.drop); - unwind = 222; - _417 = false; - _418 = false; - _419 = false; - _420 = false; - _421 = false; + unwind = 233; + _437 = false; + _438 = false; + _439 = false; + _440 = false; + _441 = false; + _442 = false; rt.dropAll(items); - _422 = false; - _423 = false; - _424 = false; - _425 = false; - _426 = false; - _427 = false; - _428 = false; - _429 = false; - _430 = false; - _431 = false; - _432 = false; - _433 = false; - _434 = false; + _443 = false; + _444 = false; + _445 = false; + _446 = false; + _447 = false; + _448 = false; + _449 = false; + _450 = false; + _451 = false; + _452 = false; + _453 = false; + _454 = false; + _455 = false; } catch (e2) { b4: { b5: { @@ -1569,181 +1608,189 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { b18: { b19: { b20: { - if (unwind === 0) { - throw e2; - } - if (unwind === 188) { - rt.dequeDrop(queue, rt.drop); - break b18; - } - if (unwind === 189) { - break b18; - } - if (unwind === 190) { - break b18; - } - if (unwind === 193) { - rt.drop(_277); - break b19; - } - if (unwind === 194) { - break b19; - } - if (unwind === 195) { - break b14; - } - if (unwind === 196) { - rt.dropAll(v5); - break b13; - } - if (unwind === 198) { - rt.drop(_227); - break b12; - } - if (unwind === 199) { - break b12; - } - if (unwind === 200) { - break b9; - } - if (unwind === 202) { - rt.drop(_169); - break b8; - } - if (unwind === 203) { - rt.dropAll(v3); - break b7; - } - if (unwind === 206) { - rt.drop(_103); - break b20; - } - if (unwind === 207) { - break b20; - } - if (unwind === 208) { - rt.drop(g); - } else if (unwind !== 209) { - if (unwind === 210) { - rt.dropAll(v2); - break b6; + b21: { + if (unwind === 0) { + throw e2; } - if (unwind === 211) { - rt.dropAll(v); - break b4; + if (unwind === 197) { + rt.dequeDrop(queue, rt.drop); + break b19; } - if (unwind === 214) { - break b17; + if (unwind === 198) { + break b19; } - if (unwind === 216) { - break b16; + if (unwind === 199) { + break b19; + } + if (unwind === 202) { + rt.drop(_277); + break b20; } - if (unwind === 218) { - break b15; + if (unwind === 203) { + break b20; } - if (unwind === 222) { + if (unwind === 204) { + break b14; + } + if (unwind === 205) { + rt.dropAll(v5); break b13; } - if (unwind === 225) { - break b11; + if (unwind === 207) { + rt.drop(_227); + break b12; } - if (unwind === 227) { - break b10; + if (unwind === 208) { + break b12; } - if (unwind === 229) { + if (unwind === 209) { break b9; } - if (unwind === 232) { + if (unwind === 211) { + rt.drop(_169); break b8; } - if (unwind === 234) { + if (unwind === 212) { + rt.dropAll(v3); break b7; } - if (unwind === 238) { - break b6; + if (unwind === 215) { + rt.drop(_103); + break b21; } - if (unwind === 240) { - break b5; + if (unwind === 216) { + break b21; + } + if (unwind === 217) { + rt.drop(g); + } else if (unwind !== 218) { + if (unwind === 219) { + rt.dropAll(v2); + break b6; + } + if (unwind === 220) { + rt.dropAll(v); + break b4; + } + if (unwind === 223) { + break b18; + } + if (unwind === 225) { + break b17; + } + if (unwind === 227) { + break b16; + } + if (unwind === 229) { + break b15; + } + if (unwind === 233) { + break b13; + } + if (unwind === 236) { + break b11; + } + if (unwind === 238) { + break b10; + } + if (unwind === 240) { + break b9; + } + if (unwind === 243) { + break b8; + } + if (unwind === 245) { + break b7; + } + if (unwind === 249) { + break b6; + } + if (unwind === 251) { + break b5; + } + break b4; } - break b4; + rt.drop(iter); + break b6; } - rt.drop(iter); + rt.drop(_100); break b6; } - rt.drop(_100); - break b6; + rt.drop(_274); + break b14; } - rt.drop(_274); - break b14; + rt.btreeDrop(map, undefined, rt.drop); + } + if (_437) { + rt.drop(r); } - rt.btreeDrop(map, undefined, rt.drop); } - if (_417) { + if (_438) { rt.drop(o); } } - if (_418) { + if (_439) { rt.drop(n); } } - if (_419) { + if (_440) { rt.drop(m); } - if (_420) { + if (_441) { rt.drop(l); } - if (_421) { + if (_442) { rt.drop(k); } } rt.dropAll(items); } - if (_422) { + if (_443) { rt.drop(j); } - if (_423) { + if (_444) { rt.drop(i); } } } - if (_424) { + if (_445) { rt.drop(h); } } - if (_425) { + if (_446) { rt.drop(flat); } } - if (_426) { + if (_447) { rt.drop(g2); } - if (_427) { + if (_448) { rt.drop(f); } } - if (_428) { + if (_449) { rt.drop(chained); } } - if (_429) { + if (_450) { rt.drop(e); } - if (_430) { + if (_451) { rt.drop(d); } - if (_431) { + if (_452) { rt.drop(c); } } - if (_432) { + if (_453) { rt.drop(b); } } - if (_433) { + if (_454) { rt.drop(mapped); } } - if (_434) { + if (_455) { rt.drop(a); } throw e2; diff --git a/ts/fixtures/task/src/drops/closures.rs b/ts/fixtures/task/src/drops/closures.rs index 21e303cb8..aab6d427e 100644 --- a/ts/fixtures/task/src/drops/closures.rs +++ b/ts/fixtures/task/src/drops/closures.rs @@ -270,6 +270,15 @@ pub(super) fn iterated(log: &Log, id: u32, at: u8) { .iter() .for_each(move |&x| log.note(format!("each {}", x + o.id()))); log.note(format!("sum {sum}")); + // 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)] { @@ -288,7 +297,6 @@ pub(super) fn iterated(log: &Log, id: u32, at: u8) { let q = guard(35); queue.retain(move |g| g.id() + 2 != q.id()); log.note(format!("retained {} {}", map.len(), queue.len())); - check(7); } /// What drops of a closure's captures when one's `Drop` panics: the rest still drop, in From 1e737a0e0ee7ee86b25260b6b03d0e16779b6dd1 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Tue, 27 Oct 2026 19:33:27 -0700 Subject: [PATCH 4/7] feat(ts): drop the item successors holds next `rt.iterSuccessors` takes what drops its item and drops the one it holds next before its closure, as std's fields drop, and the item it passed to a closure that panics. This lifts the last `successors` refusal, so the reject fixture's `owning_lazy` goes. The task fixture's drop scenarios gain three panic points so `successors` panics at one of its own. Co-Authored-By: Claude Opus 5.5 --- quest/m2/ts-drop.md | 11 +- ts/fixtures/reject/census.md | 68 +- ts/fixtures/reject/expected.txt | 25 +- ts/fixtures/reject/src/lib.rs | 5 - ts/fixtures/reject/ts.toml | 1 - ts/fixtures/task/expected/core/option.ts | 2 +- ts/fixtures/task/expected/drops.ts | 4 +- ts/fixtures/task/expected/drops/closures.ts | 848 +++++++++++--------- ts/fixtures/task/src/drops.rs | 4 +- ts/fixtures/task/src/drops/closures.rs | 13 +- ts/runtime/rt/iter.ts | 52 +- ts/src/lower/iter.rs | 12 +- ts/tests/task.ts | 2 +- 13 files changed, 569 insertions(+), 478 deletions(-) diff --git a/quest/m2/ts-drop.md b/quest/m2/ts-drop.md index d18f5dac0..719464477 100644 --- a/quest/m2/ts-drop.md +++ b/quest/m2/ts-drop.md @@ -21,7 +21,8 @@ that takes an iterator by value takes `rt.drop` for it. A closure that owns a va 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). Given to std, an iterator adaptor holds it and drops it after its iterator, as std's fields do -(`iter::holds_closure`), and a function that calls it by `Fn` or `FnMut`, keeps nothing +(`iter::holds_closure`), as `successors` drops the item it holds next before its own, +and a function that calls it by `Fn` or `FnMut`, keeps nothing of it, and takes nothing else that drops by value drops it as it returns or unwinds (`rt.dropAfter`). The task fixture's `drops.rs`, `drops/iters.rs`, and `drops/closures.rs` check these against native Rust, natively unwinding too. @@ -39,13 +40,7 @@ after the half it yields, `next` before); `zip` of two `TrustedRandomAccess` ite 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. +whose second iterator drops; and `DebugList::entries` of items that drop. Watch the cost: a function whose cleanup does something JS can see sets a variable before each call that can panic and wraps its body in a `try`; measure any change on diff --git a/ts/fixtures/reject/census.md b/ts/fixtures/reject/census.md index 5d2b4f070..10162d6c7 100644 --- a/ts/fixtures/reject/census.md +++ b/ts/fixtures/reject/census.md @@ -1,7 +1,7 @@ # Census of `reject-fixture` -- Refusals: 80 -- Function instances: 72 +- Refusals: 79 +- Function instances: 71 - Generic functions no instance reached, lowered over their type parameters: 2 ## By construct @@ -10,7 +10,7 @@ | ---: | --- | --- | | 9 | unsupported call to `_` | fixtures/reject/src/lib.rs:28:4 | | 6 | `_` is not supported: its `None` and `Some` would both be `undefined` | fixtures/reject/src/lib.rs:23:15 | -| 4 | a variant of `_`, which is not supported: either is the same JS string | fixtures/reject/src/lib.rs:390:2 | +| 4 | a variant of `_`, which is not supported: either is the same JS string | fixtures/reject/src/lib.rs:385:2 | | 4 | an assignment through a reference to `_` | fixtures/reject/src/lib.rs:111: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 | @@ -27,7 +27,7 @@ | 1 | `Octal` formatting, as in `{:o}`, is not supported | fixtures/reject/src/lib.rs:73:3 | | 1 | `Pointer` formatting, as in `{:p}`, is not supported | fixtures/reject/src/lib.rs:77:3 | | 1 | `_` holds `_`, which is `undefined` as `None` is, which is not supported | fixtures/reject/src/lib.rs:288:6 | -| 1 | `_` is not supported yet | fixtures/reject/src/lib.rs:401:18 | +| 1 | `_` is not supported yet | fixtures/reject/src/lib.rs:396:18 | | 1 | `_` of `_` by `_`, which is not supported yet | fixtures/reject/src/lib.rs:311:6 | | 1 | `_` of `_`, which drops `_`, which is not supported yet | fixtures/reject/src/lib.rs:53:13 | | 1 | `_` of `_`, which folds a closure that drops beside what else drops, which is not supported yet | fixtures/reject/src/lib.rs:47:23 | @@ -41,16 +41,15 @@ | 1 | a constant of type `_` | fixtures/reject/src/lib.rs:90:2 | | 1 | a copy of a closure that changes what it captured | fixtures/reject/src/lib.rs:277:14 | | 1 | a mutable borrow of a subslice of `_`, which JS would copy, having no views | fixtures/reject/src/lib.rs:246:13 | -| 1 | a mutable reference into a `Result`'s payload, passed on or kept | fixtures/reject/src/lib.rs:439:12 | +| 1 | a mutable reference into a `Result`'s payload, passed on or kept | fixtures/reject/src/lib.rs:434:12 | | 1 | a precision, as in `{:.2}`, is not supported | fixtures/reject/src/lib.rs:69:3 | | 1 | a printable type must implement `Display` or `Debug` | fixtures/reject/src/lib.rs:102:1 | | 1 | a scalar constant of type `_` | fixtures/reject/src/lib.rs:8:2 | | 1 | a width or precision from an argument, as in `{:1$}`, is not supported | fixtures/reject/src/lib.rs:76:3 | | 1 | a zero-sized constant of type `_` | fixtures/reject/src/lib.rs:62:2 | -| 1 | an iterator that owns `_`, which drops, which is not supported yet | fixtures/reject/src/lib.rs:385:2 | | 1 | arithmetic on `_` | fixtures/reject/src/lib.rs:8:2 | | 1 | comparing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:293:52 | -| 1 | constructing `_` | fixtures/reject/src/lib.rs:408:53 | +| 1 | constructing `_` | fixtures/reject/src/lib.rs:403:53 | | 1 | hashing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:293:52 | | 1 | hex `Debug`, as in `{:x?}`, is not supported | fixtures/reject/src/lib.rs:75:3 | | 1 | the `+` flag of a format spec is not supported | fixtures/reject/src/lib.rs:70:3 | @@ -62,7 +61,7 @@ The type or module each refused type or path belongs to. | Count | API | First | | ---: | --- | --- | -| 7 | `std::borrow::Cow` | fixtures/reject/src/lib.rs:390:2 | +| 7 | `std::borrow::Cow` | fixtures/reject/src/lib.rs:385:2 | | 6 | `Option` | fixtures/reject/src/lib.rs:23:15 | | 6 | `f64` | fixtures/reject/src/lib.rs:7:14 | | 3 | `Iterator` | fixtures/reject/src/lib.rs:154:2 | @@ -71,7 +70,6 @@ The type or module each refused type or path belongs to. | 3 | `std::slice` | fixtures/reject/src/lib.rs:28:4 | | 3 | `std::sync::Arc` | fixtures/reject/src/lib.rs:111:2 | | 2 | `Meters` | fixtures/reject/src/lib.rs:95:2 | -| 2 | `Noisy` | fixtures/reject/src/lib.rs:53:13 | | 2 | `Poll` | fixtures/reject/src/lib.rs:115:20 | | 2 | `std::iter::Iterator` | fixtures/reject/src/lib.rs:267:16 | | 2 | `std::ops::Range` | fixtures/reject/src/lib.rs:195:8 | @@ -86,11 +84,12 @@ The type or module each refused type or path belongs to. | 1 | `HashMap` | fixtures/reject/src/lib.rs:311:6 | | 1 | `Hasher` | fixtures/reject/src/lib.rs:319:9 | | 1 | `IntToFloat` | fixtures/reject/src/lib.rs:106:2 | +| 1 | `Noisy` | fixtures/reject/src/lib.rs:53:13 | | 1 | `[u16; 1]` | fixtures/reject/src/lib.rs:260:22 | | 1 | `count` | fixtures/reject/src/lib.rs:47:23 | | 1 | `dyn std::ops::Fn(u8) -> u8` | fixtures/reject/src/lib.rs:11:16 | | 1 | `into_keys` | fixtures/reject/src/lib.rs:53:13 | -| 1 | `std::collections::hash_map::Entry` | fixtures/reject/src/lib.rs:429:15 | +| 1 | `std::collections::hash_map::Entry` | fixtures/reject/src/lib.rs:424:15 | | 1 | `std::iter::Chain` | fixtures/reject/src/lib.rs:187:51 | | 1 | `std::iter::Flatten` | fixtures/reject/src/lib.rs:236:26 | | 1 | `std::iter::IntoIterator` | fixtures/reject/src/lib.rs:17:2 | @@ -101,7 +100,7 @@ The type or module each refused type or path belongs to. | 1 | `std::str` | fixtures/reject/src/lib.rs:372:4 | | 1 | `std::string::String` | fixtures/reject/src/lib.rs:84:10 | | 1 | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:136:2 | -| 1 | `std::time::Duration` | fixtures/reject/src/lib.rs:416:2 | +| 1 | `std::time::Duration` | fixtures/reject/src/lib.rs:411:2 | | 1 | `u32` | fixtures/reject/src/lib.rs:246:13 | | 1 | `u64` | fixtures/reject/src/lib.rs:106:2 | | 1 | `{async closure}` | fixtures/reject/src/lib.rs:62:2 | @@ -111,22 +110,22 @@ The type or module each refused type or path belongs to. | Count | Construct | Type or path | First | | ---: | --- | --- | --- | | 6 | `_` is not supported: its `None` and `Some` would both be `undefined` | `Option` | fixtures/reject/src/lib.rs:23:15 | -| 4 | a variant of `_`, which is not supported: either is the same JS string | `std::borrow::Cow` | fixtures/reject/src/lib.rs:390:2 | +| 4 | a variant of `_`, which is not supported: either is the same JS string | `std::borrow::Cow` | fixtures/reject/src/lib.rs:385: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:115:20 | | 2 | an assignment through a reference to `_` | `std::pin::Pin` | fixtures/reject/src/lib.rs:131:2 | | 2 | replacing the value behind a reference to `_` | `Meters` | fixtures/reject/src/lib.rs:95:2 | | 1 | `_` holds `_`, which is `undefined` as `None` is, which is not supported | `std::collections::HashMap`, `std::option::Option` | fixtures/reject/src/lib.rs:288:6 | -| 1 | `_` is not supported yet | `std::borrow::Cow` | fixtures/reject/src/lib.rs:401:18 | +| 1 | `_` is not supported yet | `std::borrow::Cow` | fixtures/reject/src/lib.rs:396:18 | | 1 | `_` of `_` by `_`, which is not supported yet | `HashMap::contains_key`, `std::collections::HashMap`, `u8` | fixtures/reject/src/lib.rs:311:6 | | 1 | `_` of `_`, which drops `_`, which is not supported yet | `into_keys`, `std::collections::HashMap`, `Noisy` | fixtures/reject/src/lib.rs:53: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:47:23 | | 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:267: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:267:16 | | 1 | `_` through a held type's own, which is not supported yet | `::ne` | fixtures/reject/src/lib.rs:343: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:429:15 | +| 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:424: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:422:21 | +| 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::slice::last_mut` | fixtures/reject/src/lib.rs:417:21 | | 1 | `_`, which is not supported yet | `Hasher::write` | fixtures/reject/src/lib.rs:319: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:236:26 | | 1 | a `_` cast from `_` to `_` | `IntToFloat`, `u64`, `f64` | fixtures/reject/src/lib.rs:106:2 | @@ -143,10 +142,9 @@ The type or module each refused type or path belongs to. | 1 | an assignment through a reference to `_` | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:136:2 | | 1 | an iterator of the crate implementing `_`, which is not supported yet | `DoubleEndedIterator` | fixtures/reject/src/lib.rs:174:1 | | 1 | an iterator of the crate implementing `_`, which is not supported yet | `FusedIterator` | fixtures/reject/src/lib.rs:228:1 | -| 1 | an iterator that owns `_`, which drops, which is not supported yet | `Noisy` | fixtures/reject/src/lib.rs:385:2 | | 1 | arithmetic on `_` | `f64` | fixtures/reject/src/lib.rs:8:2 | | 1 | comparing `_` as a key, which is not supported yet | `std::vec::Vec` | fixtures/reject/src/lib.rs:293:52 | -| 1 | constructing `_` | `std::borrow::Cow` | fixtures/reject/src/lib.rs:408:53 | +| 1 | constructing `_` | `std::borrow::Cow` | fixtures/reject/src/lib.rs:403:53 | | 1 | constructing `_` from another crate | `std::iter::Map` | fixtures/reject/src/lib.rs:160:23 | | 1 | constructing `_` from another crate | `std::iter::Rev` | fixtures/reject/src/lib.rs:181:14 | | 1 | hashing `_` as a key, which is not supported yet | `std::vec::Vec` | fixtures/reject/src/lib.rs:293:52 | @@ -155,11 +153,11 @@ The type or module each refused type or path belongs to. | 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:379: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:380:16 | | 1 | replacing the value behind a reference to `_` | `[u16; 1]` | fixtures/reject/src/lib.rs:260:22 | -| 1 | unsupported call to `_` | `::deref` | fixtures/reject/src/lib.rs:402:2 | -| 1 | unsupported call to `_` | `::eq` | fixtures/reject/src/lib.rs:446:2 | +| 1 | unsupported call to `_` | `::deref` | fixtures/reject/src/lib.rs:397:2 | +| 1 | unsupported call to `_` | `::eq` | fixtures/reject/src/lib.rs:441:2 | | 1 | unsupported call to `_` | `::cycle` | fixtures/reject/src/lib.rs:141:11 | | 1 | unsupported call to `_` | `::write_fmt` | fixtures/reject/src/lib.rs:84:10 | -| 1 | unsupported call to `_` | `::add_assign` | fixtures/reject/src/lib.rs:416:2 | +| 1 | unsupported call to `_` | `::add_assign` | fixtures/reject/src/lib.rs:411:2 | | 1 | unsupported call to `_` | `std::ops::Range::contains` | fixtures/reject/src/lib.rs:195:8 | | 1 | unsupported call to `_` | `std::slice::copy_within` | fixtures/reject/src/lib.rs:361:4 | | 1 | unsupported call to `_` | `std::slice::sort` | fixtures/reject/src/lib.rs:28:4 | @@ -176,9 +174,9 @@ The type or module each refused type or path belongs to. - fixtures/reject/src/lib.rs:195:8: unsupported call to `std::ops::Range::::contains::` - fixtures/reject/src/lib.rs:361:4: unsupported call to `core::slice::::copy_within::>` - fixtures/reject/src/lib.rs:372:4: unsupported call to `core::str::::split::<[char; 2]>` -- fixtures/reject/src/lib.rs:402:2: unsupported call to ` as std::ops::Deref>::deref` -- fixtures/reject/src/lib.rs:416:2: unsupported call to `::add_assign` -- fixtures/reject/src/lib.rs:446:2: unsupported call to ` as std::cmp::PartialEq>::eq` +- fixtures/reject/src/lib.rs:397:2: unsupported call to ` as std::ops::Deref>::deref` +- fixtures/reject/src/lib.rs:411:2: unsupported call to `::add_assign` +- fixtures/reject/src/lib.rs:441:2: unsupported call to ` as std::cmp::PartialEq>::eq` @@ -195,10 +193,10 @@ The type or module each refused type or path belongs to.
a variant of `_`, which is not supported: either is the same JS string (4) -- fixtures/reject/src/lib.rs:390:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string -- fixtures/reject/src/lib.rs:391:30: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string -- fixtures/reject/src/lib.rs:392:27: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string -- fixtures/reject/src/lib.rs:397:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +- fixtures/reject/src/lib.rs:385:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +- fixtures/reject/src/lib.rs:386:30: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +- fixtures/reject/src/lib.rs:387:27: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +- fixtures/reject/src/lib.rs:392:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string
@@ -223,8 +221,8 @@ The type or module each refused type or path belongs to.
`_` 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:422:21: `core::slice::::last_mut` with a mutable reference to a value JS copies, which its mapping would copy -- fixtures/reject/src/lib.rs:429: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 +- fixtures/reject/src/lib.rs:417:21: `core::slice::::last_mut` with a mutable reference to a value JS copies, which its mapping would copy +- fixtures/reject/src/lib.rs:424: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
@@ -317,7 +315,7 @@ The type or module each refused type or path belongs to.
`_` is not supported yet (1) -- fixtures/reject/src/lib.rs:401:18: `std::borrow::Cow<'_, [u8]>` is not supported yet +- fixtures/reject/src/lib.rs:396:18: `std::borrow::Cow<'_, [u8]>` is not supported yet
@@ -401,7 +399,7 @@ The type or module each refused type or path belongs to.
a mutable reference into a `Result`'s payload, passed on or kept (1) -- fixtures/reject/src/lib.rs:439:12: a mutable reference into a `Result`'s payload, passed on or kept +- fixtures/reject/src/lib.rs:434:12: a mutable reference into a `Result`'s payload, passed on or kept
@@ -435,12 +433,6 @@ The type or module each refused type or path belongs to. -
an iterator that owns `_`, which drops, which is not supported yet (1) - -- fixtures/reject/src/lib.rs:385:2: an iterator that owns `Noisy`, which drops, which is not supported yet - -
-
arithmetic on `_` (1) - fixtures/reject/src/lib.rs:8:2: arithmetic on `f64` @@ -455,7 +447,7 @@ The type or module each refused type or path belongs to.
constructing `_` (1) -- fixtures/reject/src/lib.rs:408:53: constructing `std::borrow::Cow<'_, std::sync::Arc>` +- fixtures/reject/src/lib.rs:403:53: constructing `std::borrow::Cow<'_, std::sync::Arc>`
diff --git a/ts/fixtures/reject/expected.txt b/ts/fixtures/reject/expected.txt index e4f312a25..bad0cf3c5 100644 --- a/ts/fixtures/reject/expected.txt +++ b/ts/fixtures/reject/expected.txt @@ -57,22 +57,21 @@ comparing `std::vec::Vec` as a key, which is not supported yet at fixtures/r `HashMap::contains_key` of `std::collections::HashMap` by `u8`, which is not supported yet at fixtures/reject/src/lib.rs:311:6 unsupported call to `core::slice::::copy_within::>` at fixtures/reject/src/lib.rs:361:4 a coercion to `std::sync::Arc<[u8]>` at fixtures/reject/src/lib.rs:366:2 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:390:2 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:392:27 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:391:30 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:397:2 -`std::borrow::Cow<'_, [u8]>` is not supported yet at fixtures/reject/src/lib.rs:401:18 -unsupported call to ` as std::ops::Deref>::deref` at fixtures/reject/src/lib.rs:402:2 -constructing `std::borrow::Cow<'_, std::sync::Arc>` at fixtures/reject/src/lib.rs:408:53 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:385:2 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:387:27 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:386:30 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:392:2 +`std::borrow::Cow<'_, [u8]>` is not supported yet at fixtures/reject/src/lib.rs:396:18 +unsupported call to ` as std::ops::Deref>::deref` at fixtures/reject/src/lib.rs:397:2 +constructing `std::borrow::Cow<'_, std::sync::Arc>` at fixtures/reject/src/lib.rs:403:53 unsupported call to `core::str::::split::<[char; 2]>` at fixtures/reject/src/lib.rs:372:4 passing `{closure@fixtures/reject/src/lib.rs:379:28: 379: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:379:13 passing `{closure@fixtures/reject/src/lib.rs:380:25: 380:33}`, a closure that owns a value that drops, to `Iterator::for_each`, which is not supported yet at fixtures/reject/src/lib.rs:380:16 -an iterator that owns `Noisy`, which drops, which is not supported yet at fixtures/reject/src/lib.rs:385:2 -unsupported call to `::add_assign` at fixtures/reject/src/lib.rs:416:2 -`core::slice::::last_mut` with a mutable reference to a value JS copies, which its mapping would copy at fixtures/reject/src/lib.rs:422: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:429:15 -a mutable reference into a `Result`'s payload, passed on or kept at fixtures/reject/src/lib.rs:439:12 -unsupported call to ` as std::cmp::PartialEq>::eq` at fixtures/reject/src/lib.rs:446:2 +unsupported call to `::add_assign` at fixtures/reject/src/lib.rs:411:2 +`core::slice::::last_mut` with a mutable reference to a value JS copies, which its mapping would copy at fixtures/reject/src/lib.rs:417: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:424:15 +a mutable reference into a `Result`'s payload, passed on or kept at fixtures/reject/src/lib.rs:434:12 +unsupported call to ` as std::cmp::PartialEq>::eq` at fixtures/reject/src/lib.rs:441:2 overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:154:2 an iterator of the crate implementing `DoubleEndedIterator`, which is not supported yet at fixtures/reject/src/lib.rs:174:1 overriding `Iterator::size_hint`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:208:2 diff --git a/ts/fixtures/reject/src/lib.rs b/ts/fixtures/reject/src/lib.rs index 2e34023bc..9a6b9b3b5 100644 --- a/ts/fixtures/reject/src/lib.rs +++ b/ts/fixtures/reject/src/lib.rs @@ -380,11 +380,6 @@ pub fn called_closure(v: Vec, m: &mut std::collections::HashMap usize { - std::iter::successors(Some(Noisy(4)), |_| None).count() -} - /// A `Cow` is a JS string, which keeps no variant to match on or ask about. pub fn cow_matched(c: std::borrow::Cow<'_, str>) -> String { match c { diff --git a/ts/fixtures/reject/ts.toml b/ts/fixtures/reject/ts.toml index 5765d60e8..35a24ebc4 100644 --- a/ts/fixtures/reject/ts.toml +++ b/ts/fixtures/reject/ts.toml @@ -49,7 +49,6 @@ roots = [ "cow_made", "split_chars", "called_closure", - "owning_lazy", "duration_assign", "last_bumped", "modified", diff --git a/ts/fixtures/task/expected/core/option.ts b/ts/fixtures/task/expected/core/option.ts index 226ff2e89..8d7e65e3b 100644 --- a/ts/fixtures/task/expected/core/option.ts +++ b/ts/fixtures/task/expected/core/option.ts @@ -35,7 +35,7 @@ export function unwrapOr$Option_u64(self: rt.u64 | undefined, default_: rt.u64): return self; } -export function map$Option_Guard_u32_iterated_closure14(self: Guard.Guard | undefined, f: (a0: Guard.Guard) => rt.u32): rt.u32 | undefined { +export function map$Option_Guard_u32_iterated_closure15(self: Guard.Guard | undefined, f: (a0: Guard.Guard) => rt.u32): rt.u32 | undefined { if (self === undefined) { return undefined; } diff --git a/ts/fixtures/task/expected/drops.ts b/ts/fixtures/task/expected/drops.ts index feb8c54cd..c1fe8afbd 100644 --- a/ts/fixtures/task/expected/drops.ts +++ b/ts/fixtures/task/expected/drops.ts @@ -22,7 +22,7 @@ import * as Log from "./log.Log.ts"; import * as Guard from "./model.Guard.ts"; /** - * Run scenario `arg % 23`, panicking at the point `arg / 23 % 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, 23), 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)); }; diff --git a/ts/fixtures/task/expected/drops/closures.ts b/ts/fixtures/task/expected/drops/closures.ts index 80c6133db..8d62255e2 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_Guard_u32_iterated_closure14, 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_closure15, 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"; @@ -1074,81 +1074,87 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { let i!: Guard.Guard; let j!: Guard.Guard; let _227!: 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 _274!: Guard.Guard; - let _277!: Guard.Guard; + let _303!: Guard.Guard; + let _306!: Guard.Guard; let n!: Guard.Guard; let o!: Guard.Guard; let r!: Guard.Guard; let map!: rt.BTreeMap; let queue!: rt.VecDeque; - let _437!: boolean; - let _438!: boolean; - let _439!: boolean; - let _440!: boolean; - let _441!: boolean; - let _442!: boolean; - let _443!: boolean; - let _444!: boolean; - let _445!: boolean; - let _446!: boolean; - let _447!: boolean; - let _448!: boolean; - let _449!: boolean; - let _450!: boolean; - let _451!: boolean; - let _452!: boolean; - let _453!: boolean; - let _454!: boolean; - let _455!: boolean; + let _468!: boolean; + let _469!: boolean; + let _470!: boolean; + let _471!: boolean; + let _472!: boolean; + let _473!: boolean; + let _474!: boolean; + let _475!: boolean; + let _476!: boolean; + let _477!: boolean; + let _478!: boolean; + let _479!: boolean; + let _480!: boolean; + let _481!: boolean; + let _482!: boolean; + let _483!: boolean; + let _484!: boolean; + let _485!: boolean; + let _486!: boolean; + let _487!: boolean; + let _488!: boolean; let unwind: number = 0; try { - _455 = false; - _454 = false; - _453 = false; - _452 = false; - _451 = false; - _450 = false; - _449 = false; - _448 = false; - _447 = false; - _446 = false; - _445 = false; - _444 = false; - _443 = false; - _442 = false; - _441 = false; - _440 = false; - _439 = false; - _438 = false; - _437 = false; + _488 = false; + _487 = false; + _486 = false; + _485 = false; + _484 = false; + _483 = false; + _482 = false; + _481 = false; + _480 = false; + _479 = false; + _478 = false; + _477 = false; + _476 = false; + _475 = false; + _474 = false; + _473 = false; + _472 = false; + _471 = false; + _470 = false; + _469 = false; + _468 = 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 args24: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(id, f), (f: rt.Formatter) => rt.u8Display(point, f)]; - rt.panicFmt(["d", args24[0], " at ", args24[1]]); + const args26: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(id, f), (f: rt.Formatter) => rt.u8Display(point, f)]; + rt.panicFmt(["d", args26[0], " at ", args26[1]]); } }; - _455 = true; + _488 = true; a = guard(1); - unwind = 253; + unwind = 271; v = []; - unwind = 220; + unwind = 234; 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 = 253; + unwind = 271; const _13: rt.Iter = rt.iterSlice(v, rt.drop); - _455 = false; + _488 = false; const captured = id; const captured2 = check; const captured3 = a; @@ -1173,28 +1179,28 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured3); })); - unwind = 251; - _454 = true; + unwind = 269; + _487 = 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.u32Display), (f: rt.Formatter) => rt.fmtOption(_41, f, rt.u32Display)]; Log.note(log, rt.fmtFormat(["map ", args2[0], " ", args2[1]])); - _454 = false; + _487 = false; rt.drop(mapped); b = guard(5); - unwind = 249; - _453 = true; + unwind = 267; + _486 = true; v2 = []; - unwind = 219; + unwind = 233; 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 = 249; + unwind = 267; const _55: rt.Iter = rt.iterSlice(v2, rt.drop); - _453 = false; + _486 = false; const captured4 = b; iter = rt.iterFilter(_55, rt.closure((g4: Guard.Guard): boolean => { return Guard.id(g4) !== rt.u32Add(Guard.id(captured4), 1); @@ -1202,41 +1208,41 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { rt.drop(captured4); }), rt.drop); while (true) { - unwind = 218; + unwind = 232; const _75: Guard.Guard | rt.Done = iter.next(); if (_75 === rt.DONE) { break; } - unwind = 217; + unwind = 231; 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 = 218; + unwind = 232; rt.drop(g); } else { - unwind = 218; + unwind = 232; rt.drop(g); break; } } - unwind = 249; + unwind = 267; rt.drop(iter); _100 = guard(9); - unwind = 216; + unwind = 230; _103 = guard(10); - unwind = 215; + unwind = 229; const _106: Guard.Guard = guard(11); - unwind = 245; - _452 = true; + unwind = 263; + _485 = true; c = _100; - _451 = true; + _484 = true; d = _103; - _450 = true; + _483 = true; e = _106; v3 = []; - unwind = 212; + unwind = 226; const _117: Guard.Guard = guard(12); v3.push(_117); const _122: Guard.Guard = guard(13); @@ -1245,23 +1251,23 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { v3.push(_127); const _132: Guard.Guard = guard(15); v3.push(_132); - unwind = 245; + unwind = 263; const _112: rt.Iter = rt.iterSlice(v3, rt.drop); - _452 = false; + _485 = 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); - _451 = false; + _484 = 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); - _450 = false; + _483 = false; const captured7 = id; const captured8 = check; const captured9 = e; @@ -1271,14 +1277,14 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { } const _173: rt.u32 = Guard.id(g7); const _192: rt.u32 = Guard.id(captured9); - const args26: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_173, f), (f: rt.Formatter) => rt.u32Display(_192, f)]; - Log.note(log, rt.fmtFormat(["inspect ", args26[0], " ", args26[1]])); + const args28: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_173, f), (f: rt.Formatter) => rt.u32Display(_192, f)]; + Log.note(log, rt.fmtFormat(["inspect ", args28[0], " ", args28[1]])); }, (): void => { rt.drop(captured9); }), rt.drop); - unwind = 243; - _449 = true; - const part2 = map$Option_Guard_u32_iterated_closure14(rt.iterToOption(chained.next()), (g8: Guard.Guard): rt.u32 => { + unwind = 261; + _482 = true; + const part2 = map$Option_Guard_u32_iterated_closure15(rt.iterToOption(chained.next()), (g8: Guard.Guard): rt.u32 => { let unwind3: number = 0; try { unwind3 = 4; @@ -1296,7 +1302,7 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }); const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part2, f, rt.u32Display)]; Log.note(log, rt.fmtFormat(["chained ", args6[0]])); - const part3 = map$Option_Guard_u32_iterated_closure14(rt.iterToOption(chained.next()), (g9: Guard.Guard): rt.u32 => { + const part3 = map$Option_Guard_u32_iterated_closure15(rt.iterToOption(chained.next()), (g9: Guard.Guard): rt.u32 => { let unwind4: number = 0; try { unwind4 = 4; @@ -1314,31 +1320,31 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }); const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part3, f, rt.u32Display)]; Log.note(log, rt.fmtFormat(["chained ", args8[0]])); - _449 = false; + _482 = false; rt.drop(chained); _169 = guard(16); - unwind = 211; + unwind = 225; const _172: Guard.Guard = guard(17); - unwind = 240; - _448 = true; + unwind = 258; + _481 = true; f = _169; - _447 = true; + _480 = true; g2 = _172; const v4: rt.u32[] = []; - unwind = 209; + unwind = 223; v4.push(1); v4.push(2); v4.push(3); - unwind = 240; + unwind = 258; const _177: rt.Iter = rt.iterSlice(v4); - _448 = false; + _481 = 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); })); - _447 = false; + _480 = false; const captured11 = g2; flat = rt.iterFlatMap(_176, rt.closure((n5: rt.u32): rt.u32[] => { const v6: rt.u32[] = []; @@ -1349,19 +1355,19 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured11); }), (value: rt.u32[]) => rt.iterSlice(value), true); - unwind = 238; - _446 = true; + unwind = 256; + _479 = true; const part4 = rt.iterToOption(flat.next()); const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part4, f, rt.u32Display)]; Log.note(log, rt.fmtFormat(["flat ", args10[0]])); check(3); - _446 = false; + _479 = false; rt.drop(flat); h = guard(18); - unwind = 236; - _445 = true; + unwind = 254; + _478 = true; const _210: rt.Iter = rt.iterSlice([1, 2, 3]); - _445 = false; + _478 = false; const captured12 = h; const whiles: rt.u32[] = rt.iterToArray(rt.iterMapWhile(_210, rt.closure((_2: rt.u32): rt.u32 | undefined => { const n6: rt.u32 = _2; @@ -1369,18 +1375,18 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured12); })), false, rt.drop); - unwind = 208; + unwind = 222; const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(whiles, f, rt.u32Display)]; Log.note(log, rt.fmtFormat(["map_while ", args12[0]])); _227 = guard(19); - unwind = 207; + unwind = 221; const _230: Guard.Guard = guard(20); - unwind = 233; - _444 = true; + unwind = 251; + _477 = true; i = _227; - _443 = true; + _476 = true; j = _230; - _444 = false; + _477 = false; const captured13 = check; const captured14 = i; const made: rt.usize = rt.ownedCount(rt.iterTake(rt.iterFromFn(rt.closure((): rt.u32 | undefined => { @@ -1389,7 +1395,7 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured14); })), 2), rt.drop); - _443 = false; + _476 = false; const captured15 = j; const walked: rt.u32 = rt.iterSum(rt.iterSuccessors(1, rt.closure((_26: rt.u32): rt.u32 | undefined => { const n7: rt.u32 = _26; @@ -1397,199 +1403,257 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured15); })), rt.u32Add, 0, rt.drop); - const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(made, f), (f: rt.Formatter) => rt.u32Display(walked, f)]; - Log.note(log, rt.fmtFormat(["lazy ", args14[0], " ", args14[1]])); - v5 = []; - unwind = 205; - const _257: Guard.Guard = guard(21); - v5.push(_257); - const _262: Guard.Guard = guard(22); - v5.push(_262); - const _267: Guard.Guard = guard(23); - v5.push(_267); - unwind = 204; - items = v5; - _274 = guard(24); - unwind = 203; - _277 = guard(25); - unwind = 202; - const _280: Guard.Guard = guard(26); - unwind = 229; - _442 = true; - k = _274; - _441 = true; - l = _277; - _440 = true; - m = _280; - const _285: rt.Iter = rt.iterSlice(items); - _442 = false; + s = guard(43); + unwind = 249; + _475 = true; + const _245: Guard.Guard | undefined = guard(40); + _475 = false; const captured16 = id; const captured17 = check; - const captured18 = k; - const _288: (a0: Guard.Guard) => boolean = rt.closure((g10: Guard.Guard): boolean => { - if (Guard.id(g10) === rt.u32Add(captured16, 22)) { - captured17(5); + const captured18 = s; + chain = rt.iterSuccessors(_245, rt.closure((g10: Guard.Guard): Guard.Guard | undefined => { + if (Guard.id(g10) === rt.u32Add(captured16, 41)) { + captured17(8); } - return Guard.id(g10) === Guard.id(captured18); + return rt.boolThen(rt.u32Add(Guard.id(g10), 1) < Guard.id(captured18), (): Guard.Guard => { + return Guard.new(rt.u32Add(Guard.id(g10), 1), Log.clone$Clone(log)); + }); }, (): void => { rt.drop(captured18); + }), rt.drop); + unwind = 247; + _474 = true; + const _256: rt.u32 | undefined = map$Option_Guard_u32_iterated_closure15(rt.iterToOption(chain.next()), (g11: Guard.Guard): rt.u32 => { + let unwind5: number = 0; + try { + unwind5 = 4; + const _015: rt.u32 = Guard.id(g11); + unwind5 = 0; + rt.drop(g11); + return _015; + } 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(_256, f, rt.u32Display)]; + Log.note(log, rt.fmtFormat(["lazy ", args14[0], " ", args14[1], " ", args14[2]])); + const part5 = map$Option_Guard_u32_iterated_closure15(rt.iterToOption(chain.next()), (g12: Guard.Guard): rt.u32 => { + let unwind6: number = 0; + try { + unwind6 = 4; + const _016: rt.u32 = Guard.id(g12); + unwind6 = 0; + rt.drop(g12); + return _016; + } catch (e7) { + if (unwind6 === 0) { + throw e7; + } + rt.drop(g12); + throw e7; + } + }); + const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part5, f, rt.u32Display)]; + Log.note(log, rt.fmtFormat(["successor ", args16[0]])); + _474 = false; + rt.drop(chain); + v5 = []; + unwind = 219; + const _286: Guard.Guard = guard(21); + v5.push(_286); + const _291: Guard.Guard = guard(22); + v5.push(_291); + const _296: Guard.Guard = guard(23); + v5.push(_296); + unwind = 218; + items = v5; + _303 = guard(24); + unwind = 217; + _306 = guard(25); + unwind = 216; + const _309: Guard.Guard = guard(26); + unwind = 243; + _473 = true; + k = _303; + _472 = true; + l = _306; + _471 = true; + m = _309; + const _314: rt.Iter = rt.iterSlice(items); + _473 = false; + const captured19 = id; + const captured20 = check; + const captured21 = k; + const _317: (a0: Guard.Guard) => boolean = rt.closure((g13: Guard.Guard): boolean => { + if (Guard.id(g13) === rt.u32Add(captured19, 22)) { + captured20(5); + } + return Guard.id(g13) === Guard.id(captured21); + }, (): void => { + rt.drop(captured21); }); - const any: boolean = rt.dropAfter(_288, () => rt.iterAny(_285, _288)); - const _292: rt.Iter = rt.iterSlice(items); - _441 = false; - const captured19 = l; - const _295: (a0: Guard.Guard) => boolean = rt.closure((g11: Guard.Guard): boolean => { - return Guard.id(g11) === rt.u32Sub(Guard.id(captured19), 3); + const any: boolean = rt.dropAfter(_317, () => rt.iterAny(_314, _317)); + const _321: rt.Iter = rt.iterSlice(items); + _472 = false; + const captured22 = l; + const _324: (a0: Guard.Guard) => boolean = rt.closure((g14: Guard.Guard): boolean => { + return Guard.id(g14) === rt.u32Sub(Guard.id(captured22), 3); }, (): void => { - rt.drop(captured19); + rt.drop(captured22); }); - const found: rt.u32 | undefined = map$Option_Guard_u32_iterated_closure14(rt.dropAfter(_295, () => rt.iterFind(_292, _295)), (g12: Guard.Guard): rt.u32 => { - return Guard.id(g12); + const found: rt.u32 | undefined = map$Option_Guard_u32_iterated_closure15(rt.dropAfter(_324, () => rt.iterFind(_321, _324)), (g15: Guard.Guard): rt.u32 => { + return Guard.id(g15); }); - const _298: rt.Iter = rt.iterSlice(items); - _440 = false; - const captured20 = m; - const _301: (a0: Guard.Guard) => boolean = rt.closure((g13: Guard.Guard): boolean => { - return rt.u32Add(Guard.id(g13), 2) === Guard.id(captured20); + const _327: rt.Iter = rt.iterSlice(items); + _471 = false; + const captured23 = m; + const _330: (a0: Guard.Guard) => boolean = rt.closure((g16: Guard.Guard): boolean => { + return rt.u32Add(Guard.id(g16), 2) === Guard.id(captured23); }, (): void => { - rt.drop(captured20); + rt.drop(captured23); }); - const atPos: rt.usize | undefined = rt.dropAfter(_301, () => rt.iterPosition(_298, _301)); - const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(any, f), (f: rt.Formatter) => rt.fmtOption(found, f, rt.u32Display), (f: rt.Formatter) => rt.fmtOption(atPos, f, rt.usizeDisplay)]; - Log.note(log, rt.fmtFormat(["found ", args16[0], " ", args16[1], " ", args16[2]])); + const atPos: rt.usize | undefined = rt.dropAfter(_330, () => rt.iterPosition(_327, _330)); + const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(any, f), (f: rt.Formatter) => rt.fmtOption(found, f, rt.u32Display), (f: rt.Formatter) => rt.fmtOption(atPos, f, rt.usizeDisplay)]; + Log.note(log, rt.fmtFormat(["found ", args18[0], " ", args18[1], " ", args18[2]])); n = guard(27); - unwind = 227; - _439 = true; - const _321: rt.Iter = rt.iterSlice([1, 2, 3]); - _439 = false; - const captured21 = n; - const sum: rt.u32 = rt.iterSum(rt.iterMap(_321, rt.closure((_27: rt.u32): rt.u32 => { - return rt.u32Add(_27, Guard.id(captured21)); + unwind = 241; + _470 = true; + const _350: rt.Iter = rt.iterSlice([1, 2, 3]); + _470 = false; + const captured24 = n; + const sum: rt.u32 = rt.iterSum(rt.iterMap(_350, rt.closure((_29: rt.u32): rt.u32 => { + return rt.u32Add(_29, Guard.id(captured24)); }, (): void => { - rt.drop(captured21); + rt.drop(captured24); })), rt.u32Add, 0, rt.drop); o = guard(28); - unwind = 225; - _438 = true; - const _329: rt.Iter = rt.iterSlice([1, 2]); - _438 = false; - const captured22 = o; - const _332: (a0: rt.u32) => void = rt.closure((_29: rt.u32): void => { - const part5 = rt.u32Add(_29, Guard.id(captured22)); - const args28: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(part5, f)]; - Log.note(log, rt.fmtFormat(["each ", args28[0]])); + unwind = 239; + _469 = true; + const _358: rt.Iter = rt.iterSlice([1, 2]); + _469 = false; + const captured25 = o; + const _361: (a0: rt.u32) => void = rt.closure((_214: rt.u32): void => { + const part6 = rt.u32Add(_214, Guard.id(captured25)); + const args30: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(part6, f)]; + Log.note(log, rt.fmtFormat(["each ", args30[0]])); }, (): void => { - rt.drop(captured22); + rt.drop(captured25); }); - rt.dropAfter(_332, () => rt.iterForEach(_329, _332)); - const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(sum, f)]; - Log.note(log, rt.fmtFormat(["sum ", args18[0]])); + rt.dropAfter(_361, () => rt.iterForEach(_358, _361)); + const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(sum, f)]; + Log.note(log, rt.fmtFormat(["sum ", args20[0]])); r = guard(36); - unwind = 223; - _437 = true; - const _347: rt.Iter = rt.iterMap(rt.iterSlice([1, 2, 3]), (_214: rt.u32): Guard.Guard => { - return guard(rt.u32Add(36, _214)); + unwind = 237; + _468 = true; + const _376: rt.Iter = rt.iterMap(rt.iterSlice([1, 2, 3]), (_218: rt.u32): Guard.Guard => { + return guard(rt.u32Add(36, _218)); }); - _437 = false; - const captured23 = id; - const captured24 = check; - const captured25 = r; - const _353: (a0: Guard.Guard) => rt.u32 = rt.closure((g14: Guard.Guard): rt.u32 => { - if (Guard.id(g14) === rt.u32Add(captured23, 38)) { - captured24(7); + _468 = false; + const captured26 = id; + const captured27 = check; + const captured28 = r; + const _382: (a0: Guard.Guard) => rt.u32 = rt.closure((g17: Guard.Guard): rt.u32 => { + if (Guard.id(g17) === rt.u32Add(captured26, 38)) { + captured27(7); } - return rt.u32Add(rt.u32Rem(Guard.id(g14), 2), Guard.id(captured25)); + return rt.u32Add(rt.u32Rem(Guard.id(g17), 2), Guard.id(captured28)); }, (): void => { - rt.drop(captured25); + rt.drop(captured28); }); - const part7 = map$Option_Guard_u32_iterated_closure14(rt.dropAfter(_353, () => rt.iterMaxByKey(_347, _353, undefined, rt.drop)), (g15: Guard.Guard): rt.u32 => { - let unwind5: number = 0; + const part8 = map$Option_Guard_u32_iterated_closure15(rt.dropAfter(_382, () => rt.iterMaxByKey(_376, _382, undefined, rt.drop)), (g18: Guard.Guard): rt.u32 => { + let unwind7: number = 0; try { - unwind5 = 4; - const _020: rt.u32 = Guard.id(g15); - unwind5 = 0; - rt.drop(g15); - return _020; - } catch (e6) { - if (unwind5 === 0) { - throw e6; + unwind7 = 4; + const _024: rt.u32 = Guard.id(g18); + unwind7 = 0; + rt.drop(g18); + return _024; + } catch (e8) { + if (unwind7 === 0) { + throw e8; } - rt.drop(g15); - throw e6; + rt.drop(g18); + throw e8; } }); - const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part7, f, rt.u32Display)]; - Log.note(log, rt.fmtFormat(["best ", args20[0]])); + const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part8, f, rt.u32Display)]; + Log.note(log, rt.fmtFormat(["best ", args22[0]])); map = rt.btreeNew(rt.cmp) as rt.BTreeMap; - unwind = 199; + unwind = 213; 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 = 198; - const _372: [rt.u32, rt.u32] | rt.Done = iter2.next(); - if (_372 === rt.DONE) { + unwind = 212; + const _401: [rt.u32, rt.u32] | rt.Done = iter2.next(); + if (_401 === rt.DONE) { break; } - const k2: rt.u32 = _372[0]; - const _379: Guard.Guard = guard(_372[1]); - rt.drop(rt.btreeInsert(map, k2, _379, undefined, rt.drop)); + const k2: rt.u32 = _401[0]; + const _408: Guard.Guard = guard(_401[1]); + rt.drop(rt.btreeInsert(map, k2, _408, undefined, rt.drop)); } - unwind = 199; + unwind = 213; const p: Guard.Guard = guard(32); - const captured26 = check; - const captured27 = p; - const captured28 = id; - const _387: (a0: rt.u32, a1: Guard.Guard) => boolean = rt.closure((_218: rt.u32, _328: Guard.Guard): boolean => { - const k3: rt.u32 = _218; + const captured29 = check; + const captured30 = p; + const captured31 = id; + const _416: (a0: rt.u32, a1: Guard.Guard) => boolean = rt.closure((_219: rt.u32, _329: Guard.Guard): boolean => { + const k3: rt.u32 = _219; if (k3 === 2) { - captured26(6); + captured29(6); } - return rt.u32Add(k3, Guard.id(captured27)) !== rt.u32Add(captured28, 34); + return rt.u32Add(k3, Guard.id(captured30)) !== rt.u32Add(captured31, 34); }, (): void => { - rt.drop(captured27); + rt.drop(captured30); }); - rt.dropAfter(_387, () => rt.btreeRetain(map, _387, undefined, rt.drop)); + rt.dropAfter(_416, () => rt.btreeRetain(map, _416, undefined, rt.drop)); queue = rt.dequeNew() as rt.VecDeque; - unwind = 197; - const _391: Guard.Guard = guard(33); - rt.dequePushBack(queue, _391); - const _396: Guard.Guard = guard(34); - rt.dequePushBack(queue, _396); - const captured29 = guard(35); - const _404: (a0: Guard.Guard) => boolean = rt.closure((g16: Guard.Guard): boolean => { - return rt.u32Add(Guard.id(g16), 2) !== Guard.id(captured29); + unwind = 211; + const _420: Guard.Guard = guard(33); + rt.dequePushBack(queue, _420); + const _425: Guard.Guard = guard(34); + rt.dequePushBack(queue, _425); + const captured32 = guard(35); + const _433: (a0: Guard.Guard) => boolean = rt.closure((g19: Guard.Guard): boolean => { + return rt.u32Add(Guard.id(g19), 2) !== Guard.id(captured32); }, (): void => { - rt.drop(captured29); + rt.drop(captured32); }); - rt.dropAfter(_404, () => rt.dequeRetain(queue, _404, rt.drop)); - const _411: rt.usize = rt.btreeLen(map); - const _414: rt.usize = queue.n; - const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(_411, f), (f: rt.Formatter) => rt.usizeDisplay(_414, f)]; - Log.note(log, rt.fmtFormat(["retained ", args22[0], " ", args22[1]])); - unwind = 199; + rt.dropAfter(_433, () => rt.dequeRetain(queue, _433, rt.drop)); + const _440: rt.usize = rt.btreeLen(map); + const _443: rt.usize = queue.n; + const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(_440, f), (f: rt.Formatter) => rt.usizeDisplay(_443, f)]; + Log.note(log, rt.fmtFormat(["retained ", args24[0], " ", args24[1]])); + unwind = 213; rt.dequeDrop(queue, rt.drop); - unwind = 223; + unwind = 237; rt.btreeDrop(map, undefined, rt.drop); - unwind = 233; - _437 = false; - _438 = false; - _439 = false; - _440 = false; - _441 = false; - _442 = false; + unwind = 247; + _468 = false; + _469 = false; + _470 = false; + _471 = false; + _472 = false; + _473 = false; rt.dropAll(items); - _443 = false; - _444 = false; - _445 = false; - _446 = false; - _447 = false; - _448 = false; - _449 = false; - _450 = false; - _451 = false; - _452 = false; - _453 = false; - _454 = false; - _455 = false; + _474 = false; + _475 = false; + _476 = false; + _477 = false; + _478 = false; + _479 = false; + _480 = false; + _481 = false; + _482 = false; + _483 = false; + _484 = false; + _485 = false; + _486 = false; + _487 = false; + _488 = false; } catch (e2) { b4: { b5: { @@ -1609,188 +1673,204 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { b19: { b20: { b21: { - if (unwind === 0) { - throw e2; - } - if (unwind === 197) { - rt.dequeDrop(queue, rt.drop); - break b19; - } - if (unwind === 198) { - break b19; - } - if (unwind === 199) { - break b19; - } - if (unwind === 202) { - rt.drop(_277); - break b20; - } - if (unwind === 203) { - break b20; - } - if (unwind === 204) { - break b14; - } - if (unwind === 205) { - rt.dropAll(v5); - break b13; - } - if (unwind === 207) { - rt.drop(_227); - break b12; - } - if (unwind === 208) { - break b12; - } - if (unwind === 209) { - break b9; - } - if (unwind === 211) { - rt.drop(_169); - break b8; - } - if (unwind === 212) { - rt.dropAll(v3); - break b7; - } - if (unwind === 215) { - rt.drop(_103); - break b21; - } - if (unwind === 216) { - break b21; - } - if (unwind === 217) { - rt.drop(g); - } else if (unwind !== 218) { - if (unwind === 219) { - rt.dropAll(v2); - break b6; - } - if (unwind === 220) { - rt.dropAll(v); - break b4; - } - if (unwind === 223) { - break b18; - } - if (unwind === 225) { - break b17; - } - if (unwind === 227) { - break b16; - } - if (unwind === 229) { - break b15; - } - if (unwind === 233) { - break b13; - } - if (unwind === 236) { - break b11; - } - if (unwind === 238) { - break b10; - } - if (unwind === 240) { - break b9; - } - if (unwind === 243) { - break b8; - } - if (unwind === 245) { - break b7; - } - if (unwind === 249) { + b22: { + b23: { + if (unwind === 0) { + throw e2; + } + if (unwind === 211) { + rt.dequeDrop(queue, rt.drop); + break b21; + } + if (unwind === 212) { + break b21; + } + if (unwind === 213) { + break b21; + } + if (unwind === 216) { + rt.drop(_306); + break b22; + } + if (unwind === 217) { + break b22; + } + if (unwind === 218) { + break b16; + } + if (unwind === 219) { + rt.dropAll(v5); + break b15; + } + if (unwind === 221) { + rt.drop(_227); + break b12; + } + if (unwind === 222) { + break b12; + } + if (unwind === 223) { + break b9; + } + if (unwind === 225) { + rt.drop(_169); + break b8; + } + if (unwind === 226) { + rt.dropAll(v3); + break b7; + } + if (unwind === 229) { + rt.drop(_103); + break b23; + } + if (unwind === 230) { + break b23; + } + if (unwind === 231) { + rt.drop(g); + } else if (unwind !== 232) { + if (unwind === 233) { + rt.dropAll(v2); + break b6; + } + if (unwind === 234) { + rt.dropAll(v); + break b4; + } + if (unwind === 237) { + break b20; + } + if (unwind === 239) { + break b19; + } + if (unwind === 241) { + break b18; + } + if (unwind === 243) { + break b17; + } + if (unwind === 247) { + break b15; + } + if (unwind === 249) { + break b14; + } + if (unwind === 251) { + break b13; + } + if (unwind === 254) { + break b11; + } + if (unwind === 256) { + break b10; + } + if (unwind === 258) { + break b9; + } + if (unwind === 261) { + break b8; + } + if (unwind === 263) { + break b7; + } + if (unwind === 267) { + break b6; + } + if (unwind === 269) { + break b5; + } + break b4; + } + rt.drop(iter); break b6; } - if (unwind === 251) { - break b5; - } - break b4; + rt.drop(_100); + break b6; } - rt.drop(iter); - break b6; + rt.drop(_303); + break b16; } - rt.drop(_100); - break b6; + rt.btreeDrop(map, undefined, rt.drop); + } + if (_468) { + rt.drop(r); } - rt.drop(_274); - break b14; } - rt.btreeDrop(map, undefined, rt.drop); + if (_469) { + rt.drop(o); + } } - if (_437) { - rt.drop(r); + if (_470) { + rt.drop(n); } } - if (_438) { - rt.drop(o); + if (_471) { + rt.drop(m); + } + if (_472) { + rt.drop(l); + } + if (_473) { + rt.drop(k); } } - if (_439) { - rt.drop(n); - } + rt.dropAll(items); } - if (_440) { - rt.drop(m); - } - if (_441) { - rt.drop(l); - } - if (_442) { - rt.drop(k); + if (_474) { + rt.drop(chain); } } - rt.dropAll(items); + if (_475) { + rt.drop(s); + } } - if (_443) { + if (_476) { rt.drop(j); } - if (_444) { + if (_477) { rt.drop(i); } } } - if (_445) { + if (_478) { rt.drop(h); } } - if (_446) { + if (_479) { rt.drop(flat); } } - if (_447) { + if (_480) { rt.drop(g2); } - if (_448) { + if (_481) { rt.drop(f); } } - if (_449) { + if (_482) { rt.drop(chained); } } - if (_450) { + if (_483) { rt.drop(e); } - if (_451) { + if (_484) { rt.drop(d); } - if (_452) { + if (_485) { rt.drop(c); } } - if (_453) { + if (_486) { rt.drop(b); } } - if (_454) { + if (_487) { rt.drop(mapped); } } - if (_455) { + if (_488) { rt.drop(a); } throw e2; diff --git a/ts/fixtures/task/src/drops.rs b/ts/fixtures/task/src/drops.rs index 94cc23563..8c4a1c572 100644 --- a/ts/fixtures/task/src/drops.rs +++ b/ts/fixtures/task/src/drops.rs @@ -64,10 +64,10 @@ pub struct Named<'a>(Text<'a>); /// order, the second after the first panics. pub struct Entries(Vec<(K, V)>); -/// Run scenario `arg % 23`, panicking at the point `arg / 23 % 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 / 23 % 8; + let at = arg / 23 % 11; let guard = |n: u32| Guard::new(id + n, log.clone()); let check = |point: u8| { if point == at { diff --git a/ts/fixtures/task/src/drops/closures.rs b/ts/fixtures/task/src/drops/closures.rs index aab6d427e..b929dbe79 100644 --- a/ts/fixtures/task/src/drops/closures.rs +++ b/ts/fixtures/task/src/drops/closures.rs @@ -249,7 +249,18 @@ pub(super) fn iterated(log: &Log, id: u32, at: u8) { .take(2) .count(); let walked: u32 = std::iter::successors(Some(1u32), move |&n| (n < 3).then_some(n + 1 + j.id() - j.id())).sum(); - log.note(format!("lazy {made} {walked}")); + // 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)); diff --git a/ts/runtime/rt/iter.ts b/ts/runtime/rt/iter.ts index 1dba77ff3..cc7744007 100644 --- a/ts/runtime/rt/iter.ts +++ b/ts/runtime/rt/iter.ts @@ -147,19 +147,10 @@ export function iterFromFn(f: () => T | undefined): Iter { /** * `iter::successors`: `first`, then `succ` of each item, called as that item is yielded. - * `succ` drops with it, and the item it holds next, of a type that drops nothing, needn't. + * 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): Iter { - let next = first; - const step = (succ: (item: T) => T | undefined): T | Done => { - const item = next; - if (item === undefined) return DONE; - // Taken before `succ` runs, so a panic in it leaves the iterator done, as std's. - next = undefined; - next = succ(item); - return item; - }; - return new FromNext(succ, step, dispose); +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. */ @@ -358,7 +349,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) { @@ -1301,6 +1292,41 @@ class FromNext extends Iter implements Disposable { } } +/** `Successors`, holding the item it yields next. */ +class SuccessorsIter extends Iter implements Disposable { + private item: T | undefined; + private readonly succ: (item: T) => T | undefined; + private readonly drop: Drop | undefined; + + 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 { + 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. diff --git a/ts/src/lower/iter.rs b/ts/src/lower/iter.rs index a1cbf600e..f9440e619 100644 --- a/ts/src/lower/iter.rs +++ b/ts/src/lower/iter.rs @@ -272,16 +272,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]))); } _ => {} } diff --git a/ts/tests/task.ts b/ts/tests/task.ts index b8b2603b3..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: 184 }, (_, arg) => [11, arg]), + ...Array.from({ length: 253 }, (_, arg) => [11, arg]), ].map((script) => Uint8Array.from(script)); From d9cc96db592be3d9c00cb8083cfccae37e0895dc Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Tue, 27 Oct 2026 20:06:38 -0700 Subject: [PATCH 5/7] chore(quest): move drop's remaining refusals to m3 and finish ts-drop moq-net, its model, and kio have no drop refusal left, so the drop quest is done; what it still refuses, none in moq's census, moves to quest/m3/ts-drop-order.md, as rust2 aims for all of std. ts-async, ts-shared, and the model epic no longer wait on it. Co-Authored-By: Claude Opus 5.5 --- quest/m2/README.md | 1 - quest/m2/ts-async.md | 4 --- quest/m2/ts-drop.md | 49 ------------------------------------- quest/m2/ts-model/README.md | 1 - quest/m2/ts-shared.md | 4 --- quest/m3/README.md | 1 + quest/m3/ts-drop-order.md | 42 +++++++++++++++++++++++++++++++ ts/README.md | 2 +- 8 files changed, 44 insertions(+), 60 deletions(-) delete mode 100644 quest/m2/ts-drop.md create mode 100644 quest/m3/ts-drop-order.md diff --git a/quest/m2/README.md b/quest/m2/README.md index 572d2f664..a915a7106 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 - [A tuple's parts read after their variables change](/quest/m2/ts-swap-parts.md) - `(a, b) = (b, a)` swaps instead of copying one into both - [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 719464477..000000000 --- a/quest/m2/ts-drop.md +++ /dev/null @@ -1,49 +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). Given to std, an -iterator adaptor holds it and drops it after its iterator, as std's fields do -(`iter::holds_closure`), as `successors` drops the item it holds next before its own, -and a function that calls it by `Fn` or `FnMut`, keeps nothing -of it, and takes nothing else that drops by value drops it as it returns or unwinds -(`rt.dropAfter`). 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 consumer that std folds, 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), and a closure that owns a value that -drops given to a function that takes another value that drops by value, such as -`for_each` of items that drop, or that keeps it outside an adaptor, or that calls it -through `FnOnce` other than where `discards` in `library.rs` says (`or_insert_with`); -`into_keys` and `into_values` of a hash map whose other half drops (`fold` drops it -after the half it yields, `next` before); `zip` of two `TrustedRandomAccess` iterators -of items that drop; a `flatten` whose inner iterator holds items once ended, or that a -`fold` reads where both its source and inner iterators drop; a B-tree's `collect` of -entries that drop, sorted by the crate's own `Ord`; a `collect` in place of a `zip` -whose second iterator drops; and `DebugList::entries` of items that drop. - -Watch the cost: a function whose cleanup does something JS can see sets a variable -before each call that can panic and wraps its body in a `try`; measure any change on -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 25f0f0da5..62b3b9a2a 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 a9eabdf52..d27f69a09 100644 --- a/quest/m3/README.md +++ b/quest/m3/README.md @@ -25,3 +25,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 25ed71238..63855ce1a 100644 --- a/ts/README.md +++ b/ts/README.md @@ -424,7 +424,7 @@ hand-written TS ([bindings](#bindings)). These fail translation: floats, statics, async closures, a closure that owns a value 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](/quest/m2/ts-drop.md)), a `Cow` of other than `str`, +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 collection's `capacity`, looking up a key by another type it borrows as through the crate's own `Borrow`, a `&mut` to a value JS copies that std makes, other than a map's, or hands a closure, as `iter_mut` and From db3a53b62c675ab5ed4f5cb617e510f9b10b22f7 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Tue, 27 Oct 2026 20:17:14 -0700 Subject: [PATCH 6/7] fix(ts): drop an adaptor's closure once, and refuse a Pattern closure that drops `count` of a `peekable` or `skip`, and `last` of a `skip`, drop the adaptor they wrap and then the one holding it, so `Calling` and `SuccessorsIter` now drop what they hold only the first time. Only a closure that a function trait bounds skips the check for operands that drop, since only those does `called_closures` decide: one given as a `Pattern`, as `str::contains` takes, refuses again. Co-Authored-By: Claude Opus 5.5 --- ts/fixtures/reject/census.md | 67 +- ts/fixtures/reject/expected.txt | 23 +- ts/fixtures/reject/src/lib.rs | 7 + ts/fixtures/reject/ts.toml | 1 + ts/fixtures/task/expected/drops/closures.ts | 745 +++++++++++--------- ts/fixtures/task/src/drops/closures.rs | 7 + ts/runtime/rt/iter.ts | 13 +- ts/src/lower/library.rs | 42 +- 8 files changed, 513 insertions(+), 392 deletions(-) diff --git a/ts/fixtures/reject/census.md b/ts/fixtures/reject/census.md index 10162d6c7..ce50eee04 100644 --- a/ts/fixtures/reject/census.md +++ b/ts/fixtures/reject/census.md @@ -1,7 +1,7 @@ # Census of `reject-fixture` -- Refusals: 79 -- Function instances: 71 +- Refusals: 80 +- Function instances: 72 - Generic functions no instance reached, lowered over their type parameters: 2 ## By construct @@ -10,7 +10,7 @@ | ---: | --- | --- | | 9 | unsupported call to `_` | fixtures/reject/src/lib.rs:28:4 | | 6 | `_` is not supported: its `None` and `Some` would both be `undefined` | fixtures/reject/src/lib.rs:23:15 | -| 4 | a variant of `_`, which is not supported: either is the same JS string | fixtures/reject/src/lib.rs:385:2 | +| 4 | a variant of `_`, which is not supported: either is the same JS string | fixtures/reject/src/lib.rs:392:2 | | 4 | an assignment through a reference to `_` | fixtures/reject/src/lib.rs:111: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 | @@ -27,7 +27,7 @@ | 1 | `Octal` formatting, as in `{:o}`, is not supported | fixtures/reject/src/lib.rs:73:3 | | 1 | `Pointer` formatting, as in `{:p}`, is not supported | fixtures/reject/src/lib.rs:77:3 | | 1 | `_` holds `_`, which is `undefined` as `None` is, which is not supported | fixtures/reject/src/lib.rs:288:6 | -| 1 | `_` is not supported yet | fixtures/reject/src/lib.rs:396:18 | +| 1 | `_` is not supported yet | fixtures/reject/src/lib.rs:403:18 | | 1 | `_` of `_` by `_`, which is not supported yet | fixtures/reject/src/lib.rs:311:6 | | 1 | `_` of `_`, which drops `_`, which is not supported yet | fixtures/reject/src/lib.rs:53:13 | | 1 | `_` of `_`, which folds a closure that drops beside what else drops, which is not supported yet | fixtures/reject/src/lib.rs:47:23 | @@ -41,7 +41,7 @@ | 1 | a constant of type `_` | fixtures/reject/src/lib.rs:90:2 | | 1 | a copy of a closure that changes what it captured | fixtures/reject/src/lib.rs:277:14 | | 1 | a mutable borrow of a subslice of `_`, which JS would copy, having no views | fixtures/reject/src/lib.rs:246:13 | -| 1 | a mutable reference into a `Result`'s payload, passed on or kept | fixtures/reject/src/lib.rs:434:12 | +| 1 | a mutable reference into a `Result`'s payload, passed on or kept | fixtures/reject/src/lib.rs:441:12 | | 1 | a precision, as in `{:.2}`, is not supported | fixtures/reject/src/lib.rs:69:3 | | 1 | a printable type must implement `Display` or `Debug` | fixtures/reject/src/lib.rs:102:1 | | 1 | a scalar constant of type `_` | fixtures/reject/src/lib.rs:8:2 | @@ -49,9 +49,10 @@ | 1 | a zero-sized constant of type `_` | fixtures/reject/src/lib.rs:62:2 | | 1 | arithmetic on `_` | fixtures/reject/src/lib.rs:8:2 | | 1 | comparing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:293:52 | -| 1 | constructing `_` | fixtures/reject/src/lib.rs:403:53 | +| 1 | constructing `_` | fixtures/reject/src/lib.rs:410:53 | | 1 | hashing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:293:52 | | 1 | hex `Debug`, as in `{:x?}`, is not supported | fixtures/reject/src/lib.rs:75:3 | +| 1 | passing `_`, which drops, to `_`, which is not supported yet | fixtures/reject/src/lib.rs:387:4 | | 1 | the `+` flag of a format spec is not supported | fixtures/reject/src/lib.rs:70:3 | | 1 | the `-` flag of a format spec is not supported | fixtures/reject/src/lib.rs:71:3 | @@ -61,7 +62,7 @@ The type or module each refused type or path belongs to. | Count | API | First | | ---: | --- | --- | -| 7 | `std::borrow::Cow` | fixtures/reject/src/lib.rs:385:2 | +| 7 | `std::borrow::Cow` | fixtures/reject/src/lib.rs:392:2 | | 6 | `Option` | fixtures/reject/src/lib.rs:23:15 | | 6 | `f64` | fixtures/reject/src/lib.rs:7:14 | | 3 | `Iterator` | fixtures/reject/src/lib.rs:154:2 | @@ -69,6 +70,7 @@ The type or module each refused type or path belongs to. | 3 | `std::iter::Map` | fixtures/reject/src/lib.rs:47:23 | | 3 | `std::slice` | fixtures/reject/src/lib.rs:28:4 | | 3 | `std::sync::Arc` | fixtures/reject/src/lib.rs:111:2 | +| 3 | `{closure}` | fixtures/reject/src/lib.rs:379:13 | | 2 | `Meters` | fixtures/reject/src/lib.rs:95:2 | | 2 | `Poll` | fixtures/reject/src/lib.rs:115:20 | | 2 | `std::iter::Iterator` | fixtures/reject/src/lib.rs:267:16 | @@ -77,7 +79,6 @@ The type or module each refused type or path belongs to. | 2 | `std::pin::Pin` | fixtures/reject/src/lib.rs:131:2 | | 2 | `std::vec::Vec` | fixtures/reject/src/lib.rs:293:52 | | 2 | `u8` | fixtures/reject/src/lib.rs:90:2 | -| 2 | `{closure}` | fixtures/reject/src/lib.rs:379:13 | | 1 | `DoubleEndedIterator` | fixtures/reject/src/lib.rs:174:1 | | 1 | `Entry` | fixtures/reject/src/lib.rs:379:13 | | 1 | `FusedIterator` | fixtures/reject/src/lib.rs:228:1 | @@ -89,7 +90,7 @@ The type or module each refused type or path belongs to. | 1 | `count` | fixtures/reject/src/lib.rs:47:23 | | 1 | `dyn std::ops::Fn(u8) -> u8` | fixtures/reject/src/lib.rs:11:16 | | 1 | `into_keys` | fixtures/reject/src/lib.rs:53:13 | -| 1 | `std::collections::hash_map::Entry` | fixtures/reject/src/lib.rs:424:15 | +| 1 | `std::collections::hash_map::Entry` | fixtures/reject/src/lib.rs:431:15 | | 1 | `std::iter::Chain` | fixtures/reject/src/lib.rs:187:51 | | 1 | `std::iter::Flatten` | fixtures/reject/src/lib.rs:236:26 | | 1 | `std::iter::IntoIterator` | fixtures/reject/src/lib.rs:17:2 | @@ -100,7 +101,8 @@ The type or module each refused type or path belongs to. | 1 | `std::str` | fixtures/reject/src/lib.rs:372:4 | | 1 | `std::string::String` | fixtures/reject/src/lib.rs:84:10 | | 1 | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:136:2 | -| 1 | `std::time::Duration` | fixtures/reject/src/lib.rs:411:2 | +| 1 | `std::time::Duration` | fixtures/reject/src/lib.rs:418:2 | +| 1 | `str` | fixtures/reject/src/lib.rs:387:4 | | 1 | `u32` | fixtures/reject/src/lib.rs:246:13 | | 1 | `u64` | fixtures/reject/src/lib.rs:106:2 | | 1 | `{async closure}` | fixtures/reject/src/lib.rs:62:2 | @@ -110,22 +112,22 @@ The type or module each refused type or path belongs to. | Count | Construct | Type or path | First | | ---: | --- | --- | --- | | 6 | `_` is not supported: its `None` and `Some` would both be `undefined` | `Option` | fixtures/reject/src/lib.rs:23:15 | -| 4 | a variant of `_`, which is not supported: either is the same JS string | `std::borrow::Cow` | fixtures/reject/src/lib.rs:385:2 | +| 4 | a variant of `_`, which is not supported: either is the same JS string | `std::borrow::Cow` | fixtures/reject/src/lib.rs:392: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:115:20 | | 2 | an assignment through a reference to `_` | `std::pin::Pin` | fixtures/reject/src/lib.rs:131:2 | | 2 | replacing the value behind a reference to `_` | `Meters` | fixtures/reject/src/lib.rs:95:2 | | 1 | `_` holds `_`, which is `undefined` as `None` is, which is not supported | `std::collections::HashMap`, `std::option::Option` | fixtures/reject/src/lib.rs:288:6 | -| 1 | `_` is not supported yet | `std::borrow::Cow` | fixtures/reject/src/lib.rs:396:18 | +| 1 | `_` is not supported yet | `std::borrow::Cow` | fixtures/reject/src/lib.rs:403:18 | | 1 | `_` of `_` by `_`, which is not supported yet | `HashMap::contains_key`, `std::collections::HashMap`, `u8` | fixtures/reject/src/lib.rs:311:6 | | 1 | `_` of `_`, which drops `_`, which is not supported yet | `into_keys`, `std::collections::HashMap`, `Noisy` | fixtures/reject/src/lib.rs:53: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:47:23 | | 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:267: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:267:16 | | 1 | `_` through a held type's own, which is not supported yet | `::ne` | fixtures/reject/src/lib.rs:343: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:424:15 | +| 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 | `_` 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:417:21 | +| 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:319: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:236:26 | | 1 | a `_` cast from `_` to `_` | `IntToFloat`, `u64`, `f64` | fixtures/reject/src/lib.rs:106:2 | @@ -144,7 +146,7 @@ The type or module each refused type or path belongs to. | 1 | an iterator of the crate implementing `_`, which is not supported yet | `FusedIterator` | fixtures/reject/src/lib.rs:228:1 | | 1 | arithmetic on `_` | `f64` | fixtures/reject/src/lib.rs:8:2 | | 1 | comparing `_` as a key, which is not supported yet | `std::vec::Vec` | fixtures/reject/src/lib.rs:293:52 | -| 1 | constructing `_` | `std::borrow::Cow` | fixtures/reject/src/lib.rs:403:53 | +| 1 | constructing `_` | `std::borrow::Cow` | fixtures/reject/src/lib.rs:410:53 | | 1 | constructing `_` from another crate | `std::iter::Map` | fixtures/reject/src/lib.rs:160:23 | | 1 | constructing `_` from another crate | `std::iter::Rev` | fixtures/reject/src/lib.rs:181:14 | | 1 | hashing `_` as a key, which is not supported yet | `std::vec::Vec` | fixtures/reject/src/lib.rs:293:52 | @@ -152,12 +154,13 @@ The type or module each refused type or path belongs to. | 1 | overriding `_`, which std's adaptors call in place of `next` or beside it | `Iterator::size_hint` | fixtures/reject/src/lib.rs:208: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:379: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:380:16 | +| 1 | passing `_`, which drops, to `_`, which is not supported yet | `{closure}`, `str::contains` | fixtures/reject/src/lib.rs:387:4 | | 1 | replacing the value behind a reference to `_` | `[u16; 1]` | fixtures/reject/src/lib.rs:260:22 | -| 1 | unsupported call to `_` | `::deref` | fixtures/reject/src/lib.rs:397:2 | -| 1 | unsupported call to `_` | `::eq` | fixtures/reject/src/lib.rs:441:2 | +| 1 | unsupported call to `_` | `::deref` | fixtures/reject/src/lib.rs:404:2 | +| 1 | unsupported call to `_` | `::eq` | fixtures/reject/src/lib.rs:448:2 | | 1 | unsupported call to `_` | `::cycle` | fixtures/reject/src/lib.rs:141:11 | | 1 | unsupported call to `_` | `::write_fmt` | fixtures/reject/src/lib.rs:84:10 | -| 1 | unsupported call to `_` | `::add_assign` | fixtures/reject/src/lib.rs:411:2 | +| 1 | unsupported call to `_` | `::add_assign` | fixtures/reject/src/lib.rs:418:2 | | 1 | unsupported call to `_` | `std::ops::Range::contains` | fixtures/reject/src/lib.rs:195:8 | | 1 | unsupported call to `_` | `std::slice::copy_within` | fixtures/reject/src/lib.rs:361:4 | | 1 | unsupported call to `_` | `std::slice::sort` | fixtures/reject/src/lib.rs:28:4 | @@ -174,9 +177,9 @@ The type or module each refused type or path belongs to. - fixtures/reject/src/lib.rs:195:8: unsupported call to `std::ops::Range::::contains::` - fixtures/reject/src/lib.rs:361:4: unsupported call to `core::slice::::copy_within::>` - fixtures/reject/src/lib.rs:372:4: unsupported call to `core::str::::split::<[char; 2]>` -- fixtures/reject/src/lib.rs:397:2: unsupported call to ` as std::ops::Deref>::deref` -- fixtures/reject/src/lib.rs:411:2: unsupported call to `::add_assign` -- fixtures/reject/src/lib.rs:441:2: unsupported call to ` as std::cmp::PartialEq>::eq` +- fixtures/reject/src/lib.rs:404:2: unsupported call to ` as std::ops::Deref>::deref` +- fixtures/reject/src/lib.rs:418:2: unsupported call to `::add_assign` +- fixtures/reject/src/lib.rs:448:2: unsupported call to ` as std::cmp::PartialEq>::eq`
@@ -193,10 +196,10 @@ The type or module each refused type or path belongs to.
a variant of `_`, which is not supported: either is the same JS string (4) -- fixtures/reject/src/lib.rs:385:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string -- fixtures/reject/src/lib.rs:386:30: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string -- fixtures/reject/src/lib.rs:387:27: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string - fixtures/reject/src/lib.rs:392:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +- fixtures/reject/src/lib.rs:393:30: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +- fixtures/reject/src/lib.rs:394:27: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +- fixtures/reject/src/lib.rs:399:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string
@@ -221,8 +224,8 @@ The type or module each refused type or path belongs to.
`_` 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:417:21: `core::slice::::last_mut` with a mutable reference to a value JS copies, which its mapping would copy -- fixtures/reject/src/lib.rs:424: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 +- 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
@@ -315,7 +318,7 @@ The type or module each refused type or path belongs to.
`_` is not supported yet (1) -- fixtures/reject/src/lib.rs:396:18: `std::borrow::Cow<'_, [u8]>` is not supported yet +- fixtures/reject/src/lib.rs:403:18: `std::borrow::Cow<'_, [u8]>` is not supported yet
@@ -399,7 +402,7 @@ The type or module each refused type or path belongs to.
a mutable reference into a `Result`'s payload, passed on or kept (1) -- fixtures/reject/src/lib.rs:434:12: a mutable reference into a `Result`'s payload, passed on or kept +- fixtures/reject/src/lib.rs:441:12: a mutable reference into a `Result`'s payload, passed on or kept
@@ -447,7 +450,7 @@ The type or module each refused type or path belongs to.
constructing `_` (1) -- fixtures/reject/src/lib.rs:403:53: constructing `std::borrow::Cow<'_, std::sync::Arc>` +- fixtures/reject/src/lib.rs:410:53: constructing `std::borrow::Cow<'_, std::sync::Arc>`
@@ -463,6 +466,12 @@ The type or module each refused type or path belongs to. +
passing `_`, which drops, to `_`, which is not supported yet (1) + +- fixtures/reject/src/lib.rs:387:4: passing `{closure@fixtures/reject/src/lib.rs:387:13: 387:27}`, which drops, to `str::contains`, which is not supported yet + +
+
the `+` flag of a format spec is not supported (1) - fixtures/reject/src/lib.rs:70:3: the `+` flag of a format spec is not supported diff --git a/ts/fixtures/reject/expected.txt b/ts/fixtures/reject/expected.txt index bad0cf3c5..7b9a7ae80 100644 --- a/ts/fixtures/reject/expected.txt +++ b/ts/fixtures/reject/expected.txt @@ -57,21 +57,22 @@ comparing `std::vec::Vec` as a key, which is not supported yet at fixtures/r `HashMap::contains_key` of `std::collections::HashMap` by `u8`, which is not supported yet at fixtures/reject/src/lib.rs:311:6 unsupported call to `core::slice::::copy_within::>` at fixtures/reject/src/lib.rs:361:4 a coercion to `std::sync::Arc<[u8]>` at fixtures/reject/src/lib.rs:366:2 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:385:2 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:387:27 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:386:30 a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:392:2 -`std::borrow::Cow<'_, [u8]>` is not supported yet at fixtures/reject/src/lib.rs:396:18 -unsupported call to ` as std::ops::Deref>::deref` at fixtures/reject/src/lib.rs:397:2 -constructing `std::borrow::Cow<'_, std::sync::Arc>` at fixtures/reject/src/lib.rs:403:53 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:394:27 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:393:30 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:399:2 +`std::borrow::Cow<'_, [u8]>` is not supported yet at fixtures/reject/src/lib.rs:403:18 +unsupported call to ` as std::ops::Deref>::deref` at fixtures/reject/src/lib.rs:404:2 +constructing `std::borrow::Cow<'_, std::sync::Arc>` at fixtures/reject/src/lib.rs:410:53 unsupported call to `core::str::::split::<[char; 2]>` at fixtures/reject/src/lib.rs:372:4 passing `{closure@fixtures/reject/src/lib.rs:379:28: 379: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:379:13 passing `{closure@fixtures/reject/src/lib.rs:380:25: 380:33}`, a closure that owns a value that drops, to `Iterator::for_each`, which is not supported yet at fixtures/reject/src/lib.rs:380:16 -unsupported call to `::add_assign` at fixtures/reject/src/lib.rs:411:2 -`core::slice::::last_mut` with a mutable reference to a value JS copies, which its mapping would copy at fixtures/reject/src/lib.rs:417: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:424:15 -a mutable reference into a `Result`'s payload, passed on or kept at fixtures/reject/src/lib.rs:434:12 -unsupported call to ` as std::cmp::PartialEq>::eq` at fixtures/reject/src/lib.rs:441:2 +passing `{closure@fixtures/reject/src/lib.rs:387:13: 387:27}`, which drops, to `str::contains`, which is not supported yet at fixtures/reject/src/lib.rs:387:4 +unsupported call to `::add_assign` at fixtures/reject/src/lib.rs:418:2 +`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:154:2 an iterator of the crate implementing `DoubleEndedIterator`, which is not supported yet at fixtures/reject/src/lib.rs:174:1 overriding `Iterator::size_hint`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:208:2 diff --git a/ts/fixtures/reject/src/lib.rs b/ts/fixtures/reject/src/lib.rs index 9a6b9b3b5..2f8869f81 100644 --- a/ts/fixtures/reject/src/lib.rs +++ b/ts/fixtures/reject/src/lib.rs @@ -380,6 +380,13 @@ pub fn called_closure(v: Vec, m: &mut std::collections::HashMap 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. pub fn cow_matched(c: std::borrow::Cow<'_, str>) -> String { match c { diff --git a/ts/fixtures/reject/ts.toml b/ts/fixtures/reject/ts.toml index 35a24ebc4..ef9c40391 100644 --- a/ts/fixtures/reject/ts.toml +++ b/ts/fixtures/reject/ts.toml @@ -49,6 +49,7 @@ roots = [ "cow_made", "split_chars", "called_closure", + "pattern_closure", "duration_assign", "last_bumped", "modified", diff --git a/ts/fixtures/task/expected/drops/closures.ts b/ts/fixtures/task/expected/drops/closures.ts index 8d62255e2..25efa7809 100644 --- a/ts/fixtures/task/expected/drops/closures.ts +++ b/ts/fixtures/task/expected/drops/closures.ts @@ -1085,76 +1085,87 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { let _306!: Guard.Guard; let n!: Guard.Guard; let o!: Guard.Guard; + let t!: Guard.Guard; + let u!: Guard.Guard; + let v6!: Guard.Guard; + let _376!: Guard.Guard; + let _379!: Guard.Guard; let r!: Guard.Guard; let map!: rt.BTreeMap; let queue!: rt.VecDeque; - let _468!: boolean; - let _469!: boolean; - let _470!: boolean; - let _471!: boolean; - let _472!: boolean; - let _473!: boolean; - let _474!: boolean; - let _475!: boolean; - let _476!: boolean; - let _477!: boolean; - let _478!: boolean; - let _479!: boolean; - let _480!: boolean; - let _481!: boolean; - let _482!: boolean; - let _483!: boolean; - let _484!: boolean; - let _485!: boolean; - let _486!: boolean; - let _487!: boolean; - let _488!: boolean; + let _519!: boolean; + let _520!: boolean; + let _521!: boolean; + let _522!: boolean; + let _523!: boolean; + let _524!: boolean; + let _525!: boolean; + let _526!: boolean; + let _527!: boolean; + let _528!: boolean; + let _529!: boolean; + let _530!: boolean; + let _531!: boolean; + let _532!: boolean; + let _533!: boolean; + let _534!: boolean; + let _535!: boolean; + let _536!: boolean; + let _537!: boolean; + let _538!: boolean; + let _539!: boolean; + let _540!: boolean; + let _541!: boolean; + let _542!: boolean; let unwind: number = 0; try { - _488 = false; - _487 = false; - _486 = false; - _485 = false; - _484 = false; - _483 = false; - _482 = false; - _481 = false; - _480 = false; - _479 = false; - _478 = false; - _477 = false; - _476 = false; - _475 = false; - _474 = false; - _473 = false; - _472 = false; - _471 = false; - _470 = false; - _469 = false; - _468 = false; + _542 = false; + _541 = false; + _540 = false; + _539 = false; + _538 = false; + _537 = false; + _536 = false; + _535 = false; + _534 = false; + _533 = false; + _532 = false; + _531 = false; + _530 = false; + _529 = false; + _528 = false; + _527 = false; + _526 = false; + _525 = false; + _524 = false; + _523 = false; + _522 = false; + _521 = false; + _520 = false; + _519 = 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 args26: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(id, f), (f: rt.Formatter) => rt.u8Display(point, f)]; - rt.panicFmt(["d", args26[0], " at ", args26[1]]); + 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]]); } }; - _488 = true; + _542 = true; a = guard(1); - unwind = 271; + unwind = 301; v = []; - unwind = 234; + unwind = 260; 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 = 271; + unwind = 301; const _13: rt.Iter = rt.iterSlice(v, rt.drop); - _488 = false; + _542 = false; const captured = id; const captured2 = check; const captured3 = a; @@ -1179,28 +1190,28 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured3); })); - unwind = 269; - _487 = true; + unwind = 299; + _541 = 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.u32Display), (f: rt.Formatter) => rt.fmtOption(_41, f, rt.u32Display)]; Log.note(log, rt.fmtFormat(["map ", args2[0], " ", args2[1]])); - _487 = false; + _541 = false; rt.drop(mapped); b = guard(5); - unwind = 267; - _486 = true; + unwind = 297; + _540 = true; v2 = []; - unwind = 233; + unwind = 259; 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 = 267; + unwind = 297; const _55: rt.Iter = rt.iterSlice(v2, rt.drop); - _486 = false; + _540 = false; const captured4 = b; iter = rt.iterFilter(_55, rt.closure((g4: Guard.Guard): boolean => { return Guard.id(g4) !== rt.u32Add(Guard.id(captured4), 1); @@ -1208,41 +1219,41 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { rt.drop(captured4); }), rt.drop); while (true) { - unwind = 232; + unwind = 258; const _75: Guard.Guard | rt.Done = iter.next(); if (_75 === rt.DONE) { break; } - unwind = 231; + unwind = 257; 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 = 232; + unwind = 258; rt.drop(g); } else { - unwind = 232; + unwind = 258; rt.drop(g); break; } } - unwind = 267; + unwind = 297; rt.drop(iter); _100 = guard(9); - unwind = 230; + unwind = 256; _103 = guard(10); - unwind = 229; + unwind = 255; const _106: Guard.Guard = guard(11); - unwind = 263; - _485 = true; + unwind = 293; + _539 = true; c = _100; - _484 = true; + _538 = true; d = _103; - _483 = true; + _537 = true; e = _106; v3 = []; - unwind = 226; + unwind = 252; const _117: Guard.Guard = guard(12); v3.push(_117); const _122: Guard.Guard = guard(13); @@ -1251,23 +1262,23 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { v3.push(_127); const _132: Guard.Guard = guard(15); v3.push(_132); - unwind = 263; + unwind = 293; const _112: rt.Iter = rt.iterSlice(v3, rt.drop); - _485 = false; + _539 = 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); - _484 = false; + _538 = 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); - _483 = false; + _537 = false; const captured7 = id; const captured8 = check; const captured9 = e; @@ -1277,13 +1288,13 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { } const _173: rt.u32 = Guard.id(g7); const _192: rt.u32 = Guard.id(captured9); - const args28: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_173, f), (f: rt.Formatter) => rt.u32Display(_192, f)]; - Log.note(log, rt.fmtFormat(["inspect ", args28[0], " ", args28[1]])); + 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 = 261; - _482 = true; + unwind = 291; + _536 = true; const part2 = map$Option_Guard_u32_iterated_closure15(rt.iterToOption(chained.next()), (g8: Guard.Guard): rt.u32 => { let unwind3: number = 0; try { @@ -1320,54 +1331,54 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }); const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part3, f, rt.u32Display)]; Log.note(log, rt.fmtFormat(["chained ", args8[0]])); - _482 = false; + _536 = false; rt.drop(chained); _169 = guard(16); - unwind = 225; + unwind = 251; const _172: Guard.Guard = guard(17); - unwind = 258; - _481 = true; + unwind = 288; + _535 = true; f = _169; - _480 = true; + _534 = true; g2 = _172; const v4: rt.u32[] = []; - unwind = 223; + unwind = 249; v4.push(1); v4.push(2); v4.push(3); - unwind = 258; + unwind = 288; const _177: rt.Iter = rt.iterSlice(v4); - _481 = false; + _535 = 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); })); - _480 = false; + _534 = false; const captured11 = g2; flat = rt.iterFlatMap(_176, rt.closure((n5: rt.u32): rt.u32[] => { - const v6: rt.u32[] = []; - v6.push(n5); + const v7: rt.u32[] = []; + v7.push(n5); const _83: rt.u32 = rt.u32Add(n5, Guard.id(captured11)); - v6.push(_83); - return v6; + v7.push(_83); + return v7; }, (): void => { rt.drop(captured11); }), (value: rt.u32[]) => rt.iterSlice(value), true); - unwind = 256; - _479 = true; + unwind = 286; + _533 = true; const part4 = rt.iterToOption(flat.next()); const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part4, f, rt.u32Display)]; Log.note(log, rt.fmtFormat(["flat ", args10[0]])); check(3); - _479 = false; + _533 = false; rt.drop(flat); h = guard(18); - unwind = 254; - _478 = true; + unwind = 284; + _532 = true; const _210: rt.Iter = rt.iterSlice([1, 2, 3]); - _478 = false; + _532 = false; const captured12 = h; const whiles: rt.u32[] = rt.iterToArray(rt.iterMapWhile(_210, rt.closure((_2: rt.u32): rt.u32 | undefined => { const n6: rt.u32 = _2; @@ -1375,18 +1386,18 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured12); })), false, rt.drop); - unwind = 222; + unwind = 248; const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(whiles, f, rt.u32Display)]; Log.note(log, rt.fmtFormat(["map_while ", args12[0]])); _227 = guard(19); - unwind = 221; + unwind = 247; const _230: Guard.Guard = guard(20); - unwind = 251; - _477 = true; + unwind = 281; + _531 = true; i = _227; - _476 = true; + _530 = true; j = _230; - _477 = false; + _531 = false; const captured13 = check; const captured14 = i; const made: rt.usize = rt.ownedCount(rt.iterTake(rt.iterFromFn(rt.closure((): rt.u32 | undefined => { @@ -1395,7 +1406,7 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured14); })), 2), rt.drop); - _476 = false; + _530 = false; const captured15 = j; const walked: rt.u32 = rt.iterSum(rt.iterSuccessors(1, rt.closure((_26: rt.u32): rt.u32 | undefined => { const n7: rt.u32 = _26; @@ -1404,10 +1415,10 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { rt.drop(captured15); })), rt.u32Add, 0, rt.drop); s = guard(43); - unwind = 249; - _475 = true; + unwind = 279; + _529 = true; const _245: Guard.Guard | undefined = guard(40); - _475 = false; + _529 = false; const captured16 = id; const captured17 = check; const captured18 = s; @@ -1421,8 +1432,8 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured18); }), rt.drop); - unwind = 247; - _474 = true; + unwind = 277; + _528 = true; const _256: rt.u32 | undefined = map$Option_Guard_u32_iterated_closure15(rt.iterToOption(chain.next()), (g11: Guard.Guard): rt.u32 => { let unwind5: number = 0; try { @@ -1459,32 +1470,32 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }); const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part5, f, rt.u32Display)]; Log.note(log, rt.fmtFormat(["successor ", args16[0]])); - _474 = false; + _528 = false; rt.drop(chain); v5 = []; - unwind = 219; + unwind = 245; const _286: Guard.Guard = guard(21); v5.push(_286); const _291: Guard.Guard = guard(22); v5.push(_291); const _296: Guard.Guard = guard(23); v5.push(_296); - unwind = 218; + unwind = 244; items = v5; _303 = guard(24); - unwind = 217; + unwind = 243; _306 = guard(25); - unwind = 216; + unwind = 242; const _309: Guard.Guard = guard(26); - unwind = 243; - _473 = true; + unwind = 273; + _527 = true; k = _303; - _472 = true; + _526 = true; l = _306; - _471 = true; + _525 = true; m = _309; const _314: rt.Iter = rt.iterSlice(items); - _473 = false; + _527 = false; const captured19 = id; const captured20 = check; const captured21 = k; @@ -1498,7 +1509,7 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }); const any: boolean = rt.dropAfter(_317, () => rt.iterAny(_314, _317)); const _321: rt.Iter = rt.iterSlice(items); - _472 = false; + _526 = false; const captured22 = l; const _324: (a0: Guard.Guard) => boolean = rt.closure((g14: Guard.Guard): boolean => { return Guard.id(g14) === rt.u32Sub(Guard.id(captured22), 3); @@ -1509,7 +1520,7 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { return Guard.id(g15); }); const _327: rt.Iter = rt.iterSlice(items); - _471 = false; + _525 = false; const captured23 = m; const _330: (a0: Guard.Guard) => boolean = rt.closure((g16: Guard.Guard): boolean => { return rt.u32Add(Guard.id(g16), 2) === Guard.id(captured23); @@ -1520,10 +1531,10 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(any, f), (f: rt.Formatter) => rt.fmtOption(found, f, rt.u32Display), (f: rt.Formatter) => rt.fmtOption(atPos, f, rt.usizeDisplay)]; Log.note(log, rt.fmtFormat(["found ", args18[0], " ", args18[1], " ", args18[2]])); n = guard(27); - unwind = 241; - _470 = true; + unwind = 271; + _524 = true; const _350: rt.Iter = rt.iterSlice([1, 2, 3]); - _470 = false; + _524 = false; const captured24 = n; const sum: rt.u32 = rt.iterSum(rt.iterMap(_350, rt.closure((_29: rt.u32): rt.u32 => { return rt.u32Add(_29, Guard.id(captured24)); @@ -1531,47 +1542,85 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { rt.drop(captured24); })), rt.u32Add, 0, rt.drop); o = guard(28); - unwind = 239; - _469 = true; + unwind = 269; + _523 = true; const _358: rt.Iter = rt.iterSlice([1, 2]); - _469 = false; + _523 = false; const captured25 = o; const _361: (a0: rt.u32) => void = rt.closure((_214: rt.u32): void => { const part6 = rt.u32Add(_214, Guard.id(captured25)); - const args30: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(part6, f)]; - Log.note(log, rt.fmtFormat(["each ", args30[0]])); + const args32: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(part6, f)]; + Log.note(log, rt.fmtFormat(["each ", args32[0]])); }, (): void => { rt.drop(captured25); }); rt.dropAfter(_361, () => rt.iterForEach(_358, _361)); const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(sum, f)]; Log.note(log, rt.fmtFormat(["sum ", args20[0]])); + _376 = guard(44); + unwind = 239; + _379 = guard(45); + unwind = 238; + const _382: Guard.Guard = guard(46); + unwind = 265; + _522 = true; + t = _376; + _521 = true; + u = _379; + _520 = true; + v6 = _382; + const _388: rt.Iter = rt.iterSlice([1, 2]); + _522 = false; + const captured26 = t; + const peeked: rt.usize = rt.ownedCount(rt.iterPeekable(rt.iterMap(_388, rt.closure((_218: rt.u32): rt.u32 => { + return rt.u32Add(_218, Guard.id(captured26)); + }, (): void => { + rt.drop(captured26); + }))), rt.drop); + const _395: rt.Iter = rt.iterSlice([1, 2, 3]); + _521 = false; + const captured27 = u; + const skipped: rt.usize = rt.ownedCount(rt.iterSkip(rt.iterMap(_395, rt.closure((_219: rt.u32): rt.u32 => { + return rt.u32Add(_219, Guard.id(captured27)); + }, (): void => { + rt.drop(captured27); + })), 1), rt.drop); + const _402: rt.Iter = rt.iterSlice([1, 2]); + _520 = false; + const captured28 = v6; + const last: rt.u32 | undefined = rt.ownedLast(rt.iterSkip(rt.iterMap(_402, rt.closure((_220: rt.u32): rt.u32 => { + return rt.u32Add(_220, Guard.id(captured28)); + }, (): void => { + rt.drop(captured28); + })), 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.u32Display)]; + Log.note(log, rt.fmtFormat(["counted ", args22[0], " ", args22[1], " ", args22[2]])); r = guard(36); - unwind = 237; - _468 = true; - const _376: rt.Iter = rt.iterMap(rt.iterSlice([1, 2, 3]), (_218: rt.u32): Guard.Guard => { - return guard(rt.u32Add(36, _218)); + unwind = 263; + _519 = true; + const _424: rt.Iter = rt.iterMap(rt.iterSlice([1, 2, 3]), (_223: rt.u32): Guard.Guard => { + return guard(rt.u32Add(36, _223)); }); - _468 = false; - const captured26 = id; - const captured27 = check; - const captured28 = r; - const _382: (a0: Guard.Guard) => rt.u32 = rt.closure((g17: Guard.Guard): rt.u32 => { - if (Guard.id(g17) === rt.u32Add(captured26, 38)) { - captured27(7); + _519 = false; + const captured29 = id; + const captured30 = check; + const captured31 = r; + const _430: (a0: Guard.Guard) => rt.u32 = rt.closure((g17: Guard.Guard): rt.u32 => { + if (Guard.id(g17) === rt.u32Add(captured29, 38)) { + captured30(7); } - return rt.u32Add(rt.u32Rem(Guard.id(g17), 2), Guard.id(captured28)); + return rt.u32Add(rt.u32Rem(Guard.id(g17), 2), Guard.id(captured31)); }, (): void => { - rt.drop(captured28); + rt.drop(captured31); }); - const part8 = map$Option_Guard_u32_iterated_closure15(rt.dropAfter(_382, () => rt.iterMaxByKey(_376, _382, undefined, rt.drop)), (g18: Guard.Guard): rt.u32 => { + const part8 = map$Option_Guard_u32_iterated_closure15(rt.dropAfter(_430, () => rt.iterMaxByKey(_424, _430, undefined, rt.drop)), (g18: Guard.Guard): rt.u32 => { let unwind7: number = 0; try { unwind7 = 4; - const _024: rt.u32 = Guard.id(g18); + const _027: rt.u32 = Guard.id(g18); unwind7 = 0; rt.drop(g18); - return _024; + return _027; } catch (e8) { if (unwind7 === 0) { throw e8; @@ -1580,80 +1629,83 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { throw e8; } }); - const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part8, f, rt.u32Display)]; - Log.note(log, rt.fmtFormat(["best ", args22[0]])); + const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part8, f, rt.u32Display)]; + Log.note(log, rt.fmtFormat(["best ", args24[0]])); map = rt.btreeNew(rt.cmp) as rt.BTreeMap; - unwind = 213; + unwind = 235; 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 = 212; - const _401: [rt.u32, rt.u32] | rt.Done = iter2.next(); - if (_401 === rt.DONE) { + unwind = 234; + const _449: [rt.u32, rt.u32] | rt.Done = iter2.next(); + if (_449 === rt.DONE) { break; } - const k2: rt.u32 = _401[0]; - const _408: Guard.Guard = guard(_401[1]); - rt.drop(rt.btreeInsert(map, k2, _408, undefined, rt.drop)); + const k2: rt.u32 = _449[0]; + const _456: Guard.Guard = guard(_449[1]); + rt.drop(rt.btreeInsert(map, k2, _456, undefined, rt.drop)); } - unwind = 213; + unwind = 235; const p: Guard.Guard = guard(32); - const captured29 = check; - const captured30 = p; - const captured31 = id; - const _416: (a0: rt.u32, a1: Guard.Guard) => boolean = rt.closure((_219: rt.u32, _329: Guard.Guard): boolean => { - const k3: rt.u32 = _219; + const captured32 = check; + const captured33 = p; + const captured34 = id; + const _464: (a0: rt.u32, a1: Guard.Guard) => boolean = rt.closure((_224: rt.u32, _329: Guard.Guard): boolean => { + const k3: rt.u32 = _224; if (k3 === 2) { - captured29(6); + captured32(6); } - return rt.u32Add(k3, Guard.id(captured30)) !== rt.u32Add(captured31, 34); + return rt.u32Add(k3, Guard.id(captured33)) !== rt.u32Add(captured34, 34); }, (): void => { - rt.drop(captured30); + rt.drop(captured33); }); - rt.dropAfter(_416, () => rt.btreeRetain(map, _416, undefined, rt.drop)); + rt.dropAfter(_464, () => rt.btreeRetain(map, _464, undefined, rt.drop)); queue = rt.dequeNew() as rt.VecDeque; - unwind = 211; - const _420: Guard.Guard = guard(33); - rt.dequePushBack(queue, _420); - const _425: Guard.Guard = guard(34); - rt.dequePushBack(queue, _425); - const captured32 = guard(35); - const _433: (a0: Guard.Guard) => boolean = rt.closure((g19: Guard.Guard): boolean => { - return rt.u32Add(Guard.id(g19), 2) !== Guard.id(captured32); + unwind = 233; + const _468: Guard.Guard = guard(33); + rt.dequePushBack(queue, _468); + const _473: Guard.Guard = guard(34); + rt.dequePushBack(queue, _473); + const captured35 = guard(35); + const _481: (a0: Guard.Guard) => boolean = rt.closure((g19: Guard.Guard): boolean => { + return rt.u32Add(Guard.id(g19), 2) !== Guard.id(captured35); }, (): void => { - rt.drop(captured32); + rt.drop(captured35); }); - rt.dropAfter(_433, () => rt.dequeRetain(queue, _433, rt.drop)); - const _440: rt.usize = rt.btreeLen(map); - const _443: rt.usize = queue.n; - const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(_440, f), (f: rt.Formatter) => rt.usizeDisplay(_443, f)]; - Log.note(log, rt.fmtFormat(["retained ", args24[0], " ", args24[1]])); - unwind = 213; + rt.dropAfter(_481, () => rt.dequeRetain(queue, _481, rt.drop)); + const _488: rt.usize = rt.btreeLen(map); + const _491: rt.usize = queue.n; + const args26: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(_488, f), (f: rt.Formatter) => rt.usizeDisplay(_491, f)]; + Log.note(log, rt.fmtFormat(["retained ", args26[0], " ", args26[1]])); + unwind = 235; rt.dequeDrop(queue, rt.drop); - unwind = 237; + unwind = 263; rt.btreeDrop(map, undefined, rt.drop); - unwind = 247; - _468 = false; - _469 = false; - _470 = false; - _471 = false; - _472 = false; - _473 = false; + unwind = 277; + _519 = false; + _520 = false; + _521 = false; + _522 = false; + _523 = false; + _524 = false; + _525 = false; + _526 = false; + _527 = false; rt.dropAll(items); - _474 = false; - _475 = false; - _476 = false; - _477 = false; - _478 = false; - _479 = false; - _480 = false; - _481 = false; - _482 = false; - _483 = false; - _484 = false; - _485 = false; - _486 = false; - _487 = false; - _488 = false; + _528 = false; + _529 = false; + _530 = false; + _531 = false; + _532 = false; + _533 = false; + _534 = false; + _535 = false; + _536 = false; + _537 = false; + _538 = false; + _539 = false; + _540 = false; + _541 = false; + _542 = false; } catch (e2) { b4: { b5: { @@ -1675,202 +1727,227 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { b21: { b22: { b23: { - if (unwind === 0) { - throw e2; - } - if (unwind === 211) { - rt.dequeDrop(queue, rt.drop); - break b21; - } - if (unwind === 212) { - break b21; - } - if (unwind === 213) { - break b21; - } - if (unwind === 216) { - rt.drop(_306); - break b22; - } - if (unwind === 217) { - break b22; - } - if (unwind === 218) { - break b16; - } - if (unwind === 219) { - rt.dropAll(v5); - break b15; - } - if (unwind === 221) { - rt.drop(_227); - break b12; - } - if (unwind === 222) { - break b12; - } - if (unwind === 223) { - break b9; - } - if (unwind === 225) { - rt.drop(_169); - break b8; - } - if (unwind === 226) { - rt.dropAll(v3); - break b7; - } - if (unwind === 229) { - rt.drop(_103); - break b23; - } - if (unwind === 230) { - break b23; - } - if (unwind === 231) { - rt.drop(g); - } else if (unwind !== 232) { - if (unwind === 233) { - rt.dropAll(v2); - break b6; - } - if (unwind === 234) { - rt.dropAll(v); - break b4; - } - if (unwind === 237) { - break b20; - } - if (unwind === 239) { - break b19; - } - if (unwind === 241) { - break b18; - } - if (unwind === 243) { - break b17; - } - if (unwind === 247) { - break b15; - } - if (unwind === 249) { - break b14; - } - if (unwind === 251) { - break b13; - } - if (unwind === 254) { - break b11; - } - if (unwind === 256) { - break b10; - } - if (unwind === 258) { - break b9; - } - if (unwind === 261) { - break b8; - } - if (unwind === 263) { - break b7; - } - if (unwind === 267) { + b24: { + b25: { + if (unwind === 0) { + throw e2; + } + if (unwind === 233) { + rt.dequeDrop(queue, rt.drop); + break b22; + } + if (unwind === 234) { + break b22; + } + if (unwind === 235) { + break b22; + } + if (unwind === 238) { + rt.drop(_379); + break b23; + } + if (unwind === 239) { + break b23; + } + if (unwind === 242) { + rt.drop(_306); + break b24; + } + if (unwind === 243) { + break b24; + } + if (unwind === 244) { + break b16; + } + if (unwind === 245) { + rt.dropAll(v5); + break b15; + } + if (unwind === 247) { + rt.drop(_227); + break b12; + } + if (unwind === 248) { + break b12; + } + if (unwind === 249) { + break b9; + } + if (unwind === 251) { + rt.drop(_169); + break b8; + } + if (unwind === 252) { + rt.dropAll(v3); + break b7; + } + if (unwind === 255) { + rt.drop(_103); + break b25; + } + if (unwind === 256) { + break b25; + } + if (unwind === 257) { + rt.drop(g); + } else if (unwind !== 258) { + if (unwind === 259) { + rt.dropAll(v2); + break b6; + } + if (unwind === 260) { + rt.dropAll(v); + break b4; + } + if (unwind === 263) { + break b21; + } + if (unwind === 265) { + break b20; + } + if (unwind === 269) { + break b19; + } + if (unwind === 271) { + break b18; + } + if (unwind === 273) { + break b17; + } + if (unwind === 277) { + break b15; + } + if (unwind === 279) { + break b14; + } + if (unwind === 281) { + break b13; + } + if (unwind === 284) { + break b11; + } + if (unwind === 286) { + break b10; + } + if (unwind === 288) { + break b9; + } + if (unwind === 291) { + break b8; + } + if (unwind === 293) { + break b7; + } + if (unwind === 297) { + break b6; + } + if (unwind === 299) { + break b5; + } + break b4; + } + rt.drop(iter); break b6; } - if (unwind === 269) { - break b5; - } - break b4; + rt.drop(_100); + break b6; } - rt.drop(iter); - break b6; + rt.drop(_303); + break b16; } - rt.drop(_100); - break b6; + rt.drop(_376); + break b19; } - rt.drop(_303); - break b16; + rt.btreeDrop(map, undefined, rt.drop); + } + if (_519) { + rt.drop(r); } - rt.btreeDrop(map, undefined, rt.drop); } - if (_468) { - rt.drop(r); + if (_520) { + rt.drop(v6); + } + if (_521) { + rt.drop(u); + } + if (_522) { + rt.drop(t); } } - if (_469) { + if (_523) { rt.drop(o); } } - if (_470) { + if (_524) { rt.drop(n); } } - if (_471) { + if (_525) { rt.drop(m); } - if (_472) { + if (_526) { rt.drop(l); } - if (_473) { + if (_527) { rt.drop(k); } } rt.dropAll(items); } - if (_474) { + if (_528) { rt.drop(chain); } } - if (_475) { + if (_529) { rt.drop(s); } } - if (_476) { + if (_530) { rt.drop(j); } - if (_477) { + if (_531) { rt.drop(i); } } } - if (_478) { + if (_532) { rt.drop(h); } } - if (_479) { + if (_533) { rt.drop(flat); } } - if (_480) { + if (_534) { rt.drop(g2); } - if (_481) { + if (_535) { rt.drop(f); } } - if (_482) { + if (_536) { rt.drop(chained); } } - if (_483) { + if (_537) { rt.drop(e); } - if (_484) { + if (_538) { rt.drop(d); } - if (_485) { + if (_539) { rt.drop(c); } } - if (_486) { + if (_540) { rt.drop(b); } } - if (_487) { + if (_541) { rt.drop(mapped); } } - if (_488) { + if (_542) { rt.drop(a); } throw e2; diff --git a/ts/fixtures/task/src/drops/closures.rs b/ts/fixtures/task/src/drops/closures.rs index b929dbe79..06355ebc1 100644 --- a/ts/fixtures/task/src/drops/closures.rs +++ b/ts/fixtures/task/src/drops/closures.rs @@ -281,6 +281,13 @@ pub(super) fn iterated(log: &Log, id: u32, at: u8) { .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| { diff --git a/ts/runtime/rt/iter.ts b/ts/runtime/rt/iter.ts index fb4e0d829..e570af793 100644 --- a/ts/runtime/rt/iter.ts +++ b/ts/runtime/rt/iter.ts @@ -101,9 +101,13 @@ abstract class Adaptor extends Iter implements Disposable { } } -/** An adaptor of `inner` that calls `f`, which drops after it, as std's fields do. */ +/** + * 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); @@ -111,6 +115,8 @@ abstract class Calling extends Adaptor { } override [Symbol.dispose](): void { + if (this.dropped) return; + this.dropped = true; both( () => dispose(this.inner), () => dispose(this.f), @@ -999,11 +1005,12 @@ class FromNext extends Iter implements Disposable { } } -/** `Successors`, holding the item it yields next. */ +/** `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(); @@ -1023,6 +1030,8 @@ class SuccessorsIter extends Iter implements Disposable { } [Symbol.dispose](): void { + if (this.dropped) return; + this.dropped = true; const item = this.item; this.item = undefined; both( diff --git a/ts/src/lower/library.rs b/ts/src/lower/library.rs index 9d2038e35..f11cbba34 100644 --- a/ts/src/lower/library.rs +++ b/ts/src/lower/library.rs @@ -504,7 +504,6 @@ fn called_closures<'tcx>( let sig = tcx.instantiate_bound_regions_with_erased(sig); let inputs = sig.inputs().to_vec(); let output = sig.output(); - let bounds = tcx.param_env(call.def_id).caller_bounds(); for (i, &input) in inputs.iter().enumerate() { let ty::Param(param) = *input.kind() else { continue; @@ -513,18 +512,7 @@ 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) { @@ -564,10 +552,27 @@ fn called_closures<'tcx>( closures } -/// The first type `call` takes by value that drops, but for a closure, which -/// `called_closures` decides. +/// 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, 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. @@ -580,9 +585,14 @@ fn dropping_operand<'tcx>(b: &mut Body<'_, '_, 'tcx>, call: &Call<'tcx>) -> Opti .unwrap_or(ty) }) .collect(); + 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() - .find(|&ty| !matches!(ty.kind(), ty::Closure(..)) && b.t.drops(ty)) + .enumerate() + .find(|&(i, ty)| !called(i, ty) && b.t.drops(ty)) + .map(|(_, ty)| ty) } /// `owner::name` for a standard library function. From c54d1b687ec38fabb0628cc6a66496b0a8d02b64 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Wed, 28 Oct 2026 00:33:34 -0700 Subject: [PATCH 7/7] fix(ts): keep an ended flat_map's closure when its source is fused std's `FlatMap` holds `Fuse>`, which keeps the mapped source, `F` included, once it ends if `I` is a `FusedIterator`. `fused` looked only at the source, so a `flat_map` over a borrowed slice dropped its closure as it ended. Co-Authored-By: Claude Opus 5.5 --- ts/fixtures/task/expected/core/option.ts | 2 +- ts/fixtures/task/expected/drops/closures.ts | 1025 ++++++++++--------- ts/fixtures/task/src/drops/closures.rs | 6 + ts/src/lower/iter.rs | 15 +- 4 files changed, 550 insertions(+), 498 deletions(-) diff --git a/ts/fixtures/task/expected/core/option.ts b/ts/fixtures/task/expected/core/option.ts index 8d7e65e3b..1398aa065 100644 --- a/ts/fixtures/task/expected/core/option.ts +++ b/ts/fixtures/task/expected/core/option.ts @@ -35,7 +35,7 @@ export function unwrapOr$Option_u64(self: rt.u64 | undefined, default_: rt.u64): return self; } -export function map$Option_Guard_u32_iterated_closure15(self: Guard.Guard | undefined, f: (a0: Guard.Guard) => rt.u32): rt.u32 | undefined { +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; } diff --git a/ts/fixtures/task/expected/drops/closures.ts b/ts/fixtures/task/expected/drops/closures.ts index e253b11fe..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_Guard_u32_iterated_closure15, 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"; @@ -1070,10 +1070,12 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { 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 _227!: Guard.Guard; + let _245!: Guard.Guard; let s!: Guard.Guard; let chain!: rt.Iter; let items!: Guard.Guard[]; @@ -1081,68 +1083,72 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { let k!: Guard.Guard; let l!: Guard.Guard; let m!: Guard.Guard; - let _303!: Guard.Guard; - let _306!: 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 _376!: Guard.Guard; - let _379!: Guard.Guard; + let _394!: Guard.Guard; + let _397!: Guard.Guard; let r!: Guard.Guard; let map!: rt.BTreeMap; let queue!: rt.VecDeque; - let _519!: boolean; - let _520!: boolean; - let _521!: boolean; - let _522!: boolean; - let _523!: boolean; - let _524!: boolean; - let _525!: boolean; - let _526!: boolean; - let _527!: boolean; - let _528!: boolean; - let _529!: boolean; - let _530!: boolean; - let _531!: boolean; - let _532!: boolean; - let _533!: boolean; - let _534!: boolean; - let _535!: boolean; - let _536!: boolean; 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; - _536 = false; - _535 = false; - _534 = false; - _533 = false; - _532 = false; - _531 = false; - _530 = false; - _529 = false; - _528 = false; - _527 = false; - _526 = false; - _525 = false; - _524 = false; - _523 = false; - _522 = false; - _521 = false; - _520 = false; - _519 = false; const guard: (a0: rt.u32) => Guard.Guard = (n3: rt.u32): Guard.Guard => { return Guard.new(rt.u32Add(id, n3), Log.clone$Clone(log)); }; @@ -1152,20 +1158,20 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { rt.panicFmt(["d", args28[0], " at ", args28[1]]); } }; - _542 = true; + _562 = true; a = guard(1); - unwind = 301; + unwind = 317; v = []; - unwind = 260; + 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 = 301; + unwind = 317; const _13: rt.Iter = rt.iterSlice(v, rt.drop); - _542 = false; + _562 = false; const captured = id; const captured2 = check; const captured3 = a; @@ -1190,28 +1196,28 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured3); })); - unwind = 299; - _541 = true; + 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]])); - _541 = false; + _561 = false; rt.drop(mapped); b = guard(5); - unwind = 297; - _540 = true; + unwind = 313; + _560 = true; v2 = []; - unwind = 259; + 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 = 297; + unwind = 313; const _55: rt.Iter = rt.iterSlice(v2, rt.drop); - _540 = false; + _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); @@ -1219,41 +1225,41 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { rt.drop(captured4); }), rt.drop); while (true) { - unwind = 258; + unwind = 270; const _75: Guard.Guard | rt.Done = iter.next(); if (_75 === rt.DONE) { break; } - unwind = 257; + 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 = 258; + unwind = 270; rt.drop(g); } else { - unwind = 258; + unwind = 270; rt.drop(g); break; } } - unwind = 297; + unwind = 313; rt.drop(iter); _100 = guard(9); - unwind = 256; + unwind = 268; _103 = guard(10); - unwind = 255; + unwind = 267; const _106: Guard.Guard = guard(11); - unwind = 293; - _539 = true; + unwind = 309; + _559 = true; c = _100; - _538 = true; + _558 = true; d = _103; - _537 = true; + _557 = true; e = _106; v3 = []; - unwind = 252; + unwind = 264; const _117: Guard.Guard = guard(12); v3.push(_117); const _122: Guard.Guard = guard(13); @@ -1262,23 +1268,23 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { v3.push(_127); const _132: Guard.Guard = guard(15); v3.push(_132); - unwind = 293; + unwind = 309; const _112: rt.Iter = rt.iterSlice(v3, rt.drop); - _539 = false; + _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); - _538 = false; + _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); - _537 = false; + _557 = false; const captured7 = id; const captured8 = check; const captured9 = e; @@ -1293,9 +1299,9 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured9); }), rt.drop); - unwind = 291; - _536 = true; - const part2 = map$Option_Guard_u32_iterated_closure15(rt.iterToOption(chained.next()), (g8: Guard.Guard): rt.u32 => { + 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; @@ -1313,7 +1319,7 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }); 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_closure15(rt.iterToOption(chained.next()), (g9: Guard.Guard): rt.u32 => { + const part3 = map$Option_Guard_u32_iterated_closure16(rt.iterToOption(chained.next()), (g9: Guard.Guard): rt.u32 => { let unwind4: number = 0; try { unwind4 = 4; @@ -1331,31 +1337,31 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }); const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part3, f, rt.u32Debug)]; Log.note(log, rt.fmtFormat(["chained ", args8[0]])); - _536 = false; + _556 = false; rt.drop(chained); _169 = guard(16); - unwind = 251; + unwind = 263; const _172: Guard.Guard = guard(17); - unwind = 288; - _535 = true; + unwind = 304; + _555 = true; f = _169; - _534 = true; + _554 = true; g2 = _172; const v4: rt.u32[] = []; - unwind = 249; + unwind = 261; v4.push(1); v4.push(2); v4.push(3); - unwind = 288; + unwind = 304; const _177: rt.Iter = rt.iterSlice(v4); - _535 = false; + _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); })); - _534 = false; + _554 = false; const captured11 = g2; flat = rt.iterFlatMap(_176, rt.closure((n5: rt.u32): rt.u32[] => { const v7: rt.u32[] = []; @@ -1366,82 +1372,103 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured11); }), (value: rt.u32[]) => rt.iterSlice(value), true); - unwind = 286; - _533 = 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); - _533 = false; + _553 = false; rt.drop(flat); - h = guard(18); - unwind = 284; - _532 = true; - const _210: rt.Iter = rt.iterSlice([1, 2, 3]); - _532 = false; - const captured12 = h; - const whiles: rt.u32[] = rt.iterToArray(rt.iterMapWhile(_210, rt.closure((_2: rt.u32): rt.u32 | undefined => { - const n6: rt.u32 = _2; - return rt.thenSome(n6 < 3, rt.u32Add(n6, Guard.id(captured12))); + 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 = 248; + unwind = 260; const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(whiles, f, rt.u32Debug)]; Log.note(log, rt.fmtFormat(["map_while ", args12[0]])); - _227 = guard(19); - unwind = 247; - const _230: Guard.Guard = guard(20); - unwind = 281; - _531 = true; - i = _227; - _530 = true; - j = _230; - _531 = false; - const captured13 = check; - const captured14 = i; + _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 => { - captured13(4); - return Guard.id(captured14); + captured14(4); + return Guard.id(captured15); }, (): void => { - rt.drop(captured14); + rt.drop(captured15); })), 2), rt.drop); - _530 = false; - const captured15 = j; - const walked: rt.u32 = rt.iterSum(rt.iterSuccessors(1, rt.closure((_26: rt.u32): rt.u32 | undefined => { - const n7: rt.u32 = _26; - return rt.thenSome(n7 < 3, rt.u32Sub(rt.u32Add(rt.u32Add(n7, 1), Guard.id(captured15)), Guard.id(captured15))); + _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(captured15); + rt.drop(captured16); })), rt.u32Add, 0, rt.drop); s = guard(43); - unwind = 279; - _529 = true; - const _245: Guard.Guard | undefined = guard(40); - _529 = false; - const captured16 = id; - const captured17 = check; - const captured18 = s; - chain = rt.iterSuccessors(_245, rt.closure((g10: Guard.Guard): Guard.Guard | undefined => { - if (Guard.id(g10) === rt.u32Add(captured16, 41)) { - captured17(8); + 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(captured18), (): Guard.Guard => { + 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(captured18); + rt.drop(captured19); }), rt.drop); - unwind = 277; - _528 = true; - const _256: rt.u32 | undefined = map$Option_Guard_u32_iterated_closure15(rt.iterToOption(chain.next()), (g11: Guard.Guard): rt.u32 => { + 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 _015: rt.u32 = Guard.id(g11); + const _016: rt.u32 = Guard.id(g11); unwind5 = 0; rt.drop(g11); - return _015; + return _016; } catch (e6) { if (unwind5 === 0) { throw e6; @@ -1450,16 +1477,16 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { 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(_256, f, rt.u32Debug)]; + 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_closure15(rt.iterToOption(chain.next()), (g12: Guard.Guard): rt.u32 => { + 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 _016: rt.u32 = Guard.id(g12); + const _017: rt.u32 = Guard.id(g12); unwind6 = 0; rt.drop(g12); - return _016; + return _017; } catch (e7) { if (unwind6 === 0) { throw e7; @@ -1470,157 +1497,157 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }); const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part5, f, rt.u32Debug)]; Log.note(log, rt.fmtFormat(["successor ", args16[0]])); - _528 = false; + _546 = false; rt.drop(chain); v5 = []; - unwind = 245; - const _286: Guard.Guard = guard(21); - v5.push(_286); - const _291: Guard.Guard = guard(22); - v5.push(_291); - const _296: Guard.Guard = guard(23); - v5.push(_296); - unwind = 244; + 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; - _303 = guard(24); - unwind = 243; - _306 = guard(25); - unwind = 242; - const _309: Guard.Guard = guard(26); - unwind = 273; - _527 = true; - k = _303; - _526 = true; - l = _306; - _525 = true; - m = _309; - const _314: rt.Iter = rt.iterSlice(items); - _527 = false; - const captured19 = id; - const captured20 = check; - const captured21 = k; - const _317: (a0: Guard.Guard) => boolean = rt.closure((g13: Guard.Guard): boolean => { - if (Guard.id(g13) === rt.u32Add(captured19, 22)) { - captured20(5); + _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(captured21); + return Guard.id(g13) === Guard.id(captured22); }, (): void => { - rt.drop(captured21); + rt.drop(captured22); }); - const any: boolean = rt.dropAfter(_317, () => rt.iterAny(_314, _317)); - const _321: rt.Iter = rt.iterSlice(items); - _526 = false; - const captured22 = l; - const _324: (a0: Guard.Guard) => boolean = rt.closure((g14: Guard.Guard): boolean => { - return Guard.id(g14) === rt.u32Sub(Guard.id(captured22), 3); + 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(captured22); + rt.drop(captured23); }); - const found: rt.u32 | undefined = map$Option_Guard_u32_iterated_closure15(rt.dropAfter(_324, () => rt.iterFind(_321, _324)), (g15: Guard.Guard): rt.u32 => { + 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 _327: rt.Iter = rt.iterSlice(items); - _525 = false; - const captured23 = m; - const _330: (a0: Guard.Guard) => boolean = rt.closure((g16: Guard.Guard): boolean => { - return rt.u32Add(Guard.id(g16), 2) === Guard.id(captured23); + 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(captured23); + rt.drop(captured24); }); - const atPos: rt.usize | undefined = rt.dropAfter(_330, () => rt.iterPosition(_327, _330)); + 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 = 271; - _524 = true; - const _350: rt.Iter = rt.iterSlice([1, 2, 3]); - _524 = false; - const captured24 = n; - const sum: rt.u32 = rt.iterSum(rt.iterMap(_350, rt.closure((_29: rt.u32): rt.u32 => { - return rt.u32Add(_29, Guard.id(captured24)); + 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(captured24); + rt.drop(captured25); })), rt.u32Add, 0, rt.drop); o = guard(28); - unwind = 269; - _523 = true; - const _358: rt.Iter = rt.iterSlice([1, 2]); - _523 = false; - const captured25 = o; - const _361: (a0: rt.u32) => void = rt.closure((_214: rt.u32): void => { - const part6 = rt.u32Add(_214, Guard.id(captured25)); + 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(captured25); + rt.drop(captured26); }); - rt.dropAfter(_361, () => rt.iterForEach(_358, _361)); + 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]])); - _376 = guard(44); - unwind = 239; - _379 = guard(45); - unwind = 238; - const _382: Guard.Guard = guard(46); - unwind = 265; - _522 = true; - t = _376; - _521 = true; - u = _379; - _520 = true; - v6 = _382; - const _388: rt.Iter = rt.iterSlice([1, 2]); - _522 = false; - const captured26 = t; - const peeked: rt.usize = rt.ownedCount(rt.iterPeekable(rt.iterMap(_388, rt.closure((_218: rt.u32): rt.u32 => { - return rt.u32Add(_218, Guard.id(captured26)); + _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(captured26); + rt.drop(captured27); }))), rt.drop); - const _395: rt.Iter = rt.iterSlice([1, 2, 3]); - _521 = false; - const captured27 = u; - const skipped: rt.usize = rt.ownedCount(rt.iterSkip(rt.iterMap(_395, rt.closure((_219: rt.u32): rt.u32 => { - return rt.u32Add(_219, Guard.id(captured27)); + 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(captured27); + rt.drop(captured28); })), 1), rt.drop); - const _402: rt.Iter = rt.iterSlice([1, 2]); - _520 = false; - const captured28 = v6; - const last: rt.u32 | undefined = rt.ownedLast(rt.iterSkip(rt.iterMap(_402, rt.closure((_220: rt.u32): rt.u32 => { - return rt.u32Add(_220, Guard.id(captured28)); + 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(captured28); + 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 = 263; - _519 = true; - const _424: rt.Iter = rt.iterMap(rt.iterSlice([1, 2, 3]), (_223: rt.u32): Guard.Guard => { - return guard(rt.u32Add(36, _223)); + 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)); }); - _519 = false; - const captured29 = id; - const captured30 = check; - const captured31 = r; - const _430: (a0: Guard.Guard) => rt.u32 = rt.closure((g17: Guard.Guard): rt.u32 => { - if (Guard.id(g17) === rt.u32Add(captured29, 38)) { - captured30(7); + _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(captured31)); + return rt.u32Add(rt.u32Rem(Guard.id(g17), 2), Guard.id(captured32)); }, (): void => { - rt.drop(captured31); + rt.drop(captured32); }); - const part8 = map$Option_Guard_u32_iterated_closure15(rt.dropAfter(_430, () => rt.iterMaxByKey(_424, _430, undefined, rt.drop)), (g18: Guard.Guard): rt.u32 => { + 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 _027: rt.u32 = Guard.id(g18); + const _028: rt.u32 = Guard.id(g18); unwind7 = 0; rt.drop(g18); - return _027; + return _028; } catch (e8) { if (unwind7 === 0) { throw e8; @@ -1632,322 +1659,340 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { 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 = 235; + 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 = 234; - const _449: [rt.u32, rt.u32] | rt.Done = iter2.next(); - if (_449 === rt.DONE) { + unwind = 246; + const _467: [rt.u32, rt.u32] | rt.Done = iter2.next(); + if (_467 === rt.DONE) { break; } - const k2: rt.u32 = _449[0]; - const _456: Guard.Guard = guard(_449[1]); - rt.drop(rt.btreeInsert(map, k2, _456, undefined, rt.drop)); + const k2: rt.u32 = _467[0]; + const _474: Guard.Guard = guard(_467[1]); + rt.drop(rt.btreeInsert(map, k2, _474, undefined, rt.drop)); } - unwind = 235; + unwind = 247; const p: Guard.Guard = guard(32); - const captured32 = check; - const captured33 = p; - const captured34 = id; - const _464: (a0: rt.u32, a1: Guard.Guard) => boolean = rt.closure((_224: rt.u32, _329: Guard.Guard): boolean => { - const k3: rt.u32 = _224; + 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) { - captured32(6); + captured33(6); } - return rt.u32Add(k3, Guard.id(captured33)) !== rt.u32Add(captured34, 34); + return rt.u32Add(k3, Guard.id(captured34)) !== rt.u32Add(captured35, 34); }, (): void => { - rt.drop(captured33); + rt.drop(captured34); }); - rt.dropAfter(_464, () => rt.btreeRetain(map, _464, undefined, rt.drop)); + rt.dropAfter(_482, () => rt.btreeRetain(map, _482, undefined, rt.drop)); queue = rt.dequeNew() as rt.VecDeque; - unwind = 233; - const _468: Guard.Guard = guard(33); - rt.dequePushBack(queue, _468); - const _473: Guard.Guard = guard(34); - rt.dequePushBack(queue, _473); - const captured35 = guard(35); - const _481: (a0: Guard.Guard) => boolean = rt.closure((g19: Guard.Guard): boolean => { - return rt.u32Add(Guard.id(g19), 2) !== Guard.id(captured35); + 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(captured35); + rt.drop(captured36); }); - rt.dropAfter(_481, () => rt.dequeRetain(queue, _481, rt.drop)); - const _488: rt.usize = rt.btreeLen(map); - const _491: rt.usize = queue.n; - const args26: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(_488, f), (f: rt.Formatter) => rt.usizeDisplay(_491, f)]; + 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 = 235; + unwind = 247; rt.dequeDrop(queue, rt.drop); - unwind = 263; + unwind = 275; rt.btreeDrop(map, undefined, rt.drop); - unwind = 277; - _519 = false; - _520 = false; - _521 = false; - _522 = false; - _523 = false; - _524 = false; - _525 = false; - _526 = false; - _527 = false; - rt.dropAll(items); - _528 = false; - _529 = false; - _530 = false; - _531 = false; - _532 = false; - _533 = false; - _534 = false; - _535 = false; - _536 = false; + 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) { - b4: { - b5: { - b6: { - b7: { - b8: { - b9: { - b10: { - b11: { - b12: { - b13: { - b14: { - b15: { - b16: { - b17: { - b18: { - b19: { - b20: { - b21: { - b22: { - b23: { - b24: { - b25: { - if (unwind === 0) { - throw e2; - } - if (unwind === 233) { - rt.dequeDrop(queue, rt.drop); - break b22; - } - if (unwind === 234) { - break b22; - } - if (unwind === 235) { - break b22; - } - if (unwind === 238) { - rt.drop(_379); - break b23; - } - if (unwind === 239) { - break b23; - } - if (unwind === 242) { - rt.drop(_306); - break b24; - } - if (unwind === 243) { - break b24; - } - if (unwind === 244) { - break b16; - } - if (unwind === 245) { - rt.dropAll(v5); - break b15; - } - if (unwind === 247) { - rt.drop(_227); - break b12; - } - if (unwind === 248) { - break b12; - } - if (unwind === 249) { - break b9; - } - if (unwind === 251) { - rt.drop(_169); - break b8; - } - if (unwind === 252) { - rt.dropAll(v3); - break b7; - } - if (unwind === 255) { - rt.drop(_103); - break b25; - } - if (unwind === 256) { - break b25; - } - if (unwind === 257) { - rt.drop(g); - } else if (unwind !== 258) { - if (unwind === 259) { - rt.dropAll(v2); - break b6; - } - if (unwind === 260) { - rt.dropAll(v); - break b4; - } - if (unwind === 263) { - break b21; - } - if (unwind === 265) { - break b20; - } - if (unwind === 269) { - break b19; - } - if (unwind === 271) { - break b18; - } - if (unwind === 273) { - break b17; - } - if (unwind === 277) { - break b15; - } - if (unwind === 279) { - break b14; - } - if (unwind === 281) { - break b13; - } - if (unwind === 284) { - break b11; - } - if (unwind === 286) { - break b10; - } - if (unwind === 288) { - break b9; - } - if (unwind === 291) { + 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; } - if (unwind === 293) { - break b7; - } - if (unwind === 297) { - break b6; - } - if (unwind === 299) { - break b5; - } - break b4; + rt.drop(_100); + break b8; } - rt.drop(iter); - break b6; + rt.drop(_321); + break b20; } - rt.drop(_100); - break b6; + rt.drop(_394); + break b23; } - rt.drop(_303); - break b16; + rt.btreeDrop(map, undefined, rt.drop); + } + if (_537) { + rt.drop(r); } - rt.drop(_376); - break b19; } - rt.btreeDrop(map, undefined, rt.drop); + if (_538) { + rt.drop(v6); + } + if (_539) { + rt.drop(u); + } + if (_540) { + rt.drop(t); + } } - if (_519) { - rt.drop(r); + if (_541) { + rt.drop(o); } } - if (_520) { - rt.drop(v6); - } - if (_521) { - rt.drop(u); - } - if (_522) { - rt.drop(t); + if (_542) { + rt.drop(n); } } - if (_523) { - rt.drop(o); + if (_543) { + rt.drop(m); + } + if (_544) { + rt.drop(l); + } + if (_545) { + rt.drop(k); } } - if (_524) { - rt.drop(n); - } - } - if (_525) { - rt.drop(m); + rt.dropAll(items); } - if (_526) { - rt.drop(l); - } - if (_527) { - rt.drop(k); + if (_546) { + rt.drop(chain); } } - rt.dropAll(items); + if (_547) { + rt.drop(s); + } } - if (_528) { - rt.drop(chain); + if (_548) { + rt.drop(j); + } + if (_549) { + rt.drop(i); } - } - if (_529) { - rt.drop(s); } } - if (_530) { - rt.drop(j); - } - if (_531) { - rt.drop(i); + if (_550) { + rt.drop(h); } } + if (_551) { + rt.drop(ended); + } } - if (_532) { - rt.drop(h); + if (_552) { + rt.drop(w); } } - if (_533) { + if (_553) { rt.drop(flat); } } - if (_534) { + if (_554) { rt.drop(g2); } - if (_535) { + if (_555) { rt.drop(f); } } - if (_536) { + if (_556) { rt.drop(chained); } } - if (_537) { + if (_557) { rt.drop(e); } - if (_538) { + if (_558) { rt.drop(d); } - if (_539) { + if (_559) { rt.drop(c); } } - if (_540) { + if (_560) { rt.drop(b); } } - if (_541) { + if (_561) { rt.drop(mapped); } } - if (_542) { + if (_562) { rt.drop(a); } throw e2; diff --git a/ts/fixtures/task/src/drops/closures.rs b/ts/fixtures/task/src/drops/closures.rs index 06355ebc1..0479cbe0e 100644 --- a/ts/fixtures/task/src/drops/closures.rs +++ b/ts/fixtures/task/src/drops/closures.rs @@ -234,6 +234,12 @@ pub(super) fn iterated(log: &Log, id: u32, at: u8) { 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() diff --git a/ts/src/lower/iter.rs b/ts/src/lower/iter.rs index 6f486223a..6e0891000 100644 --- a/ts/src/lower/iter.rs +++ b/ts/src/lower/iter.rs @@ -374,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" => { @@ -473,14 +473,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" => { @@ -531,10 +531,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", })