diff --git a/quest/m3/ts-drop-order.md b/quest/m3/ts-drop-order.md index 1fa9d9713..14387c864 100644 --- a/quest/m3/ts-drop-order.md +++ b/quest/m3/ts-drop-order.md @@ -14,10 +14,6 @@ Moved from the m2 drop quest on 2026-10-27, once moq-net, its model, and kio had 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 @@ -25,16 +21,13 @@ with a span where std's order is one JS's can't follow yet: - `into_keys` and `into_values` of a hash map whose other half drops: `fold` drops it after the half it yields, `next` before. - `zip` of two `TrustedRandomAccess` iterators of items that drop. -- A `flatten` whose inner iterator holds items once ended, or that a `fold` reads where - both its source and inner iterators drop. +- A `flatten` whose inner iterator holds items once ended. - 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`. +Each `rt.Iter` has a `fold` and `rfold` that drop what it holds where std's do, and the +by-value consumers std folds go through it: build on those rather than `rt.drop`. Watch the cost: measure any change to a hot path on the [TS benchmark](/ts/README.md#bench). diff --git a/ts/MIGRATE.md b/ts/MIGRATE.md index 7479f0e0a..f7e8d12e9 100644 --- a/ts/MIGRATE.md +++ b/ts/MIGRATE.md @@ -9,6 +9,14 @@ - A trait object in a function's suffix is named for its trait and the types it binds: `show$dynstdfmtDebug` is `show$dyn_Debug`, and `poll$dyn_Future_u64` is a `dyn Future`'s. +- A runtime consumer that takes an iterator by value is told whether it drops rather than + given `rt.drop`: `iterFold`, `iterForEach`, `iterSum`, `iterProduct`, `iterMax`, + `iterMin`, `iterMaxByKey`, `iterMinByKey`, and `durationSum` take `true`, and + `ownedCount` and `ownedLast` take only what drops an item. `iterToArray`, + `iterToByteVec`, `iterExtend`, `iterExtendBytes`, `dequeExtend`, `hashExtend`, + `hashExtendKeys`, `btreeExtend`, and `btreeExtendKeys` take an `rt.Take`, `"next"` or + `"fold"`, for how std's reads it; `iterToArray` takes `"place"` where its `inPlace` was + `true`. - `rt.FromUtf8Error` holds its `rt.Utf8Error` as std's does: `e.validUpTo` and `e.errorLen` are `e.error.validUpTo` and `e.error.errorLen`. - The runtime no longer exports `ownedNth`, `ownedNthBack`, `ownedSkip`, `ownedTake`, or diff --git a/ts/README.md b/ts/README.md index cfb64fd02..b9983e40b 100644 --- a/ts/README.md +++ b/ts/README.md @@ -229,7 +229,8 @@ std's collections, `Arc`, and the std functions that may discard an operand where std's do. So do iterators: one that owns its items, as a `Vec`'s `into_iter` or a map's `drain` does, drops those it still holds by `[Symbol.dispose]`, an adaptor drops what it skips or rejects, and a consumer that takes an iterator by value drops it, a -panic included. A `Drop` impl that +panic included: through each `rt.Iter`'s own `fold` where std's folds, which drops each +adaptor's closure as its fold ends, before what it wraps, as std's does. A `Drop` impl that panics leaves the rest to drop as Rust's does: a class's glue and the runtime's droppers go on to the rest of the value and its container, but a hash table leaks its other entries, as std's does. diff --git a/ts/fixtures/lang/expected/dyns.ts b/ts/fixtures/lang/expected/dyns.ts index fd47e82d5..51a051463 100644 --- a/ts/fixtures/lang/expected/dyns.ts +++ b/ts/fixtures/lang/expected/dyns.ts @@ -386,7 +386,7 @@ export function shared(data: rt.ByteSlice, out: rt.ByteVec): void { objects = rt.iterToArray(rt.iterMap(new rt.Range(0, 3), (_2: rt.i32): rt.Arc => { const _34: rt.Arc = rt.arcClone(hits); return new rt.ArcDyn(_34, new Shape.Hits(_34.value)); - }), false, undefined, rt.drop); + }), undefined, rt.drop); unwind = 244; _385 = true; const sum: rt.u32 = rt.iterFold(rt.iterSlice(objects), 0, (sum2: rt.u32, s2: rt.Arc): rt.u32 => { @@ -439,12 +439,12 @@ export function shared(data: rt.ByteSlice, out: rt.ByteVec): void { } const _113: rt.Arc = new rt.Arc({ side: x as rt.u16 }); return new rt.ArcDyn(_113, new Named.Square(_113.value)); - }), false, undefined, rt.drop); + }), undefined, rt.drop); unwind = 242; _384 = true; kept = rt.iterToArray(rt.iterMap(rt.iterStepBy(rt.iterSlice(tris), 2), (a0: rt.Arc): rt.Arc => { return rt.arcClone(a0); - }), false, undefined, rt.drop); + }), undefined, rt.drop); unwind = 211; for (const _298 of tris) { const _310: string = _298.value.label$Named(); @@ -504,140 +504,135 @@ export function shared(data: rt.ByteSlice, out: rt.ByteVec): void { b15: { b16: { b17: { - b18: { - if (unwind === 0) { - throw e; - } - if (unwind === 206) { - break b17; - } - if (unwind === 207) { - break b18; + if (unwind === 0) { + throw e; + } + if (unwind === 206) { + break b16; + } + if (unwind === 207) { + break b17; + } + if (unwind === 208) { + break b17; + } + if (unwind === 209) { + break b16; + } + if (unwind === 210) { + break b16; + } + if (unwind === 211) { + break b16; + } + if (unwind === 212) { + break b14; + } + if (unwind === 213) { + break b14; + } + if (unwind === 214) { + break b13; + } + if (unwind === 215) { + break b12; + } + if (unwind === 216) { + break b12; + } + if (unwind === 217) { + break b12; + } + if (unwind === 218) { + break b12; + } + if (unwind === 219) { + break b11; + } + if (unwind === 220) { + break b10; + } + if (unwind === 221) { + rt.drop(_189); + break b10; + } + if (unwind === 222) { + break b10; + } + if (unwind === 223) { + rt.drop(_168); + } else if (unwind !== 224) { + if (unwind === 225) { + break b10; } - if (unwind === 208) { - break b18; + if (unwind === 226) { + break b10; } - if (unwind === 209) { - break b17; + if (unwind === 227) { + break b10; } - if (unwind === 210) { - break b17; + if (unwind === 228) { + break b10; } - if (unwind === 211) { - break b17; + if (unwind === 229) { + break b10; } - if (unwind === 212) { - break b15; + if (unwind === 230) { + break b10; } - if (unwind === 213) { - break b15; + if (unwind === 232) { + break b9; } - if (unwind === 214) { - break b14; + if (unwind === 233) { + break b9; } - if (unwind === 215) { - break b13; + if (unwind === 234) { + break b9; } - if (unwind === 216) { - break b13; + if (unwind === 235) { + break b9; } - if (unwind === 217) { - break b13; + if (unwind === 236) { + break b9; } - if (unwind === 218) { - break b13; + if (unwind === 237) { + break b8; } - if (unwind === 219) { - break b12; + if (unwind === 238) { + break b7; } - if (unwind === 220) { - break b11; + if (unwind === 239) { + break b6; } - if (unwind === 221) { - rt.drop(_189); - break b11; + if (unwind === 242) { + break b15; } - if (unwind === 222) { - break b11; + if (unwind === 244) { + break b12; } - if (unwind === 223) { - rt.drop(_168); - } else if (unwind !== 224) { - if (unwind === 225) { - break b11; - } - if (unwind === 226) { - break b11; - } - if (unwind === 227) { - break b11; - } - if (unwind === 228) { - break b11; - } - if (unwind === 229) { - break b11; - } - if (unwind === 230) { - break b11; - } - if (unwind === 231) { - break b10; - } - if (unwind === 232) { - break b9; - } - if (unwind === 233) { - break b9; - } - if (unwind === 234) { - break b9; - } - if (unwind === 235) { - break b9; - } - if (unwind === 236) { - break b9; - } - if (unwind === 237) { - break b8; - } - if (unwind === 238) { - break b7; - } - if (unwind === 239) { - break b6; - } - if (unwind === 242) { - break b16; - } - if (unwind === 244) { - break b13; - } - if (unwind === 246) { - break b9; - } - break b5; + if (unwind === 246) { + break b9; } - break b11; + break b5; } + break b10; } - rt.dropAll(kept); - } - if (_384) { - rt.dropAll(tris); } + rt.dropAll(kept); + } + if (_384) { + rt.dropAll(tris); } - rt.drop(m); } - rt.drop(n); - } - if (_385) { - rt.dropAll(objects); + rt.drop(m); } + rt.drop(n); + } + if (_385) { + rt.dropAll(objects); } - rt.drop(hits); } + rt.drop(hits); } } if (_386) { diff --git a/ts/fixtures/reject/census.md b/ts/fixtures/reject/census.md index e32b84640..a7c37dc99 100644 --- a/ts/fixtures/reject/census.md +++ b/ts/fixtures/reject/census.md @@ -1,7 +1,7 @@ # Census of `reject-fixture` -- Refusals: 75 -- Function instances: 83 +- Refusals: 73 +- Function instances: 81 - Generic functions no instance reached, lowered over their type parameters: 6 ## By construct @@ -9,50 +9,48 @@ | Count | Construct | First | | ---: | --- | --- | | 11 | unsupported call to `_` | fixtures/reject/src/lib.rs:21:4 | -| 4 | a variant of `_`, which is not supported: either is the same JS string | fixtures/reject/src/lib.rs:396:2 | -| 4 | an assignment through a reference to `_` | fixtures/reject/src/lib.rs:110:2 | -| 3 | replacing the value behind a reference to `_` | fixtures/reject/src/lib.rs:94:2 | +| 4 | a variant of `_`, which is not supported: either is the same JS string | fixtures/reject/src/lib.rs:382:2 | +| 4 | an assignment through a reference to `_` | fixtures/reject/src/lib.rs:101:2 | +| 3 | replacing the value behind a reference to `_` | fixtures/reject/src/lib.rs:85:2 | | 3 | unsupported type `_` | fixtures/reject/src/lib.rs:7:14 | -| 2 | `_` is not supported: it would be pending two ways with one value | fixtures/reject/src/lib.rs:114:20 | +| 2 | `_` is not supported: it would be pending two ways with one value | fixtures/reject/src/lib.rs:105:20 | | 2 | `_` is not supported: its `None` and `Some` would both be `rt.None` | fixtures/reject/src/lib.rs:16:15 | | 2 | `_` of `_`, whose `None` is `rt.None`, which is not supported yet | fixtures/reject/src/lib.rs:41:42 | -| 2 | `_` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it | fixtures/reject/src/lib.rs:261:16 | -| 2 | `_`, a trait object of the generic trait `_`, which is not supported yet | fixtures/reject/src/lib.rs:488:23 | -| 2 | a coercion to `_`, which is not supported yet | fixtures/reject/src/lib.rs:479:40 | -| 2 | an iterator of the crate implementing `_`, which is not supported yet | fixtures/reject/src/lib.rs:168:1 | -| 2 | constructing `_` from another crate | fixtures/reject/src/lib.rs:154:23 | -| 2 | overriding `_`, which std's adaptors call in place of `next` or beside it | fixtures/reject/src/lib.rs:148:2 | -| 2 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | fixtures/reject/src/lib.rs:383:13 | -| 1 | `Pointer` formatting, as in `{:p}`, is not supported | fixtures/reject/src/lib.rs:77:2 | -| 1 | `_` is not supported yet | fixtures/reject/src/lib.rs:407:18 | +| 2 | `_` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it | fixtures/reject/src/lib.rs:247:16 | +| 2 | `_`, a trait object of the generic trait `_`, which is not supported yet | fixtures/reject/src/lib.rs:474:23 | +| 2 | a coercion to `_`, which is not supported yet | fixtures/reject/src/lib.rs:465:40 | +| 2 | an iterator of the crate implementing `_`, which is not supported yet | fixtures/reject/src/lib.rs:159:1 | +| 2 | constructing `_` from another crate | fixtures/reject/src/lib.rs:145:23 | +| 2 | overriding `_`, which std's adaptors call in place of `next` or beside it | fixtures/reject/src/lib.rs:139:2 | +| 2 | passing `_`, a closure that owns a value that drops, to `_`, which is not supported yet | fixtures/reject/src/lib.rs:369:13 | +| 1 | `Pointer` formatting, as in `{:p}`, is not supported | fixtures/reject/src/lib.rs:68:2 | +| 1 | `_` is not supported yet | fixtures/reject/src/lib.rs:393:18 | | 1 | `_` is not supported: its field `_` is `_`, typed `_`, whose `None` would be `rt.None` as `_` | fixtures/reject/src/lib.rs:31:2 | -| 1 | `_` of `_` by `_`, which is not supported yet | fixtures/reject/src/lib.rs:300:6 | -| 1 | `_` of `_`, which drops `_`, which is not supported yet | fixtures/reject/src/lib.rs:62:13 | -| 1 | `_` of `_`, which folds a closure that drops beside what else drops, which is not supported yet | fixtures/reject/src/lib.rs:56:23 | -| 1 | `_` through a held type's own, which is not supported yet | fixtures/reject/src/lib.rs:332:2 | +| 1 | `_` of `_` by `_`, which is not supported yet | fixtures/reject/src/lib.rs:286:6 | +| 1 | `_` of `_`, which drops `_`, which is not supported yet | fixtures/reject/src/lib.rs:53:13 | +| 1 | `_` through a held type's own, which is not supported yet | fixtures/reject/src/lib.rs:318:2 | | 1 | `_`, a trait object of another crate's trait, which is not supported yet | fixtures/reject/src/lib.rs:11:16 | -| 1 | `_`, which is not supported yet | fixtures/reject/src/lib.rs:308:9 | -| 1 | `f64::mul_add`, which rounds once, where JS would round twice | fixtures/reject/src/lib.rs:458:4 | -| 1 | `fold` of `_`, which folds a `flatten` whose source and iterators both drop, which is not supported yet | fixtures/reject/src/lib.rs:230:26 | -| 1 | a `zip` of `_` and `_`, which std reads by index, of items that drop, which is not supported yet | fixtures/reject/src/lib.rs:235:30 | -| 1 | a `zip` of `_`, whose closures std calls one item further through `next` than through `fold` | fixtures/reject/src/lib.rs:181:51 | -| 1 | a cast from `_` to `_` | fixtures/reject/src/lib.rs:105:2 | -| 1 | a coercion to `_` | fixtures/reject/src/lib.rs:355:2 | -| 1 | a constant of type `_` | fixtures/reject/src/lib.rs:89:2 | -| 1 | a copy of a closure that changes what it captured | fixtures/reject/src/lib.rs:271:14 | -| 1 | a mutable borrow of a subslice of `_`, which JS would copy, having no views | fixtures/reject/src/lib.rs:240:13 | -| 1 | a mutable reference into a `Result`'s payload, passed on or kept | fixtures/reject/src/lib.rs:427:12 | -| 1 | a printable type must implement `Display` or `Debug` | fixtures/reject/src/lib.rs:101:1 | +| 1 | `_`, which is not supported yet | fixtures/reject/src/lib.rs:294:9 | +| 1 | `f64::mul_add`, which rounds once, where JS would round twice | fixtures/reject/src/lib.rs:444:4 | +| 1 | a `zip` of `_` and `_`, which std reads by index, of items that drop, which is not supported yet | fixtures/reject/src/lib.rs:221:30 | +| 1 | a `zip` of `_`, whose closures std calls one item further through `next` than through `fold` | fixtures/reject/src/lib.rs:172:51 | +| 1 | a cast from `_` to `_` | fixtures/reject/src/lib.rs:96:2 | +| 1 | a coercion to `_` | fixtures/reject/src/lib.rs:341:2 | +| 1 | a constant of type `_` | fixtures/reject/src/lib.rs:80:2 | +| 1 | a copy of a closure that changes what it captured | fixtures/reject/src/lib.rs:257:14 | +| 1 | a mutable borrow of a subslice of `_`, which JS would copy, having no views | fixtures/reject/src/lib.rs:226:13 | +| 1 | a mutable reference into a `Result`'s payload, passed on or kept | fixtures/reject/src/lib.rs:413:12 | +| 1 | a printable type must implement `Display` or `Debug` | fixtures/reject/src/lib.rs:92:1 | | 1 | a scalar constant of type `_` | fixtures/reject/src/lib.rs:8:2 | -| 1 | a trait object of `_`, which is not supported yet | fixtures/reject/src/lib.rs:505:26 | -| 1 | a zero-sized constant of type `_` | fixtures/reject/src/lib.rs:71:2 | +| 1 | a trait object of `_`, which is not supported yet | fixtures/reject/src/lib.rs:491:26 | +| 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 | collecting `_`, whose `None` is `rt.None`, which is not supported yet | fixtures/reject/src/lib.rs:36:43 | -| 1 | comparing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:282:52 | -| 1 | constructing `_` | fixtures/reject/src/lib.rs:414:53 | -| 1 | hashing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:282:52 | -| 1 | hashing `_` through `_`'s own `Hash::hash_slice`, which is not supported yet | fixtures/reject/src/lib.rs:374:16 | -| 1 | passing `_`, which drops, to `_`, which is not supported yet | fixtures/reject/src/lib.rs:391:4 | +| 1 | comparing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:268:52 | +| 1 | constructing `_` | fixtures/reject/src/lib.rs:400:53 | +| 1 | hashing `_` as a key, which is not supported yet | fixtures/reject/src/lib.rs:268:52 | +| 1 | hashing `_` through `_`'s own `Hash::hash_slice`, which is not supported yet | fixtures/reject/src/lib.rs:360:16 | +| 1 | passing `_`, which drops, to `_`, which is not supported yet | fixtures/reject/src/lib.rs:377:4 | ## By API @@ -60,117 +58,113 @@ The type or module each refused type or path belongs to. | Count | API | First | | ---: | --- | --- | -| 7 | `std::borrow::Cow` | fixtures/reject/src/lib.rs:396:2 | +| 7 | `std::borrow::Cow` | fixtures/reject/src/lib.rs:382:2 | | 6 | `Option` | fixtures/reject/src/lib.rs:16:15 | | 6 | `f32` | fixtures/reject/src/lib.rs:7:14 | | 4 | `Iterator` | fixtures/reject/src/lib.rs:41:42 | -| 3 | `std::iter::Map` | fixtures/reject/src/lib.rs:56:23 | -| 3 | `std::sync::Arc` | fixtures/reject/src/lib.rs:110:2 | -| 3 | `std::vec::Vec` | fixtures/reject/src/lib.rs:282:52 | -| 3 | `u8` | fixtures/reject/src/lib.rs:89:2 | -| 3 | `{closure}` | fixtures/reject/src/lib.rs:383:13 | -| 2 | `HashMap` | fixtures/reject/src/lib.rs:277:6 | -| 2 | `Meters` | fixtures/reject/src/lib.rs:94:2 | -| 2 | `Poll` | fixtures/reject/src/lib.rs:114:20 | -| 2 | `Scaled` | fixtures/reject/src/lib.rs:488:23 | -| 2 | `dyn Scaled` | fixtures/reject/src/lib.rs:488:23 | -| 2 | `std::collections::HashMap` | fixtures/reject/src/lib.rs:62:13 | -| 2 | `std::iter::Iterator` | fixtures/reject/src/lib.rs:261:16 | -| 2 | `std::ops::Range` | fixtures/reject/src/lib.rs:189:8 | -| 2 | `std::pin::Pin` | fixtures/reject/src/lib.rs:125:2 | +| 3 | `std::sync::Arc` | fixtures/reject/src/lib.rs:101:2 | +| 3 | `std::vec::Vec` | fixtures/reject/src/lib.rs:268:52 | +| 3 | `u8` | fixtures/reject/src/lib.rs:80:2 | +| 3 | `{closure}` | fixtures/reject/src/lib.rs:369:13 | +| 2 | `HashMap` | fixtures/reject/src/lib.rs:263:6 | +| 2 | `Meters` | fixtures/reject/src/lib.rs:85:2 | +| 2 | `Poll` | fixtures/reject/src/lib.rs:105:20 | +| 2 | `Scaled` | fixtures/reject/src/lib.rs:474:23 | +| 2 | `dyn Scaled` | fixtures/reject/src/lib.rs:474:23 | +| 2 | `std::collections::HashMap` | fixtures/reject/src/lib.rs:53:13 | +| 2 | `std::iter::Iterator` | fixtures/reject/src/lib.rs:247:16 | +| 2 | `std::iter::Map` | fixtures/reject/src/lib.rs:145:23 | +| 2 | `std::ops::Range` | fixtures/reject/src/lib.rs:180:8 | +| 2 | `std::pin::Pin` | fixtures/reject/src/lib.rs:116:2 | | 2 | `std::slice` | fixtures/reject/src/lib.rs:21:4 | -| 2 | `std::vec::IntoIter` | fixtures/reject/src/lib.rs:453:17 | -| 1 | `Batched` | fixtures/reject/src/lib.rs:374:16 | -| 1 | `DoubleEndedIterator` | fixtures/reject/src/lib.rs:168:1 | -| 1 | `Entry` | fixtures/reject/src/lib.rs:383:13 | -| 1 | `FusedIterator` | fixtures/reject/src/lib.rs:222:1 | -| 1 | `Hasher` | fixtures/reject/src/lib.rs:308:9 | +| 2 | `std::vec::IntoIter` | fixtures/reject/src/lib.rs:439:17 | +| 1 | `Batched` | fixtures/reject/src/lib.rs:360:16 | +| 1 | `DoubleEndedIterator` | fixtures/reject/src/lib.rs:159:1 | +| 1 | `Entry` | fixtures/reject/src/lib.rs:369:13 | +| 1 | `FusedIterator` | fixtures/reject/src/lib.rs:213:1 | +| 1 | `Hasher` | fixtures/reject/src/lib.rs:294:9 | | 1 | `Maybe` | fixtures/reject/src/lib.rs:31:2 | -| 1 | `Noisy` | fixtures/reject/src/lib.rs:62:13 | +| 1 | `Noisy` | fixtures/reject/src/lib.rs:53:13 | | 1 | `T \| undefined` | fixtures/reject/src/lib.rs:31:2 | -| 1 | `Tail` | fixtures/reject/src/lib.rs:515:30 | -| 1 | `[u16; 1]` | fixtures/reject/src/lib.rs:254:22 | -| 1 | `[u8; 4]` | fixtures/reject/src/lib.rs:505:26 | -| 1 | `count` | fixtures/reject/src/lib.rs:56:23 | +| 1 | `Tail` | fixtures/reject/src/lib.rs:501:30 | +| 1 | `[u16; 1]` | fixtures/reject/src/lib.rs:240:22 | +| 1 | `[u8; 4]` | fixtures/reject/src/lib.rs:491:26 | | 1 | `dyn std::ops::Fn(u8) -> u8` | fixtures/reject/src/lib.rs:11:16 | -| 1 | `f64` | fixtures/reject/src/lib.rs:463:2 | -| 1 | `into_keys` | fixtures/reject/src/lib.rs:62:13 | -| 1 | `std::iter::Chain` | fixtures/reject/src/lib.rs:181:51 | -| 1 | `std::iter::Flatten` | fixtures/reject/src/lib.rs:230:26 | -| 1 | `std::iter::Rev` | fixtures/reject/src/lib.rs:175:14 | -| 1 | `std::option::Option` | fixtures/reject/src/lib.rs:434:2 | -| 1 | `std::slice::Iter` | fixtures/reject/src/lib.rs:135:11 | -| 1 | `std::string::String` | fixtures/reject/src/lib.rs:83:10 | -| 1 | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:130:2 | -| 1 | `std::sync::Weak` | fixtures/reject/src/lib.rs:479:40 | -| 1 | `str` | fixtures/reject/src/lib.rs:391:4 | -| 1 | `u32` | fixtures/reject/src/lib.rs:240:13 | -| 1 | `u64` | fixtures/reject/src/lib.rs:105:2 | +| 1 | `f64` | fixtures/reject/src/lib.rs:449:2 | +| 1 | `into_keys` | fixtures/reject/src/lib.rs:53:13 | +| 1 | `std::iter::Chain` | fixtures/reject/src/lib.rs:172:51 | +| 1 | `std::iter::Rev` | fixtures/reject/src/lib.rs:166:14 | +| 1 | `std::option::Option` | fixtures/reject/src/lib.rs:420:2 | +| 1 | `std::slice::Iter` | fixtures/reject/src/lib.rs:126:11 | +| 1 | `std::string::String` | fixtures/reject/src/lib.rs:74:10 | +| 1 | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:121:2 | +| 1 | `std::sync::Weak` | fixtures/reject/src/lib.rs:465:40 | +| 1 | `str` | fixtures/reject/src/lib.rs:377:4 | +| 1 | `u32` | fixtures/reject/src/lib.rs:226:13 | +| 1 | `u64` | fixtures/reject/src/lib.rs:96:2 | | 1 | `value` | fixtures/reject/src/lib.rs:31:2 | -| 1 | `{async closure}` | fixtures/reject/src/lib.rs:71:2 | +| 1 | `{async closure}` | fixtures/reject/src/lib.rs:62:2 | ## By type or path | Count | Construct | Type or path | First | | ---: | --- | --- | --- | -| 4 | a variant of `_`, which is not supported: either is the same JS string | `std::borrow::Cow` | fixtures/reject/src/lib.rs:396:2 | +| 4 | a variant of `_`, which is not supported: either is the same JS string | `std::borrow::Cow` | fixtures/reject/src/lib.rs:382:2 | | 3 | unsupported type `_` | `f32` | 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:114:20 | +| 2 | `_` is not supported: it would be pending two ways with one value | `Poll` | fixtures/reject/src/lib.rs:105:20 | | 2 | `_` is not supported: its `None` and `Some` would both be `rt.None` | `Option` | fixtures/reject/src/lib.rs:16:15 | -| 2 | `_`, a trait object of the generic trait `_`, which is not supported yet | `dyn Scaled`, `Scaled` | fixtures/reject/src/lib.rs:488:23 | -| 2 | an assignment through a reference to `_` | `std::pin::Pin` | fixtures/reject/src/lib.rs:125:2 | -| 2 | replacing the value behind a reference to `_` | `Meters` | fixtures/reject/src/lib.rs:94:2 | -| 2 | unsupported call to `_` | `::sum` | fixtures/reject/src/lib.rs:453:17 | -| 1 | `_` is not supported yet | `std::borrow::Cow` | fixtures/reject/src/lib.rs:407:18 | +| 2 | `_`, a trait object of the generic trait `_`, which is not supported yet | `dyn Scaled`, `Scaled` | fixtures/reject/src/lib.rs:474:23 | +| 2 | an assignment through a reference to `_` | `std::pin::Pin` | fixtures/reject/src/lib.rs:116:2 | +| 2 | replacing the value behind a reference to `_` | `Meters` | fixtures/reject/src/lib.rs:85:2 | +| 2 | unsupported call to `_` | `::sum` | fixtures/reject/src/lib.rs:439:17 | +| 1 | `_` is not supported yet | `std::borrow::Cow` | fixtures/reject/src/lib.rs:393:18 | | 1 | `_` is not supported: its field `_` is `_`, typed `_`, whose `None` would be `rt.None` as `_` | `Maybe`, `value`, `Option`, `T \| undefined`, `Option` | fixtures/reject/src/lib.rs:31:2 | -| 1 | `_` of `_` by `_`, which is not supported yet | `HashMap::contains_key`, `std::collections::HashMap`, `u8` | fixtures/reject/src/lib.rs:300:6 | -| 1 | `_` of `_`, which drops `_`, which is not supported yet | `into_keys`, `std::collections::HashMap`, `Noisy` | fixtures/reject/src/lib.rs:62: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:56:23 | -| 1 | `_` of `_`, whose `None` is `rt.None`, which is not supported yet | `HashMap::get`, `Option` | fixtures/reject/src/lib.rs:277:6 | +| 1 | `_` of `_` by `_`, which is not supported yet | `HashMap::contains_key`, `std::collections::HashMap`, `u8` | fixtures/reject/src/lib.rs:286: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 `_`, whose `None` is `rt.None`, which is not supported yet | `HashMap::get`, `Option` | fixtures/reject/src/lib.rs:263:6 | | 1 | `_` of `_`, whose `None` is `rt.None`, which is not supported yet | `Iterator::find`, `Option` | fixtures/reject/src/lib.rs:41:42 | -| 1 | `_` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it | `std::iter::Iterator::count` | fixtures/reject/src/lib.rs:261: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:261:16 | -| 1 | `_` through a held type's own, which is not supported yet | `::ne` | fixtures/reject/src/lib.rs:332:2 | +| 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:247: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:247:16 | +| 1 | `_` through a held type's own, which is not supported yet | `::ne` | fixtures/reject/src/lib.rs:318:2 | | 1 | `_`, a trait object of another crate's trait, which is not supported yet | `dyn std::ops::Fn(u8) -> u8` | fixtures/reject/src/lib.rs:11:16 | -| 1 | `_`, which is not supported yet | `Hasher::write` | fixtures/reject/src/lib.rs:308: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:230:26 | -| 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:235: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:181:51 | -| 1 | a cast from `_` to `_` | `u64`, `f32` | fixtures/reject/src/lib.rs:105:2 | -| 1 | a coercion to `_` | `std::sync::Arc` | fixtures/reject/src/lib.rs:355:2 | -| 1 | a coercion to `_`, which is not supported yet | `&Tail` | fixtures/reject/src/lib.rs:515:30 | -| 1 | a coercion to `_`, which is not supported yet | `std::sync::Weak` | fixtures/reject/src/lib.rs:479:40 | -| 1 | a constant of type `_` | `&u8` | fixtures/reject/src/lib.rs:89:2 | -| 1 | a mutable borrow of a subslice of `_`, which JS would copy, having no views | `u32` | fixtures/reject/src/lib.rs:240:13 | +| 1 | `_`, which is not supported yet | `Hasher::write` | fixtures/reject/src/lib.rs:294:9 | +| 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:221: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:172:51 | +| 1 | a cast from `_` to `_` | `u64`, `f32` | fixtures/reject/src/lib.rs:96:2 | +| 1 | a coercion to `_` | `std::sync::Arc` | fixtures/reject/src/lib.rs:341:2 | +| 1 | a coercion to `_`, which is not supported yet | `&Tail` | fixtures/reject/src/lib.rs:501:30 | +| 1 | a coercion to `_`, which is not supported yet | `std::sync::Weak` | fixtures/reject/src/lib.rs:465:40 | +| 1 | a constant of type `_` | `&u8` | fixtures/reject/src/lib.rs:80:2 | +| 1 | a mutable borrow of a subslice of `_`, which JS would copy, having no views | `u32` | fixtures/reject/src/lib.rs:226:13 | | 1 | a scalar constant of type `_` | `f32` | fixtures/reject/src/lib.rs:8:2 | -| 1 | a trait object of `_`, which is not supported yet | `[u8; 4]` | fixtures/reject/src/lib.rs:505:26 | -| 1 | a zero-sized constant of type `_` | `{async closure}` | fixtures/reject/src/lib.rs:71:2 | -| 1 | an assignment through a reference to `_` | `std::sync::Arc` | fixtures/reject/src/lib.rs:110:2 | -| 1 | an assignment through a reference to `_` | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:130:2 | -| 1 | an iterator of the crate implementing `_`, which is not supported yet | `DoubleEndedIterator` | fixtures/reject/src/lib.rs:168:1 | -| 1 | an iterator of the crate implementing `_`, which is not supported yet | `FusedIterator` | fixtures/reject/src/lib.rs:222:1 | +| 1 | a trait object of `_`, which is not supported yet | `[u8; 4]` | fixtures/reject/src/lib.rs:491:26 | +| 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:101:2 | +| 1 | an assignment through a reference to `_` | `std::sync::MutexGuard` | fixtures/reject/src/lib.rs:121:2 | +| 1 | an iterator of the crate implementing `_`, which is not supported yet | `DoubleEndedIterator` | fixtures/reject/src/lib.rs:159:1 | +| 1 | an iterator of the crate implementing `_`, which is not supported yet | `FusedIterator` | fixtures/reject/src/lib.rs:213:1 | | 1 | arithmetic on `_` | `f32` | fixtures/reject/src/lib.rs:8:2 | | 1 | collecting `_`, whose `None` is `rt.None`, which is not supported yet | `Option` | fixtures/reject/src/lib.rs:36:43 | -| 1 | comparing `_` as a key, which is not supported yet | `std::vec::Vec` | fixtures/reject/src/lib.rs:282:52 | -| 1 | constructing `_` | `std::borrow::Cow` | fixtures/reject/src/lib.rs:414:53 | -| 1 | constructing `_` from another crate | `std::iter::Map` | fixtures/reject/src/lib.rs:154:23 | -| 1 | constructing `_` from another crate | `std::iter::Rev` | fixtures/reject/src/lib.rs:175:14 | -| 1 | hashing `_` as a key, which is not supported yet | `std::vec::Vec` | fixtures/reject/src/lib.rs:282:52 | -| 1 | hashing `_` through `_`'s own `Hash::hash_slice`, which is not supported yet | `std::vec::Vec`, `Batched` | fixtures/reject/src/lib.rs:374:16 | -| 1 | overriding `_`, which std's adaptors call in place of `next` or beside it | `Iterator::fold` | fixtures/reject/src/lib.rs:148:2 | -| 1 | overriding `_`, which std's adaptors call in place of `next` or beside it | `Iterator::size_hint` | fixtures/reject/src/lib.rs:202: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:383: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:384:16 | -| 1 | passing `_`, which drops, to `_`, which is not supported yet | `{closure}`, `str::contains` | fixtures/reject/src/lib.rs:391:4 | -| 1 | replacing the value behind a reference to `_` | `[u16; 1]` | fixtures/reject/src/lib.rs:254:22 | -| 1 | unsupported call to `_` | `::fmt` | fixtures/reject/src/lib.rs:463:2 | -| 1 | unsupported call to `_` | `::deref` | fixtures/reject/src/lib.rs:408:2 | -| 1 | unsupported call to `_` | `::eq` | fixtures/reject/src/lib.rs:434:2 | -| 1 | unsupported call to `_` | `::cycle` | fixtures/reject/src/lib.rs:135:11 | -| 1 | unsupported call to `_` | `::write_fmt` | fixtures/reject/src/lib.rs:83:10 | -| 1 | unsupported call to `_` | `::hash` | fixtures/reject/src/lib.rs:365:10 | -| 1 | unsupported call to `_` | `std::ops::Range::contains` | fixtures/reject/src/lib.rs:189:8 | -| 1 | unsupported call to `_` | `std::slice::copy_within` | fixtures/reject/src/lib.rs:350:4 | +| 1 | comparing `_` as a key, which is not supported yet | `std::vec::Vec` | fixtures/reject/src/lib.rs:268:52 | +| 1 | constructing `_` | `std::borrow::Cow` | fixtures/reject/src/lib.rs:400:53 | +| 1 | constructing `_` from another crate | `std::iter::Map` | fixtures/reject/src/lib.rs:145:23 | +| 1 | constructing `_` from another crate | `std::iter::Rev` | fixtures/reject/src/lib.rs:166:14 | +| 1 | hashing `_` as a key, which is not supported yet | `std::vec::Vec` | fixtures/reject/src/lib.rs:268:52 | +| 1 | hashing `_` through `_`'s own `Hash::hash_slice`, which is not supported yet | `std::vec::Vec`, `Batched` | fixtures/reject/src/lib.rs:360:16 | +| 1 | overriding `_`, which std's adaptors call in place of `next` or beside it | `Iterator::fold` | fixtures/reject/src/lib.rs:139:2 | +| 1 | overriding `_`, which std's adaptors call in place of `next` or beside it | `Iterator::size_hint` | fixtures/reject/src/lib.rs:193: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:369: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:370:16 | +| 1 | passing `_`, which drops, to `_`, which is not supported yet | `{closure}`, `str::contains` | fixtures/reject/src/lib.rs:377:4 | +| 1 | replacing the value behind a reference to `_` | `[u16; 1]` | fixtures/reject/src/lib.rs:240:22 | +| 1 | unsupported call to `_` | `::fmt` | fixtures/reject/src/lib.rs:449:2 | +| 1 | unsupported call to `_` | `::deref` | fixtures/reject/src/lib.rs:394:2 | +| 1 | unsupported call to `_` | `::eq` | fixtures/reject/src/lib.rs:420:2 | +| 1 | unsupported call to `_` | `::cycle` | fixtures/reject/src/lib.rs:126:11 | +| 1 | unsupported call to `_` | `::write_fmt` | fixtures/reject/src/lib.rs:74:10 | +| 1 | unsupported call to `_` | `::hash` | fixtures/reject/src/lib.rs:351:10 | +| 1 | unsupported call to `_` | `std::ops::Range::contains` | fixtures/reject/src/lib.rs:180:8 | +| 1 | unsupported call to `_` | `std::slice::copy_within` | fixtures/reject/src/lib.rs:336:4 | | 1 | unsupported call to `_` | `std::slice::sort` | fixtures/reject/src/lib.rs:21:4 | ## Spans @@ -178,42 +172,42 @@ The type or module each refused type or path belongs to.
unsupported call to `_` (11) - fixtures/reject/src/lib.rs:21:4: unsupported call to `std::slice::::sort` -- fixtures/reject/src/lib.rs:83:10: unsupported call to `::write_fmt` -- fixtures/reject/src/lib.rs:135:11: unsupported call to ` as std::iter::Iterator>::cycle` -- fixtures/reject/src/lib.rs:189:8: unsupported call to `std::ops::Range::::contains::` -- fixtures/reject/src/lib.rs:350:4: unsupported call to `core::slice::::copy_within::>` -- fixtures/reject/src/lib.rs:365:10: unsupported call to `::hash::` -- fixtures/reject/src/lib.rs:408:2: unsupported call to ` as std::ops::Deref>::deref` -- fixtures/reject/src/lib.rs:434:2: unsupported call to ` as std::cmp::PartialEq>::eq` -- fixtures/reject/src/lib.rs:453:17: unsupported call to ` as std::iter::Iterator>::sum::` -- fixtures/reject/src/lib.rs:453:38: unsupported call to ` as std::iter::Iterator>::sum::` -- fixtures/reject/src/lib.rs:463:2: unsupported call to `::fmt` +- fixtures/reject/src/lib.rs:74:10: unsupported call to `::write_fmt` +- fixtures/reject/src/lib.rs:126:11: unsupported call to ` as std::iter::Iterator>::cycle` +- fixtures/reject/src/lib.rs:180:8: unsupported call to `std::ops::Range::::contains::` +- fixtures/reject/src/lib.rs:336:4: unsupported call to `core::slice::::copy_within::>` +- fixtures/reject/src/lib.rs:351:10: unsupported call to `::hash::` +- fixtures/reject/src/lib.rs:394:2: unsupported call to ` as std::ops::Deref>::deref` +- fixtures/reject/src/lib.rs:420:2: unsupported call to ` as std::cmp::PartialEq>::eq` +- fixtures/reject/src/lib.rs:439:17: unsupported call to ` as std::iter::Iterator>::sum::` +- fixtures/reject/src/lib.rs:439:38: unsupported call to ` as std::iter::Iterator>::sum::` +- fixtures/reject/src/lib.rs:449:2: unsupported call to `::fmt`
a variant of `_`, which is not supported: either is the same JS string (4) -- fixtures/reject/src/lib.rs:396:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string -- fixtures/reject/src/lib.rs:397:30: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string -- fixtures/reject/src/lib.rs:398:27: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string -- fixtures/reject/src/lib.rs:403:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +- fixtures/reject/src/lib.rs:382:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +- fixtures/reject/src/lib.rs:383:30: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +- fixtures/reject/src/lib.rs:384:27: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string +- fixtures/reject/src/lib.rs:389: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:110:2: an assignment through a reference to `std::sync::Arc` -- fixtures/reject/src/lib.rs:125:2: an assignment through a reference to `std::pin::Pin>` -- fixtures/reject/src/lib.rs:130:2: an assignment through a reference to `std::sync::MutexGuard<'_, u8>` -- fixtures/reject/src/lib.rs:248:2: an assignment through a reference to `std::pin::Pin<&mut Noisy>` +- fixtures/reject/src/lib.rs:101:2: an assignment through a reference to `std::sync::Arc` +- fixtures/reject/src/lib.rs:116:2: an assignment through a reference to `std::pin::Pin>` +- fixtures/reject/src/lib.rs:121:2: an assignment through a reference to `std::sync::MutexGuard<'_, u8>` +- fixtures/reject/src/lib.rs:234:2: an assignment through a reference to `std::pin::Pin<&mut Noisy>`
replacing the value behind a reference to `_` (3) -- fixtures/reject/src/lib.rs:94:2: replacing the value behind a reference to `Meters` -- fixtures/reject/src/lib.rs:98:2: replacing the value behind a reference to `Meters` -- fixtures/reject/src/lib.rs:254:22: replacing the value behind a reference to `[u16; 1]` +- fixtures/reject/src/lib.rs:85:2: replacing the value behind a reference to `Meters` +- fixtures/reject/src/lib.rs:89:2: replacing the value behind a reference to `Meters` +- fixtures/reject/src/lib.rs:240:22: replacing the value behind a reference to `[u16; 1]`
@@ -221,14 +215,14 @@ The type or module each refused type or path belongs to. - fixtures/reject/src/lib.rs:7:14: unsupported type `f32` - fixtures/reject/src/lib.rs:7:25: unsupported type `f32` -- fixtures/reject/src/lib.rs:103:51: unsupported type `f32` +- fixtures/reject/src/lib.rs:94:51: unsupported type `f32`
`_` is not supported: it would be pending two ways with one value (2) -- fixtures/reject/src/lib.rs:114:20: `Poll>>` is not supported: it would be pending two ways with one value -- fixtures/reject/src/lib.rs:119:54: `Poll>` is not supported: it would be pending two ways with one value +- fixtures/reject/src/lib.rs:105:20: `Poll>>` is not supported: it would be pending two ways with one value +- fixtures/reject/src/lib.rs:110:54: `Poll>` is not supported: it would be pending two ways with one value
@@ -242,68 +236,68 @@ The type or module each refused type or path belongs to.
`_` of `_`, whose `None` is `rt.None`, which is not supported yet (2) - fixtures/reject/src/lib.rs:41:42: `Iterator::find` of `Option>`, whose `None` is `rt.None`, which is not supported yet -- fixtures/reject/src/lib.rs:277:6: `HashMap::get` of `Option<&std::option::Option>`, whose `None` is `rt.None`, which is not supported yet +- fixtures/reject/src/lib.rs:263:6: `HashMap::get` of `Option<&std::option::Option>`, whose `None` is `rt.None`, which is not supported yet
`_` of a reference to an array of bytes it is generic over, which its mapping would take as the array, not as a slice of it (2) -- fixtures/reject/src/lib.rs:261: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:261: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:247: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:247: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 trait object of the generic trait `_`, which is not supported yet (2) -- fixtures/reject/src/lib.rs:488:23: `dyn Scaled`, a trait object of the generic trait `Scaled`, which is not supported yet -- fixtures/reject/src/lib.rs:489:4: `dyn Scaled`, a trait object of the generic trait `Scaled`, which is not supported yet +- fixtures/reject/src/lib.rs:474:23: `dyn Scaled`, a trait object of the generic trait `Scaled`, which is not supported yet +- fixtures/reject/src/lib.rs:475:4: `dyn Scaled`, a trait object of the generic trait `Scaled`, which is not supported yet
a coercion to `_`, which is not supported yet (2) -- fixtures/reject/src/lib.rs:479:40: a coercion to `std::sync::Weak`, which is not supported yet -- fixtures/reject/src/lib.rs:515:30: a coercion to `&Tail`, which is not supported yet +- fixtures/reject/src/lib.rs:465:40: a coercion to `std::sync::Weak`, which is not supported yet +- fixtures/reject/src/lib.rs:501:30: a coercion to `&Tail`, which is not supported yet
an iterator of the crate implementing `_`, which is not supported yet (2) -- fixtures/reject/src/lib.rs:168:1: an iterator of the crate implementing `DoubleEndedIterator`, which is not supported yet -- fixtures/reject/src/lib.rs:222:1: an iterator of the crate implementing `FusedIterator`, which is not supported yet +- fixtures/reject/src/lib.rs:159:1: an iterator of the crate implementing `DoubleEndedIterator`, which is not supported yet +- fixtures/reject/src/lib.rs:213:1: an iterator of the crate implementing `FusedIterator`, which is not supported yet
constructing `_` from another crate (2) -- fixtures/reject/src/lib.rs:154:23: constructing `std::iter::Map` from another crate -- fixtures/reject/src/lib.rs:175:14: constructing `std::iter::Rev` from another crate +- fixtures/reject/src/lib.rs:145:23: constructing `std::iter::Map` from another crate +- fixtures/reject/src/lib.rs:166: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:148:2: overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it -- fixtures/reject/src/lib.rs:202:2: overriding `Iterator::size_hint`, which std's adaptors call in place of `next` or beside it +- fixtures/reject/src/lib.rs:139:2: overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it +- fixtures/reject/src/lib.rs:193: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:383:13: passing `{closure@fixtures/reject/src/lib.rs:383:28: 383:35}`, a closure that owns a value that drops, to `Entry::or_insert_with`, which is not supported yet -- fixtures/reject/src/lib.rs:384:16: passing `{closure@fixtures/reject/src/lib.rs:384:25: 384:33}`, a closure that owns a value that drops, to `Iterator::for_each`, which is not supported yet +- fixtures/reject/src/lib.rs:369:13: passing `{closure@fixtures/reject/src/lib.rs:369:28: 369:35}`, a closure that owns a value that drops, to `Entry::or_insert_with`, which is not supported yet +- fixtures/reject/src/lib.rs:370:16: passing `{closure@fixtures/reject/src/lib.rs:370:25: 370:33}`, a closure that owns a value that drops, to `Iterator::for_each`, which is not supported yet
`Pointer` formatting, as in `{:p}`, is not supported (1) -- fixtures/reject/src/lib.rs:77:2: `Pointer` formatting, as in `{:p}`, is not supported +- fixtures/reject/src/lib.rs:68:2: `Pointer` formatting, as in `{:p}`, is not supported
`_` is not supported yet (1) -- fixtures/reject/src/lib.rs:407:18: `std::borrow::Cow<'_, [u8]>` is not supported yet +- fixtures/reject/src/lib.rs:393:18: `std::borrow::Cow<'_, [u8]>` is not supported yet
@@ -315,25 +309,19 @@ The type or module each refused type or path belongs to.
`_` of `_` by `_`, which is not supported yet (1) -- fixtures/reject/src/lib.rs:300:6: `HashMap::contains_key` of `std::collections::HashMap` by `u8`, which is not supported yet +- fixtures/reject/src/lib.rs:286: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:62: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:56:23: `count` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:55:10: 55:25}>`, which folds a closure that drops beside what else drops, 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
`_` through a held type's own, which is not supported yet (1) -- fixtures/reject/src/lib.rs:332:2: ` as PartialEq>::ne` through a held type's own, which is not supported yet +- fixtures/reject/src/lib.rs:318:2: ` as PartialEq>::ne` through a held type's own, which is not supported yet
@@ -345,73 +333,67 @@ The type or module each refused type or path belongs to.
`_`, which is not supported yet (1) -- fixtures/reject/src/lib.rs:308:9: `Hasher::write`, which is not supported yet +- fixtures/reject/src/lib.rs:294:9: `Hasher::write`, which is not supported yet
`f64::mul_add`, which rounds once, where JS would round twice (1) -- fixtures/reject/src/lib.rs:458:4: `f64::mul_add`, which rounds once, where JS would round twice - -
- -
`fold` of `_`, which folds a `flatten` whose source and iterators both drop, which is not supported yet (1) - -- fixtures/reject/src/lib.rs:230: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:444:4: `f64::mul_add`, which rounds once, where JS would round twice
a `zip` of `_` and `_`, which std reads by index, of items that drop, which is not supported yet (1) -- fixtures/reject/src/lib.rs:235:30: a `zip` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:235:15: 235:19}>` and `std::ops::Range`, which std reads by index, of items that drop, which is not supported yet +- fixtures/reject/src/lib.rs:221:30: a `zip` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:221:15: 221: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:181:51: a `zip` of `std::iter::Chain, {closure@fixtures/reject/src/lib.rs:181:15: 181:18}>, std::iter::Copied>>`, whose closures std calls one item further through `next` than through `fold` +- fixtures/reject/src/lib.rs:172:51: a `zip` of `std::iter::Chain, {closure@fixtures/reject/src/lib.rs:172:15: 172:18}>, std::iter::Copied>>`, whose closures std calls one item further through `next` than through `fold`
a cast from `_` to `_` (1) -- fixtures/reject/src/lib.rs:105:2: a cast from `u64` to `f32` +- fixtures/reject/src/lib.rs:96:2: a cast from `u64` to `f32`
a coercion to `_` (1) -- fixtures/reject/src/lib.rs:355:2: a coercion to `std::sync::Arc<[u8]>` +- fixtures/reject/src/lib.rs:341:2: a coercion to `std::sync::Arc<[u8]>`
a constant of type `_` (1) -- fixtures/reject/src/lib.rs:89:2: a constant of type `&u8` +- fixtures/reject/src/lib.rs:80:2: a constant of type `&u8`
a copy of a closure that changes what it captured (1) -- fixtures/reject/src/lib.rs:271:14: a copy of a closure that changes what it captured +- fixtures/reject/src/lib.rs:257: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:240:13: a mutable borrow of a subslice of `u32`, which JS would copy, having no views +- fixtures/reject/src/lib.rs:226: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:427:12: a mutable reference into a `Result`'s payload, passed on or kept +- fixtures/reject/src/lib.rs:413:12: a mutable reference into a `Result`'s payload, passed on or kept
a printable type must implement `Display` or `Debug` (1) -- fixtures/reject/src/lib.rs:101:1: a printable type must implement `Display` or `Debug` +- fixtures/reject/src/lib.rs:92:1: a printable type must implement `Display` or `Debug`
@@ -423,13 +405,13 @@ The type or module each refused type or path belongs to.
a trait object of `_`, which is not supported yet (1) -- fixtures/reject/src/lib.rs:505:26: a trait object of `[u8; 4]`, which is not supported yet +- fixtures/reject/src/lib.rs:491:26: a trait object of `[u8; 4]`, which is not supported yet
a zero-sized constant of type `_` (1) -- fixtures/reject/src/lib.rs:71:2: a zero-sized constant of type `{async closure@fixtures/reject/src/lib.rs:70:10: 70: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}`
@@ -447,30 +429,30 @@ 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:282:52: comparing `std::vec::Vec` as a key, which is not supported yet +- fixtures/reject/src/lib.rs:268:52: comparing `std::vec::Vec` as a key, which is not supported yet
constructing `_` (1) -- fixtures/reject/src/lib.rs:414:53: constructing `std::borrow::Cow<'_, std::sync::Arc>` +- fixtures/reject/src/lib.rs:400:53: constructing `std::borrow::Cow<'_, std::sync::Arc>`
hashing `_` as a key, which is not supported yet (1) -- fixtures/reject/src/lib.rs:282:52: hashing `std::vec::Vec` as a key, which is not supported yet +- fixtures/reject/src/lib.rs:268:52: hashing `std::vec::Vec` as a key, which is not supported yet
hashing `_` through `_`'s own `Hash::hash_slice`, which is not supported yet (1) -- fixtures/reject/src/lib.rs:374:16: hashing `std::vec::Vec` through `Batched`'s own `Hash::hash_slice`, which is not supported yet +- fixtures/reject/src/lib.rs:360:16: hashing `std::vec::Vec` through `Batched`'s own `Hash::hash_slice`, which is not supported yet
passing `_`, which drops, to `_`, which is not supported yet (1) -- fixtures/reject/src/lib.rs:391:4: passing `{closure@fixtures/reject/src/lib.rs:391:13: 391:27}`, which drops, to `str::contains`, which is not supported yet +- fixtures/reject/src/lib.rs:377:4: passing `{closure@fixtures/reject/src/lib.rs:377:13: 377:27}`, which drops, to `str::contains`, which is not supported yet
diff --git a/ts/fixtures/reject/expected.txt b/ts/fixtures/reject/expected.txt index cfd0e5b5e..0cd37e239 100644 --- a/ts/fixtures/reject/expected.txt +++ b/ts/fixtures/reject/expected.txt @@ -1,7 +1,7 @@ -a root must not be generic at fixtures/reject/src/lib.rs:103:1 +a root must not be generic at fixtures/reject/src/lib.rs:94:1 no item `lopsided` in the crate no item `missing` in the crate -a printable type must implement `Display` or `Debug` at fixtures/reject/src/lib.rs:101:1 +a printable type must implement `Display` or `Debug` at fixtures/reject/src/lib.rs:92:1 unsupported type `f32` at fixtures/reject/src/lib.rs:7:14 a scalar constant of type `f32` at fixtures/reject/src/lib.rs:8:2 arithmetic on `f32` at fixtures/reject/src/lib.rs:8:2 @@ -13,62 +13,60 @@ unsupported call to `std::slice::::sort` at fixtures/reject/src/lib.r `Iterator::find` of `Option>`, whose `None` is `rt.None`, which is not supported yet at fixtures/reject/src/lib.rs:41:42 `Maybe<()>` is not supported: its field `value` is `Option`, typed `T | undefined`, whose `None` would be `rt.None` as `Option<()>` at fixtures/reject/src/lib.rs:31:2 collecting `Option<()>`, whose `None` is `rt.None`, which is not supported yet at fixtures/reject/src/lib.rs:36:43 -`count` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:55:10: 55:25}>`, which folds a closure that drops beside what else drops, which is not supported yet at fixtures/reject/src/lib.rs:56:23 -`into_keys` of `std::collections::HashMap`, which drops `Noisy`, which is not supported yet at fixtures/reject/src/lib.rs:62:13 -a zero-sized constant of type `{async closure@fixtures/reject/src/lib.rs:70:10: 70:18}` at fixtures/reject/src/lib.rs:71:2 -`Pointer` formatting, as in `{:p}`, is not supported at fixtures/reject/src/lib.rs:77:11 -unsupported call to `::write_fmt` at fixtures/reject/src/lib.rs:83:10 -a constant of type `&u8` at fixtures/reject/src/lib.rs:89:2 -replacing the value behind a reference to `Meters` at fixtures/reject/src/lib.rs:94:2 -replacing the value behind a reference to `Meters` at fixtures/reject/src/lib.rs:98:2 -an assignment through a reference to `std::sync::Arc` at fixtures/reject/src/lib.rs:110:2 -`Poll>>` is not supported: it would be pending two ways with one value at fixtures/reject/src/lib.rs:114:20 -`Poll>` is not supported: it would be pending two ways with one value at fixtures/reject/src/lib.rs:119:54 -an assignment through a reference to `std::pin::Pin>` at fixtures/reject/src/lib.rs:125:2 -an assignment through a reference to `std::sync::MutexGuard<'_, u8>` at fixtures/reject/src/lib.rs:130:2 -unsupported call to ` as std::iter::Iterator>::cycle` at fixtures/reject/src/lib.rs:135:11 -constructing `std::iter::Map` from another crate at fixtures/reject/src/lib.rs:154:23 -constructing `std::iter::Rev` from another crate at fixtures/reject/src/lib.rs:175:14 -a `zip` of `std::iter::Chain, {closure@fixtures/reject/src/lib.rs:181:15: 181:18}>, std::iter::Copied>>`, whose closures std calls one item further through `next` than through `fold` at fixtures/reject/src/lib.rs:181:51 -unsupported call to `std::ops::Range::::contains::` at fixtures/reject/src/lib.rs:189: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:230:26 -a `zip` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:235:15: 235: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:235:30 -a mutable borrow of a subslice of `u32`, which JS would copy, having no views at fixtures/reject/src/lib.rs:240:13 -an assignment through a reference to `std::pin::Pin<&mut Noisy>` at fixtures/reject/src/lib.rs:248:2 -replacing the value behind a reference to `[u16; 1]` at fixtures/reject/src/lib.rs:254: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:261: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:261:38 -a copy of a closure that changes what it captured at fixtures/reject/src/lib.rs:271:14 -`HashMap::get` of `Option<&std::option::Option>`, whose `None` is `rt.None`, which is not supported yet at fixtures/reject/src/lib.rs:277:6 -hashing `std::vec::Vec` as a key, which is not supported yet at fixtures/reject/src/lib.rs:282:52 -comparing `std::vec::Vec` as a key, which is not supported yet at fixtures/reject/src/lib.rs:282:52 -`HashMap::contains_key` of `std::collections::HashMap` by `u8`, which is not supported yet at fixtures/reject/src/lib.rs:300:6 -unsupported call to `core::slice::::copy_within::>` at fixtures/reject/src/lib.rs:350:4 -a coercion to `std::sync::Arc<[u8]>` at fixtures/reject/src/lib.rs:355:2 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:396:2 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:398:27 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:397:30 -a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:403:2 -`std::borrow::Cow<'_, [u8]>` is not supported yet at fixtures/reject/src/lib.rs:407:18 -unsupported call to ` as std::ops::Deref>::deref` at fixtures/reject/src/lib.rs:408:2 -constructing `std::borrow::Cow<'_, std::sync::Arc>` at fixtures/reject/src/lib.rs:414:53 -hashing `std::vec::Vec` through `Batched`'s own `Hash::hash_slice`, which is not supported yet at fixtures/reject/src/lib.rs:374:16 -passing `{closure@fixtures/reject/src/lib.rs:383:28: 383: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:383:13 -passing `{closure@fixtures/reject/src/lib.rs:384:25: 384:33}`, a closure that owns a value that drops, to `Iterator::for_each`, which is not supported yet at fixtures/reject/src/lib.rs:384:16 -passing `{closure@fixtures/reject/src/lib.rs:391:13: 391:27}`, which drops, to `str::contains`, which is not supported yet at fixtures/reject/src/lib.rs:391:4 -unsupported call to ` as std::iter::Iterator>::sum::` at fixtures/reject/src/lib.rs:453:17 -unsupported call to ` as std::iter::Iterator>::sum::` at fixtures/reject/src/lib.rs:453:38 -a mutable reference into a `Result`'s payload, passed on or kept at fixtures/reject/src/lib.rs:427:12 -unsupported call to ` as std::cmp::PartialEq>::eq` at fixtures/reject/src/lib.rs:434:2 -`f64::mul_add`, which rounds once, where JS would round twice at fixtures/reject/src/lib.rs:458:4 -unsupported call to `::fmt` at fixtures/reject/src/lib.rs:463:11 -a coercion to `std::sync::Weak`, which is not supported yet at fixtures/reject/src/lib.rs:479:40 -`dyn Scaled`, a trait object of the generic trait `Scaled`, which is not supported yet at fixtures/reject/src/lib.rs:488:23 -`dyn Scaled`, a trait object of the generic trait `Scaled`, which is not supported yet at fixtures/reject/src/lib.rs:489:4 -a trait object of `[u8; 4]`, which is not supported yet at fixtures/reject/src/lib.rs:505:26 -a coercion to `&Tail`, which is not supported yet at fixtures/reject/src/lib.rs:515:30 -overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:148:2 -an iterator of the crate implementing `DoubleEndedIterator`, which is not supported yet at fixtures/reject/src/lib.rs:168:1 -overriding `Iterator::size_hint`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:202:2 -an iterator of the crate implementing `FusedIterator`, which is not supported yet at fixtures/reject/src/lib.rs:222:1 -`Hasher::write`, which is not supported yet at fixtures/reject/src/lib.rs:308:9 +`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 +`Pointer` formatting, as in `{:p}`, is not supported at fixtures/reject/src/lib.rs:68:11 +unsupported call to `::write_fmt` at fixtures/reject/src/lib.rs:74:10 +a constant of type `&u8` at fixtures/reject/src/lib.rs:80:2 +replacing the value behind a reference to `Meters` at fixtures/reject/src/lib.rs:85:2 +replacing the value behind a reference to `Meters` at fixtures/reject/src/lib.rs:89:2 +an assignment through a reference to `std::sync::Arc` at fixtures/reject/src/lib.rs:101:2 +`Poll>>` is not supported: it would be pending two ways with one value at fixtures/reject/src/lib.rs:105:20 +`Poll>` is not supported: it would be pending two ways with one value at fixtures/reject/src/lib.rs:110:54 +an assignment through a reference to `std::pin::Pin>` at fixtures/reject/src/lib.rs:116:2 +an assignment through a reference to `std::sync::MutexGuard<'_, u8>` at fixtures/reject/src/lib.rs:121:2 +unsupported call to ` as std::iter::Iterator>::cycle` at fixtures/reject/src/lib.rs:126:11 +constructing `std::iter::Map` from another crate at fixtures/reject/src/lib.rs:145:23 +constructing `std::iter::Rev` from another crate at fixtures/reject/src/lib.rs:166:14 +a `zip` of `std::iter::Chain, {closure@fixtures/reject/src/lib.rs:172:15: 172:18}>, std::iter::Copied>>`, whose closures std calls one item further through `next` than through `fold` at fixtures/reject/src/lib.rs:172:51 +unsupported call to `std::ops::Range::::contains::` at fixtures/reject/src/lib.rs:180:8 +a `zip` of `std::iter::Map, {closure@fixtures/reject/src/lib.rs:221:15: 221: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:221:30 +a mutable borrow of a subslice of `u32`, which JS would copy, having no views at fixtures/reject/src/lib.rs:226:13 +an assignment through a reference to `std::pin::Pin<&mut Noisy>` at fixtures/reject/src/lib.rs:234:2 +replacing the value behind a reference to `[u16; 1]` at fixtures/reject/src/lib.rs:240: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:247: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:247:38 +a copy of a closure that changes what it captured at fixtures/reject/src/lib.rs:257:14 +`HashMap::get` of `Option<&std::option::Option>`, whose `None` is `rt.None`, which is not supported yet at fixtures/reject/src/lib.rs:263:6 +hashing `std::vec::Vec` as a key, which is not supported yet at fixtures/reject/src/lib.rs:268:52 +comparing `std::vec::Vec` as a key, which is not supported yet at fixtures/reject/src/lib.rs:268:52 +`HashMap::contains_key` of `std::collections::HashMap` by `u8`, which is not supported yet at fixtures/reject/src/lib.rs:286:6 +unsupported call to `core::slice::::copy_within::>` at fixtures/reject/src/lib.rs:336:4 +a coercion to `std::sync::Arc<[u8]>` at fixtures/reject/src/lib.rs:341:2 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:382:2 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:384:27 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:383:30 +a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string at fixtures/reject/src/lib.rs:389:2 +`std::borrow::Cow<'_, [u8]>` is not supported yet at fixtures/reject/src/lib.rs:393:18 +unsupported call to ` as std::ops::Deref>::deref` at fixtures/reject/src/lib.rs:394:2 +constructing `std::borrow::Cow<'_, std::sync::Arc>` at fixtures/reject/src/lib.rs:400:53 +hashing `std::vec::Vec` through `Batched`'s own `Hash::hash_slice`, which is not supported yet at fixtures/reject/src/lib.rs:360:16 +passing `{closure@fixtures/reject/src/lib.rs:369:28: 369: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:369:13 +passing `{closure@fixtures/reject/src/lib.rs:370:25: 370:33}`, a closure that owns a value that drops, to `Iterator::for_each`, which is not supported yet at fixtures/reject/src/lib.rs:370:16 +passing `{closure@fixtures/reject/src/lib.rs:377:13: 377:27}`, which drops, to `str::contains`, which is not supported yet at fixtures/reject/src/lib.rs:377:4 +unsupported call to ` as std::iter::Iterator>::sum::` at fixtures/reject/src/lib.rs:439:17 +unsupported call to ` as std::iter::Iterator>::sum::` at fixtures/reject/src/lib.rs:439:38 +a mutable reference into a `Result`'s payload, passed on or kept at fixtures/reject/src/lib.rs:413:12 +unsupported call to ` as std::cmp::PartialEq>::eq` at fixtures/reject/src/lib.rs:420:2 +`f64::mul_add`, which rounds once, where JS would round twice at fixtures/reject/src/lib.rs:444:4 +unsupported call to `::fmt` at fixtures/reject/src/lib.rs:449:11 +a coercion to `std::sync::Weak`, which is not supported yet at fixtures/reject/src/lib.rs:465:40 +`dyn Scaled`, a trait object of the generic trait `Scaled`, which is not supported yet at fixtures/reject/src/lib.rs:474:23 +`dyn Scaled`, a trait object of the generic trait `Scaled`, which is not supported yet at fixtures/reject/src/lib.rs:475:4 +a trait object of `[u8; 4]`, which is not supported yet at fixtures/reject/src/lib.rs:491:26 +a coercion to `&Tail`, which is not supported yet at fixtures/reject/src/lib.rs:501:30 +overriding `Iterator::fold`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:139:2 +an iterator of the crate implementing `DoubleEndedIterator`, which is not supported yet at fixtures/reject/src/lib.rs:159:1 +overriding `Iterator::size_hint`, which std's adaptors call in place of `next` or beside it at fixtures/reject/src/lib.rs:193:2 +an iterator of the crate implementing `FusedIterator`, which is not supported yet at fixtures/reject/src/lib.rs:213:1 +`Hasher::write`, which is not supported yet at fixtures/reject/src/lib.rs:294:9 diff --git a/ts/fixtures/reject/src/lib.rs b/ts/fixtures/reject/src/lib.rs index 74ce254eb..20e169cb1 100644 --- a/ts/fixtures/reject/src/lib.rs +++ b/ts/fixtures/reject/src/lib.rs @@ -47,15 +47,6 @@ impl Drop for Noisy { fn drop(&mut self) {} } -/// 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); - // 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. pub fn keys(m: std::collections::HashMap) -> u8 { let mut sum = 0; @@ -225,11 +216,6 @@ pub fn fused() -> usize { Fused.fuse().count() } -/// A panic in `fold` drops the `Vec` `flatten` took mid-way before the rest, as `next` does not. -pub fn flattened(v: Vec>) -> usize { - v.into_iter().flatten().fold(0, |n, _| n + 1) -} - /// std's `zip` of two `TrustedRandomAccess` iterators makes one item past the shorter, and drops it. pub fn zip_dropped(v: &[u8]) -> usize { v.iter().map(|&n| Noisy(n)).zip(0..2).count() diff --git a/ts/fixtures/reject/ts.toml b/ts/fixtures/reject/ts.toml index 7216d83ce..8e1ec8273 100644 --- a/ts/fixtures/reject/ts.toml +++ b/ts/fixtures/reject/ts.toml @@ -8,7 +8,6 @@ roots = [ "generic_unit", "collected", "Noisy", - "owning_closure", "keys", "async_closure", "pointer", @@ -29,7 +28,6 @@ roots = [ "keyed", "hinted", "fused", - "flattened", "zip_dropped", "rest_mut", "replace_pinned_ref", diff --git a/ts/fixtures/task/expected/core/option.ts b/ts/fixtures/task/expected/core/option.ts index 925b01ea7..9caa60071 100644 --- a/ts/fixtures/task/expected/core/option.ts +++ b/ts/fixtures/task/expected/core/option.ts @@ -43,7 +43,7 @@ export function map$Option_Box_dyn_Part_u32_take(self: Part.Part | undefined, _: return self.take$Part(); } -export function map$Option_Guard_u32_iterated_closure16(self: Guard.Guard | undefined, f: (a0: Guard.Guard) => rt.u32): rt.u32 | undefined { +export function map$Option_Guard_u32_folded_closure100(self: Guard.Guard | undefined, f: (a0: Guard.Guard) => rt.u32): rt.u32 | undefined { if (self === undefined) { return undefined; } @@ -86,6 +86,13 @@ export function map$Option_u32_u32_discarded_closure16(self: rt.u32 | undefined, return _0; } +export function map$Option_usize_Guard_usize_u32_folded_closure103(self: [rt.usize, Guard.Guard] | undefined, f: (a0: [rt.usize, Guard.Guard]) => [rt.usize, rt.u32]): [rt.usize, rt.u32] | undefined { + if (self === undefined) { + return undefined; + } + return f(self); +} + export function mapOr$Option_Arc_dyn_Part_u32_shared_closure4(self: rt.Arc | undefined, default_: rt.u32, f: (a0: rt.Arc) => rt.u32): rt.u32 { if (self === undefined) { return default_; diff --git a/ts/fixtures/task/expected/drops.ts b/ts/fixtures/task/expected/drops.ts index b9d579e63..b6b192b9c 100644 --- a/ts/fixtures/task/expected/drops.ts +++ b/ts/fixtures/task/expected/drops.ts @@ -5,6 +5,7 @@ import { drop$Arc_Wrap_Pair_Held, drop$Arc_str_Arc_str, drop$Bomb_Guard, drop$Gu 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, asRef$Result_Guard_u8, mapOr$Result_Guard_u8_u32_id, 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, iterated, blasted } from "./drops/closures.ts"; +import { folded as folds_folded, rfolded as folds_rfolded } from "./drops/folds.ts"; import { looped, collected, drained, extended, bombed, spent } from "./drops/iters.ts"; import { boxed, shared } from "./drops/objects.ts"; import { run as once_run } from "./drops/once.ts"; @@ -3661,6 +3662,22 @@ export function grown(log: Log.Log, id: rt.u32, at: rt.u8, tree: boolean): void } } +/** + * Run scenario `arg % 32` of what std's by-value consumers drop of adaptors that hold + * closures that drop, panicking as a closure reads item `arg / 32`, if any. + */ +export function folded(log: Log.Log, id: rt.u32, arg: rt.u8): void { + folds_folded(log, id, arg); +} + +/** + * Run scenario `arg % 9` of what folds back to front, and through what wraps a closure + * beside another, panicking as a closure reads item `arg / 9 % 8`, if any. + */ +export function rfolded(log: Log.Log, id: rt.u32, arg: rt.u8): void { + folds_rfolded(log, id, arg); +} + /** * What a `Vec`'s edits, its and a tuple's `clone`, and `Ord`'s defaults drop, scenario * `at`'s alone, and what is left to drop when a closure, a clone, a drop, or an index diff --git a/ts/fixtures/task/expected/drops/closures.ts b/ts/fixtures/task/expected/drops/closures.ts index 7d7d6d794..3c5fd9397 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_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$Option_Guard_u32_folded_closure100, 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"; @@ -1301,7 +1301,7 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }), rt.drop); unwind = 307; _556 = true; - const part2 = map$Option_Guard_u32_iterated_closure16(rt.iterToOption(chained.next()), (g8: Guard.Guard): rt.u32 => { + const part2 = map$Option_Guard_u32_folded_closure100(rt.iterToOption(chained.next()), (g8: Guard.Guard): rt.u32 => { let unwind3: number = 0; try { unwind3 = 4; @@ -1319,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_closure16(rt.iterToOption(chained.next()), (g9: Guard.Guard): rt.u32 => { + const part3 = map$Option_Guard_u32_folded_closure100(rt.iterToOption(chained.next()), (g9: Guard.Guard): rt.u32 => { let unwind4: number = 0; try { unwind4 = 4; @@ -1412,7 +1412,7 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { return rt.thenSome(n7 < 3, rt.u32Add(n7, Guard.id(captured13))); }, (): void => { rt.drop(captured13); - })), false, rt.drop); + })), "next"); unwind = 260; const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(whiles, f, rt.u32Debug)]; Log.note(log, rt.fmtFormat(["map_while ", args12[0]])); @@ -1432,7 +1432,7 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { return Guard.id(captured15); }, (): void => { rt.drop(captured15); - })), 2), rt.drop); + })), 2)); _548 = false; const captured16 = j; const walked: rt.u32 = rt.iterSum(rt.iterSuccessors(1, rt.closure((_27: rt.u32): rt.u32 | undefined => { @@ -1440,7 +1440,7 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { return rt.thenSome(n8 < 3, rt.u32Sub(rt.u32Add(rt.u32Add(n8, 1), Guard.id(captured16)), Guard.id(captured16))); }, (): void => { rt.drop(captured16); - })), rt.u32Add, 0, rt.drop); + })), rt.u32Add, 0, true); s = guard(43); unwind = 291; _547 = true; @@ -1461,7 +1461,7 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }), rt.drop); unwind = 289; _546 = true; - const _274: rt.u32 | undefined = map$Option_Guard_u32_iterated_closure16(rt.iterToOption(chain.next()), (g11: Guard.Guard): rt.u32 => { + const _274: rt.u32 | undefined = map$Option_Guard_u32_folded_closure100(rt.iterToOption(chain.next()), (g11: Guard.Guard): rt.u32 => { let unwind5: number = 0; try { unwind5 = 4; @@ -1479,7 +1479,7 @@ 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), (f: rt.Formatter) => rt.fmtOption(_274, f, rt.u32Debug)]; Log.note(log, rt.fmtFormat(["lazy ", args14[0], " ", args14[1], " ", args14[2]])); - const part5 = map$Option_Guard_u32_iterated_closure16(rt.iterToOption(chain.next()), (g12: Guard.Guard): rt.u32 => { + const part5 = map$Option_Guard_u32_folded_closure100(rt.iterToOption(chain.next()), (g12: Guard.Guard): rt.u32 => { let unwind6: number = 0; try { unwind6 = 4; @@ -1543,7 +1543,7 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured23); }); - const found: rt.u32 | undefined = map$Option_Guard_u32_iterated_closure16(rt.dropAfter(_342, () => rt.iterFind(_339, _342)), (g15: Guard.Guard): rt.u32 => { + const found: rt.u32 | undefined = map$Option_Guard_u32_folded_closure100(rt.dropAfter(_342, () => rt.iterFind(_339, _342)), (g15: Guard.Guard): rt.u32 => { return Guard.id(g15); }); const _345: rt.Iter = rt.iterSlice(items); @@ -1567,7 +1567,7 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { return rt.u32Add(_214, Guard.id(captured25)); }, (): void => { rt.drop(captured25); - })), rt.u32Add, 0, rt.drop); + })), rt.u32Add, 0, true); o = guard(28); unwind = 281; _541 = true; @@ -1603,7 +1603,7 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { return rt.u32Add(_217, Guard.id(captured27)); }, (): void => { rt.drop(captured27); - }))), rt.drop); + })))); const _413: rt.Iter = rt.iterSlice([1, 2, 3]); _539 = false; const captured28 = u; @@ -1611,7 +1611,7 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { return rt.u32Add(_221, Guard.id(captured28)); }, (): void => { rt.drop(captured28); - })), 1), rt.drop); + })), 1)); const _420: rt.Iter = rt.iterSlice([1, 2]); _538 = false; const captured29 = v6; @@ -1619,7 +1619,7 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { return rt.u32Add(_223, Guard.id(captured29)); }, (): void => { rt.drop(captured29); - })), 1), rt.drop); + })), 1)); 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); @@ -1640,7 +1640,7 @@ export function iterated(log: Log.Log, id: rt.u32, at: rt.u8): void { }, (): void => { rt.drop(captured32); }); - const part8 = map$Option_Guard_u32_iterated_closure16(rt.dropAfter(_448, () => rt.iterMaxByKey(_442, _448, undefined, rt.drop)), (g18: Guard.Guard): rt.u32 => { + const part8 = map$Option_Guard_u32_folded_closure100(rt.dropAfter(_448, () => rt.iterMaxByKey(_442, _448, undefined, rt.drop)), (g18: Guard.Guard): rt.u32 => { let unwind7: number = 0; try { unwind7 = 4; diff --git a/ts/fixtures/task/expected/drops/folds.ts b/ts/fixtures/task/expected/drops/folds.ts new file mode 100644 index 000000000..d64353976 --- /dev/null +++ b/ts/fixtures/task/expected/drops/folds.ts @@ -0,0 +1,3191 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "../rt.ts"; +import { drop$Guard_u64, drop$u32_Guard, drop$usize_Guard } from "../lib.ts"; +import { map$Option_Guard_u32_folded_closure100, map$Option_usize_Guard_usize_u32_folded_closure103 } from "../core/option.ts"; +import * as Bomb from "../drops.Bomb.ts"; +import * as Log from "../log.Log.ts"; +import * as Guard from "../model.Guard.ts"; + +/** The id of `bomb`, which a closure that calls it captures whole. */ +export function bombId(bomb: Bomb.Bomb): rt.u32 { + return bomb.id; +} + +/** + * Run scenario `arg % 32`, panicking as a closure reads item `arg / 32`, if any. Items + * are guards 1 to 7; what closures own, 10 and up. + */ +export function folded(log: Log.Log, id: rt.u32, arg: rt.u8): void { + let c!: Guard.Guard; + let d!: Guard.Guard; + let _18!: Guard.Guard; + let best!: Guard.Guard | undefined; + let least!: Guard.Guard | undefined; + let same!: Guard.Guard[]; + let wider!: [Guard.Guard, rt.u64][]; + let queue!: rt.VecDeque; + let tree!: rt.BTreeMap; + let v!: Guard.Guard[]; + let tree2!: rt.BTreeMap; + let e!: Guard.Guard; + let f!: Guard.Guard; + let _302!: Guard.Guard; + let _332!: rt.Iter; + let _363!: rt.Iter; + let _377!: rt.Iter; + let peek!: rt.Peekable; + let flat!: rt.Iter; + let _693!: rt.Iter; + let peek2!: rt.Peekable; + let ended!: rt.Peekable; + let flat2!: rt.Iter; + let kept2!: Guard.Guard | undefined; + let _979!: rt.Iter; + let bomb!: Bomb.Bomb; + let _1048!: rt.Iter; + let _1146!: boolean; + let _1147!: boolean; + let _1148!: boolean; + let _1149!: boolean; + let _1150!: boolean; + let _1151!: boolean; + let _1152!: boolean; + let _1153!: boolean; + let _1154!: boolean; + let _1155!: boolean; + let _1156!: boolean; + let _1157!: boolean; + let _1158!: boolean; + let _1159!: boolean; + let _1160!: boolean; + let _1161!: boolean; + let _1162!: boolean; + let _1163!: boolean; + let _1164!: boolean; + let unwind: number = 0; + try { + _1147 = false; + _1146 = false; + _1164 = false; + _1163 = false; + _1162 = false; + _1161 = false; + _1160 = false; + _1159 = false; + _1158 = false; + _1157 = false; + _1156 = false; + _1155 = false; + _1154 = false; + _1153 = false; + _1152 = false; + _1151 = false; + _1150 = false; + _1149 = false; + _1148 = false; + const _8: rt.u32 = rt.u32Add(id, rt.u8Div(arg, 32) as rt.u32); + unwind = 0; + const at: rt.u32 = _8; + const guard: (a0: rt.u32) => Guard.Guard = (n25: rt.u32): Guard.Guard => { + return Guard.new(rt.u32Add(id, n25), Log.clone$Clone(log)); + }; + const guards: (a0: rt.u32, a1: rt.u32) => Guard.Guard[] = (from: rt.u32, to: rt.u32): Guard.Guard[] => { + return rt.iterToArray(rt.iterMap(new rt.Range(from, to), guard), undefined, rt.drop); + }; + const captured = at; + const captured2 = id; + const trip: (a0: Guard.Guard) => void = (g: Guard.Guard): void => { + if (Guard.id(g) === captured) { + const _10: rt.u32 = rt.u32Sub(Guard.id(g), captured2); + const args78: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(captured2, f), (f: rt.Formatter) => rt.u32Display(_10, f)]; + rt.panicFmt(["d", args78[0], " at ", args78[1]]); + } + }; + const captured3 = id; + const captured4 = at; + const trips: (a0: rt.u32) => void = (n26: rt.u32): void => { + if (rt.u32Add(captured3, n26) === captured4) { + const args80: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(captured3, f), (f: rt.Formatter) => rt.u32Display(n26, f)]; + rt.panicFmt(["d", args80[0], " at ", args80[1]]); + } + }; + _18 = guard(10); + unwind = 588; + const _21: Guard.Guard = guard(11); + unwind = 626; + _1147 = true; + c = _18; + _1146 = true; + d = _21; + const _24: rt.u8 = rt.u8Rem(arg, 32); + if (_24 === 0) { + const _28: rt.Iter = rt.iterSlice(guards(1, 5), rt.drop); + _1147 = false; + const captured126 = trip; + const captured127 = c; + const n: rt.usize = rt.ownedCount(rt.iterMap(_28, rt.closure((g95: Guard.Guard): rt.u32 => { + let unwind76: number = 0; + try { + unwind76 = 7; + captured126(g95); + const _11104: rt.u32 = rt.u32Add(Guard.id(g95), Guard.id(captured127)); + unwind76 = 0; + rt.drop(g95); + return _11104; + } catch (e77) { + if (unwind76 === 0) { + throw e77; + } + rt.drop(g95); + throw e77; + } + }, (): void => { + rt.drop(captured127); + }))); + const _35: rt.Iter = rt.iterSlice(guards(5, 8), rt.drop); + _1146 = false; + const captured128 = trip; + const captured129 = id; + const captured130 = d; + const sum: rt.u32 = rt.iterSum(rt.iterMap(_35, rt.closure((g96: Guard.Guard): rt.u32 => { + let unwind77: number = 0; + try { + unwind77 = 9; + captured128(g96); + const _1719: rt.u32 = rt.u32Sub(rt.u32Add(rt.u32Sub(Guard.id(g96), captured129), Guard.id(captured130)), captured129); + unwind77 = 0; + rt.drop(g96); + return _1719; + } catch (e78) { + if (unwind77 === 0) { + throw e78; + } + rt.drop(g96); + throw e78; + } + }, (): void => { + rt.drop(captured130); + })), rt.u32Add, 0, true); + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(n, f), (f: rt.Formatter) => rt.u32Display(sum, f)]; + Log.note(log, rt.fmtFormat(["count ", args2[0], " ", args2[1]])); + } else if (_24 === 1) { + const _54: rt.Iter = rt.iterSlice(guards(1, 7), rt.drop); + _1147 = false; + const captured124 = trip; + const captured125 = c; + const _67: rt.u32 | undefined = map$Option_Guard_u32_folded_closure100(rt.iterFold(rt.iterFilter(_54, rt.closure((g93: Guard.Guard): boolean => { + captured124(g93); + return rt.u32Rem(Guard.id(g93), 2) === rt.u32Rem(Guard.id(captured125), 2); + }, (): void => { + rt.drop(captured125); + }), rt.drop), undefined as Guard.Guard | undefined, (kept4: Guard.Guard | undefined, g94: Guard.Guard): Guard.Guard | undefined => { + let _098!: Guard.Guard | undefined; + let _3111!: boolean; + let unwind74: number = 0; + try { + unwind74 = 18; + _3111 = false; + let _303: boolean = false; + _3111 = true; + _303 = true; + const _1087: rt.u32 = Guard.id(g94); + const _1333: rt.u32 | undefined = map$Option_Guard_u32_folded_closure100(kept4, (k2: Guard.Guard): rt.u32 => { + return Guard.id(k2); + }); + const args116: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_1087, f), (f: rt.Formatter) => rt.fmtOption(_1333, f, rt.u32Debug)]; + Log.note(log, rt.fmtFormat(["fold ", args116[0], " ", args116[1]])); + if (!(rt.u32Rem(Guard.id(g94), 4) === 0)) { + _303 = false; + _098 = g94; + } else { + _3111 = false; + _098 = kept4; + } + if (_303) { + unwind74 = 23; + rt.drop(g94); + } + if (_3111) { + unwind74 = 0; + rt.drop(kept4); + return _098; + } + return _098; + } catch (e75) { + if (unwind74 === 0) { + throw e75; + } + if (unwind74 === 18) { + rt.drop(g94); + } + if (_3111) { + rt.drop(kept4); + } + throw e75; + } + }, true, rt.drop), (k3: Guard.Guard): rt.u32 => { + let unwind75: number = 0; + try { + unwind75 = 4; + const _0100: rt.u32 = Guard.id(k3); + unwind75 = 0; + rt.drop(k3); + return _0100; + } catch (e76) { + if (unwind75 === 0) { + throw e76; + } + rt.drop(k3); + throw e76; + } + }); + const _69: rt.u32 = Guard.id(d); + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(_67, f, rt.u32Debug), (f: rt.Formatter) => rt.u32Display(_69, f)]; + Log.note(log, rt.fmtFormat(["fold ", args4[0], " ", args4[1]])); + } else if (_24 === 2) { + const _78: rt.Iter = rt.iterSlice(guards(1, 7), rt.drop); + _1147 = false; + const captured122 = trip; + const captured123 = c; + rt.iterForEach(rt.iterFilterMap(_78, rt.closure((g91: Guard.Guard): Guard.Guard | undefined => { + let _1717!: boolean; + let unwind72: number = 0; + try { + unwind72 = 10; + _1717 = false; + _1717 = true; + captured122(g91); + const _7111: boolean = rt.u32Rem(Guard.id(g91), 3) !== rt.u32Rem(Guard.id(captured123), 3); + _1717 = false; + return rt.thenSome(_7111, g91, rt.drop); + } catch (e73) { + if (unwind72 === 0) { + throw e73; + } + if (_1717) { + rt.drop(g91); + } + throw e73; + } + }, (): void => { + rt.drop(captured123); + })), (g92: Guard.Guard): void => { + let unwind73: number = 0; + try { + unwind73 = 9; + const part52 = Guard.id(g92); + const args114: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(part52, f)]; + Log.note(log, rt.fmtFormat(["each ", args114[0]])); + unwind73 = 0; + rt.drop(g92); + } catch (e74) { + if (unwind73 === 0) { + throw e74; + } + rt.drop(g92); + throw e74; + } + }, true); + const part53 = Guard.id(d); + const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(part53, f)]; + Log.note(log, rt.fmtFormat(["each ", args6[0]])); + } else if (_24 === 3) { + const _98: rt.Iter = rt.iterSlice(guards(1, 5), rt.drop); + _1147 = false; + const captured120 = trip; + const captured121 = c; + const _109: rt.u32 | undefined = map$Option_Guard_u32_folded_closure100(rt.ownedLast(rt.iterInspect(_98, rt.closure((g89: Guard.Guard): void => { + captured120(g89); + const _1221: rt.u32 = Guard.id(g89); + const _1415: rt.u32 = Guard.id(captured121); + const args112: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_1221, f), (f: rt.Formatter) => rt.u32Display(_1415, f)]; + Log.note(log, rt.fmtFormat(["inspect ", args112[0], " ", args112[1]])); + }, (): void => { + rt.drop(captured121); + }), rt.drop), rt.drop), (g90: Guard.Guard): rt.u32 => { + let unwind71: number = 0; + try { + unwind71 = 4; + const _095: rt.u32 = Guard.id(g90); + unwind71 = 0; + rt.drop(g90); + return _095; + } catch (e72) { + if (unwind71 === 0) { + throw e72; + } + rt.drop(g90); + throw e72; + } + }); + const _111: rt.u32 = Guard.id(d); + const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(_109, f, rt.u32Debug), (f: rt.Formatter) => rt.u32Display(_111, f)]; + Log.note(log, rt.fmtFormat(["last ", args8[0], " ", args8[1]])); + } else if (_24 === 4) { + const _120: rt.Iter = rt.iterSlice(guards(1, 6), rt.drop); + _1147 = false; + const captured117 = trip; + const captured118 = c; + best = rt.iterMaxByKey(rt.iterMap(_120, rt.closure((g83: Guard.Guard): Guard.Guard => { + let unwind67: number = 0; + try { + unwind67 = 11; + captured117(g83); + const _1331: rt.u32 = Guard.id(g83); + const _1625: rt.u32 = Guard.id(captured118); + const args110: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_1331, f), (f: rt.Formatter) => rt.u32Display(_1625, f)]; + Log.note(log, rt.fmtFormat(["map ", args110[0], " ", args110[1]])); + return g83; + } catch (e68) { + if (unwind67 === 0) { + throw e68; + } + rt.drop(g83); + throw e68; + } + }, (): void => { + rt.drop(captured118); + })), (g84: Guard.Guard): rt.u32 => { + return rt.u32Rem(Guard.id(g84), 3); + }, true, rt.drop); + unwind = 624; + _1164 = true; + const _127: rt.Iter = rt.iterSlice(guards(6, 8), rt.drop); + const captured119 = trip; + least = rt.iterMinByKey(rt.iterMap(_127, (g85: Guard.Guard): Guard.Guard => { + let unwind68: number = 0; + try { + unwind68 = 3; + captured119(g85); + return g85; + } catch (e69) { + if (unwind68 === 0) { + throw e69; + } + rt.drop(g85); + throw e69; + } + }), (g86: Guard.Guard): rt.u32 => { + return rt.u32Add(Guard.id(g86), Guard.id(d)); + }, true, rt.drop); + unwind = 622; + _1163 = true; + _1164 = false; + const _140: rt.u32 | undefined = map$Option_Guard_u32_folded_closure100(best, (g87: Guard.Guard): rt.u32 => { + let unwind69: number = 0; + try { + unwind69 = 4; + const _093: rt.u32 = Guard.id(g87); + unwind69 = 0; + rt.drop(g87); + return _093; + } catch (e70) { + if (unwind69 === 0) { + throw e70; + } + rt.drop(g87); + throw e70; + } + }); + _1163 = false; + const _143: rt.u32 | undefined = map$Option_Guard_u32_folded_closure100(least, (g88: Guard.Guard): rt.u32 => { + let unwind70: number = 0; + try { + unwind70 = 4; + const _094: rt.u32 = Guard.id(g88); + unwind70 = 0; + rt.drop(g88); + return _094; + } catch (e71) { + if (unwind70 === 0) { + throw e71; + } + rt.drop(g88); + throw e71; + } + }); + const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(_140, f, rt.u32Debug), (f: rt.Formatter) => rt.fmtOption(_143, f, rt.u32Debug)]; + Log.note(log, rt.fmtFormat(["best ", args10[0], " ", args10[1]])); + _1163 = false; + _1164 = false; + } else if (_24 === 5) { + const _152: rt.Iter = rt.iterSlice(guards(1, 4), rt.drop); + _1147 = false; + const captured112 = trip; + const captured113 = c; + const max: rt.u32 | undefined = rt.iterMax(rt.iterMap(_152, rt.closure((g81: Guard.Guard): rt.u32 => { + let unwind65: number = 0; + try { + unwind65 = 7; + captured112(g81); + const _7108: rt.u32 = Guard.id(g81); + const _9103: rt.u32 = Guard.id(captured113); + unwind65 = 0; + const _087: rt.u32 = rt.u32Rem(_7108, _9103); + rt.drop(g81); + return _087; + } catch (e66) { + if (unwind65 === 0) { + throw e66; + } + rt.drop(g81); + throw e66; + } + }, (): void => { + rt.drop(captured113); + })), true); + const _159: rt.Iter = rt.iterSlice(guards(4, 7), rt.drop); + _1146 = false; + const captured114 = trip; + const captured115 = id; + const captured116 = d; + const product: rt.u32 = rt.iterProduct(rt.iterMap(_159, rt.closure((g82: Guard.Guard): rt.u32 => { + let unwind66: number = 0; + try { + unwind66 = 10; + captured114(g82); + const _1814: rt.u32 = rt.u32Sub(rt.u32Add(rt.u32Sub(Guard.id(g82), captured115), Guard.id(captured116)), Guard.id(captured116)); + unwind66 = 0; + rt.drop(g82); + return _1814; + } catch (e67) { + if (unwind66 === 0) { + throw e67; + } + rt.drop(g82); + throw e67; + } + }, (): void => { + rt.drop(captured116); + })), rt.u32Mul, 1, true); + const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(max, f, rt.u32Debug), (f: rt.Formatter) => rt.u32Display(product, f)]; + Log.note(log, rt.fmtFormat(["max ", args12[0], " ", args12[1]])); + } else if (_24 === 6) { + const _178: rt.Iter = rt.iterSlice(guards(1, 4), rt.drop); + _1147 = false; + const captured108 = trip; + const captured109 = c; + same = rt.iterToArray(rt.iterMap(_178, rt.closure((g79: Guard.Guard): Guard.Guard => { + let unwind63: number = 0; + try { + unwind63 = 11; + captured108(g79); + const _1329: rt.u32 = Guard.id(g79); + const _1623: rt.u32 = Guard.id(captured109); + const args108: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_1329, f), (f: rt.Formatter) => rt.u32Display(_1623, f)]; + Log.note(log, rt.fmtFormat(["map ", args108[0], " ", args108[1]])); + return g79; + } catch (e64) { + if (unwind63 === 0) { + throw e64; + } + rt.drop(g79); + throw e64; + } + }, (): void => { + rt.drop(captured109); + })), "place", rt.drop); + unwind = 586; + const _185: rt.Iter = rt.iterSlice(guards(4, 7), rt.drop); + _1146 = false; + const captured110 = trip; + const captured111 = d; + wider = rt.iterToArray(rt.iterMap(_185, rt.closure((g80: Guard.Guard): [Guard.Guard, rt.u64] => { + let _7107!: Guard.Guard; + let _1199!: boolean; + let unwind64: number = 0; + try { + unwind64 = 8; + _1199 = false; + _1199 = true; + captured110(g80); + unwind64 = 5; + _1199 = false; + _7107 = g80; + return [_7107, Guard.id(captured111) as rt.u64] as [Guard.Guard, rt.u64]; + } catch (e65) { + if (unwind64 === 0) { + throw e65; + } + if (unwind64 === 5) { + rt.drop(_7107); + } + if (_1199) { + rt.drop(g80); + } + throw e65; + } + }, (): void => { + rt.drop(captured111); + })), "fold", drop$Guard_u64); + unwind = 585; + const _196: rt.usize = same.length; + const _199: rt.usize = wider.length; + const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(_196, f), (f: rt.Formatter) => rt.usizeDisplay(_199, f)]; + Log.note(log, rt.fmtFormat(["collected ", args14[0], " ", args14[1]])); + unwind = 586; + rt.dropAll(wider, drop$Guard_u64); + unwind = 626; + rt.dropAll(same); + } else if (_24 === 7) { + const _208: rt.Iter = rt.iterSlice(guards(1, 4), rt.drop); + _1147 = false; + const captured104 = trip; + const captured105 = c; + const _207: rt.Iter = rt.iterMap(_208, rt.closure((g77: Guard.Guard): Guard.Guard => { + let unwind61: number = 0; + try { + unwind61 = 11; + captured104(g77); + const _1327: rt.u32 = Guard.id(g77); + const _1622: rt.u32 = Guard.id(captured105); + const args106: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_1327, f), (f: rt.Formatter) => rt.u32Display(_1622, f)]; + Log.note(log, rt.fmtFormat(["map ", args106[0], " ", args106[1]])); + return g77; + } catch (e62) { + if (unwind61 === 0) { + throw e62; + } + rt.drop(g77); + throw e62; + } + }, (): void => { + rt.drop(captured105); + })); + queue = rt.dequeExtend(rt.dequeNew() as rt.VecDeque, rt.iterSlice(rt.iterToArray(_207, "place", rt.drop))); + unwind = 584; + const _215: rt.Iter = rt.iterSlice(guards(4, 7), rt.drop); + _1146 = false; + const captured106 = trip; + const captured107 = d; + const _214: rt.Iter<[rt.u32, Guard.Guard]> = rt.iterMap(_215, rt.closure((g78: Guard.Guard): [rt.u32, Guard.Guard] => { + let unwind62: number = 0; + try { + unwind62 = 6; + captured106(g78); + return [rt.u32Add(Guard.id(g78), Guard.id(captured107)), g78] as [rt.u32, Guard.Guard]; + } catch (e63) { + if (unwind62 === 0) { + throw e63; + } + rt.drop(g78); + throw e63; + } + }, (): void => { + rt.drop(captured107); + })); + tree = rt.btreeCollect(rt.btreeNew(rt.cmp) as rt.BTreeMap, rt.iterToArray(_214, "fold", drop$u32_Guard), undefined, rt.drop); + unwind = 583; + const _226: rt.usize = queue.n; + const _229: rt.usize = rt.btreeLen(tree); + const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(_226, f), (f: rt.Formatter) => rt.usizeDisplay(_229, f)]; + Log.note(log, rt.fmtFormat(["collected ", args16[0], " ", args16[1]])); + unwind = 584; + rt.btreeDrop(tree, undefined, rt.drop); + unwind = 626; + rt.dequeDrop(queue, rt.drop); + } else if (_24 === 8) { + v = guards(1, 2); + unwind = 582; + const _242: rt.Iter = rt.iterSlice(guards(2, 4), rt.drop); + _1147 = false; + const captured100 = trip; + const captured101 = c; + const _241: rt.Iter = rt.iterMap(_242, rt.closure((g75: Guard.Guard): Guard.Guard => { + let unwind59: number = 0; + try { + unwind59 = 11; + captured100(g75); + const _1325: rt.u32 = Guard.id(g75); + const _1621: rt.u32 = Guard.id(captured101); + const args104: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_1325, f), (f: rt.Formatter) => rt.u32Display(_1621, f)]; + Log.note(log, rt.fmtFormat(["map ", args104[0], " ", args104[1]])); + return g75; + } catch (e60) { + if (unwind59 === 0) { + throw e60; + } + rt.drop(g75); + throw e60; + } + }, (): void => { + rt.drop(captured101); + })); + rt.iterExtend(v, _241, "fold"); + tree2 = rt.btreeNew(rt.cmp) as rt.BTreeMap; + unwind = 581; + const _251: rt.Iter = rt.iterSlice(guards(4, 7), rt.drop); + _1146 = false; + const captured102 = trip; + const captured103 = d; + const _250: rt.Iter<[rt.u32, Guard.Guard]> = rt.iterMap(_251, rt.closure((g76: Guard.Guard): [rt.u32, Guard.Guard] => { + let unwind60: number = 0; + try { + unwind60 = 6; + captured102(g76); + return [rt.u32Add(Guard.id(g76), Guard.id(captured103)), g76] as [rt.u32, Guard.Guard]; + } catch (e61) { + if (unwind60 === 0) { + throw e61; + } + rt.drop(g76); + throw e61; + } + }, (): void => { + rt.drop(captured103); + })); + rt.btreeExtend(tree2, _250, false, undefined, rt.drop, "fold"); + const _262: rt.usize = v.length; + const _265: rt.usize = rt.btreeLen(tree2); + const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(_262, f), (f: rt.Formatter) => rt.usizeDisplay(_265, f)]; + Log.note(log, rt.fmtFormat(["extended ", args18[0], " ", args18[1]])); + unwind = 582; + rt.btreeDrop(tree2, undefined, rt.drop); + unwind = 626; + rt.dropAll(v); + } else if (_24 === 9) { + const _275: rt.Iter = rt.iterSlice([1, 2, 3, 4, 5]); + _1147 = false; + const captured97 = trips; + const captured98 = c; + const _274: rt.Iter = rt.iterMap(_275, rt.closure((_231: rt.u32): rt.u32 => { + const n40: rt.u32 = _231; + captured97(n40); + return rt.u32Add(n40, Guard.id(captured98)); + }, (): void => { + rt.drop(captured98); + })); + _1146 = false; + const captured99 = d; + const part40 = rt.ownedCount(rt.iterFilter(_274, rt.closure((n41: rt.u32): boolean => { + return rt.u32Rem(n41, 2) === rt.u32Rem(Guard.id(captured99), 2); + }, (): void => { + rt.drop(captured99); + }))); + const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(part40, f)]; + Log.note(log, rt.fmtFormat(["count ", args20[0]])); + } else if (_24 === 10) { + const _293: rt.Iter = rt.iterSlice(guards(1, 5), rt.drop); + _1147 = false; + const captured90 = trip; + const captured91 = c; + const _292: rt.Iter = rt.iterFilter(_293, rt.closure((g71: Guard.Guard): boolean => { + captured90(g71); + return Guard.id(g71) !== Guard.id(captured91); + }, (): void => { + rt.drop(captured91); + }), rt.drop); + _1146 = false; + const captured92 = id; + const captured93 = d; + const n3: rt.u32 = rt.iterSum(rt.iterMap(_292, rt.closure((g72: Guard.Guard): rt.u32 => { + let unwind57: number = 0; + try { + unwind57 = 9; + const _1413: rt.u32 = rt.u32Sub(rt.u32Add(rt.u32Sub(Guard.id(g72), captured92), Guard.id(captured93)), Guard.id(captured93)); + unwind57 = 0; + rt.drop(g72); + return _1413; + } catch (e58) { + if (unwind57 === 0) { + throw e58; + } + rt.drop(g72); + throw e58; + } + }, (): void => { + rt.drop(captured93); + })), rt.u32Add, 0, true); + _302 = guard(12); + unwind = 580; + const _305: Guard.Guard = guard(13); + unwind = 619; + _1162 = true; + e = _302; + _1161 = true; + f = _305; + const _311: rt.Iter = rt.iterSlice(guards(5, 8), rt.drop); + _1162 = false; + const captured94 = trip; + const captured95 = e; + const _310: rt.Iter = rt.iterFilterMap(_311, rt.closure((g73: Guard.Guard): Guard.Guard | undefined => { + let _1323!: boolean; + let unwind58: number = 0; + try { + unwind58 = 8; + _1323 = false; + _1323 = true; + captured94(g73); + const _7102: boolean = Guard.id(g73) !== Guard.id(captured95); + _1323 = false; + return rt.thenSome(_7102, g73, rt.drop); + } catch (e59) { + if (unwind58 === 0) { + throw e59; + } + if (_1323) { + rt.drop(g73); + } + throw e59; + } + }, (): void => { + rt.drop(captured95); + })); + _1161 = false; + const captured96 = f; + const m: rt.usize = rt.ownedCount(rt.iterInspect(_310, rt.closure((g74: Guard.Guard): void => { + const _870: rt.u32 = Guard.id(g74); + const _1079: rt.u32 = Guard.id(captured96); + const args102: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_870, f), (f: rt.Formatter) => rt.u32Display(_1079, f)]; + Log.note(log, rt.fmtFormat(["inspect ", args102[0], " ", args102[1]])); + }, (): void => { + rt.drop(captured96); + }), rt.drop), rt.drop); + const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(n3, f), (f: rt.Formatter) => rt.usizeDisplay(m, f)]; + Log.note(log, rt.fmtFormat(["two ", args22[0], " ", args22[1]])); + _1161 = false; + _1162 = false; + } else if (_24 === 11) { + _332 = rt.iterSlice(guards(1, 3), rt.drop); + unwind = 617; + _1160 = true; + const _336: Guard.Guard[] = guards(3, 5); + _1160 = false; + const _331: rt.Iter = rt.iterChain(_332, rt.iterSlice(_336, rt.drop)); + unwind = 626; + _1160 = false; + _1147 = false; + const captured85 = trip; + const captured86 = id; + const captured87 = c; + const n4: rt.u32 = rt.iterSum(rt.iterMap(_331, rt.closure((g69: Guard.Guard): rt.u32 => { + let unwind55: number = 0; + try { + unwind55 = 9; + captured85(g69); + const _1715: rt.u32 = rt.u32Sub(rt.u32Add(rt.u32Sub(Guard.id(g69), captured86), Guard.id(captured87)), captured86); + unwind55 = 0; + rt.drop(g69); + return _1715; + } catch (e56) { + if (unwind55 === 0) { + throw e56; + } + rt.drop(g69); + throw e56; + } + }, (): void => { + rt.drop(captured87); + })), rt.u32Add, 0, true); + const _343: rt.Iter = rt.iterSlice(guards(5, 7), rt.drop); + _1146 = false; + const captured88 = trip; + const captured89 = d; + const m2: rt.usize = rt.ownedCount(rt.iterChain(rt.iterMap(_343, rt.closure((g70: Guard.Guard): rt.u32 => { + let unwind56: number = 0; + try { + unwind56 = 7; + captured88(g70); + const _1185: rt.u32 = rt.u32Add(Guard.id(g70), Guard.id(captured89)); + unwind56 = 0; + rt.drop(g70); + return _1185; + } catch (e57) { + if (unwind56 === 0) { + throw e57; + } + rt.drop(g70); + throw e57; + } + }, (): void => { + rt.drop(captured89); + })), rt.iterSlice([1, 2]))); + const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(n4, f), (f: rt.Formatter) => rt.usizeDisplay(m2, f)]; + Log.note(log, rt.fmtFormat(["chain ", args24[0], " ", args24[1]])); + } else if (_24 === 12) { + _363 = rt.iterSlice(guards(1, 4), rt.drop); + unwind = 615; + _1159 = true; + const _368: rt.Iter = rt.iterSlice(guards(4, 7), rt.drop); + _1147 = false; + const captured82 = trip; + const captured83 = c; + const _367: rt.Iter = rt.iterFilter(_368, rt.closure((g65: Guard.Guard): boolean => { + captured82(g65); + return Guard.id(g65) !== Guard.id(captured83); + }, (): void => { + rt.drop(captured83); + }), rt.drop); + _1159 = false; + const _362: rt.Iter = rt.iterChain(_363, _367); + unwind = 626; + _1159 = false; + const n5: rt.u32 = rt.iterFold(_362, 0, (n39: rt.u32, g66: Guard.Guard): rt.u32 => { + let unwind52: number = 0; + try { + unwind52 = 6; + const _982: rt.u32 = rt.u32Sub(rt.u32Add(n39, Guard.id(g66)), id); + unwind52 = 0; + rt.drop(g66); + return _982; + } catch (e53) { + if (unwind52 === 0) { + throw e53; + } + rt.drop(g66); + throw e53; + } + }, true); + const _378: rt.Iter = rt.iterSlice(guards(7, 8), rt.drop); + const captured84 = trip; + _377 = rt.iterMap(_378, (g67: Guard.Guard): Guard.Guard => { + let unwind53: number = 0; + try { + unwind53 = 3; + captured84(g67); + return g67; + } catch (e54) { + if (unwind53 === 0) { + throw e54; + } + rt.drop(g67); + throw e54; + } + }); + unwind = 613; + _1158 = true; + const _383: Guard.Guard[] = []; + _1158 = false; + const _376: rt.Iter = rt.iterChain(_377, rt.iterSlice(_383, rt.drop)); + unwind = 626; + _1158 = false; + const _390: rt.u32 | undefined = map$Option_Guard_u32_folded_closure100(rt.ownedLast(_376, rt.drop), (g68: Guard.Guard): rt.u32 => { + let unwind54: number = 0; + try { + unwind54 = 4; + const _073: rt.u32 = Guard.id(g68); + unwind54 = 0; + rt.drop(g68); + return _073; + } catch (e55) { + if (unwind54 === 0) { + throw e55; + } + rt.drop(g68); + throw e55; + } + }); + const _392: rt.u32 = Guard.id(d); + const args26: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(n5, f), (f: rt.Formatter) => rt.fmtOption(_390, f, rt.u32Debug), (f: rt.Formatter) => rt.u32Display(_392, f)]; + Log.note(log, rt.fmtFormat(["chain ", args26[0], " ", args26[1], " ", args26[2]])); + } else if (_24 === 13) { + const _407: rt.Iter = rt.iterSlice(guards(1, 8), rt.drop); + _1147 = false; + const captured80 = trip; + const captured81 = c; + const n6: rt.u32 = rt.iterFold(rt.iterTake(rt.iterStepBy(rt.iterSkip(rt.iterRev(rt.iterMap(_407, rt.closure((g63: Guard.Guard): Guard.Guard => { + let unwind50: number = 0; + try { + unwind50 = 11; + captured80(g63); + const _1321: rt.u32 = Guard.id(g63); + const _1619: rt.u32 = Guard.id(captured81); + const args100: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_1321, f), (f: rt.Formatter) => rt.u32Display(_1619, f)]; + Log.note(log, rt.fmtFormat(["map ", args100[0], " ", args100[1]])); + return g63; + } catch (e51) { + if (unwind50 === 0) { + throw e51; + } + rt.drop(g63); + throw e51; + } + }, (): void => { + rt.drop(captured81); + }))), 1, rt.drop), 2, rt.drop), 2, rt.drop), 0, (n38: rt.u32, g64: Guard.Guard): rt.u32 => { + let unwind51: number = 0; + try { + unwind51 = 6; + const _976: rt.u32 = rt.u32Sub(rt.u32Add(n38, Guard.id(g64)), id); + unwind51 = 0; + rt.drop(g64); + return _976; + } catch (e52) { + if (unwind51 === 0) { + throw e52; + } + rt.drop(g64); + throw e52; + } + }, true); + const _420: rt.u32 = Guard.id(d); + const args28: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(n6, f), (f: rt.Formatter) => rt.u32Display(_420, f)]; + Log.note(log, rt.fmtFormat(["read ", args28[0], " ", args28[1]])); + } else if (_24 === 14) { + const _430: rt.Iter<[rt.usize, Guard.Guard]> = rt.iterEnumerate(rt.iterSlice(guards(1, 4), rt.drop)); + _1147 = false; + const captured76 = trip; + const captured77 = c; + const n7: rt.usize = rt.iterSum(rt.iterMap(_430, rt.closure((_228: [rt.usize, Guard.Guard]): rt.usize => { + let g60!: Guard.Guard; + let unwind47: number = 0; + try { + unwind47 = 6; + const i2: rt.usize = _228[0]; + g60 = _228[1]; + captured76(g60); + const _1214: rt.usize = rt.usizeAdd(i2, Guard.id(captured77) as rt.usize); + unwind47 = 0; + rt.drop(g60); + return _1214; + } catch (e48) { + if (unwind47 === 0) { + throw e48; + } + rt.drop(g60); + throw e48; + } + }, (): void => { + rt.drop(captured77); + })), rt.usizeAdd, 0, true); + const _439: rt.Iter = rt.iterSlice(guards(4, 7), rt.drop); + _1146 = false; + const captured78 = trip; + const captured79 = d; + const _450: [rt.usize, rt.u32] | undefined = map$Option_usize_Guard_usize_u32_folded_closure103(rt.ownedLast(rt.iterEnumerate(rt.iterMap(_439, rt.closure((g61: Guard.Guard): Guard.Guard => { + let unwind48: number = 0; + try { + unwind48 = 11; + captured78(g61); + const _1320: rt.u32 = Guard.id(g61); + const _1618: rt.u32 = Guard.id(captured79); + const args98: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_1320, f), (f: rt.Formatter) => rt.u32Display(_1618, f)]; + Log.note(log, rt.fmtFormat(["map ", args98[0], " ", args98[1]])); + return g61; + } catch (e49) { + if (unwind48 === 0) { + throw e49; + } + rt.drop(g61); + throw e49; + } + }, (): void => { + rt.drop(captured79); + }))), drop$usize_Guard), (_230: [rt.usize, Guard.Guard]): [rt.usize, rt.u32] => { + let g62!: Guard.Guard; + let unwind49: number = 0; + try { + unwind49 = 4; + const i3: rt.usize = _230[0]; + g62 = _230[1]; + const _5119: rt.u32 = Guard.id(g62); + unwind49 = 0; + rt.drop(g62); + return [i3, _5119] as [rt.usize, rt.u32]; + } catch (e50) { + if (unwind49 === 0) { + throw e50; + } + rt.drop(g62); + throw e50; + } + }); + const args30: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(n7, f), (f: rt.Formatter) => rt.fmtOption(_450, f, (value: [rt.usize, rt.u32], f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.usizeDebug(value[0], f), (f: rt.Formatter) => rt.u32Debug(value[1], f)], f))]; + Log.note(log, rt.fmtFormat(["enumerate ", args30[0], " ", args30[1]])); + } else if (_24 === 15) { + const _459: rt.Iter = rt.iterSlice(guards(1, 5), rt.drop); + _1147 = false; + const captured72 = trip; + const captured73 = c; + peek = rt.iterPeekable(rt.iterMap(_459, rt.closure((g55: Guard.Guard): Guard.Guard => { + let unwind44: number = 0; + try { + unwind44 = 11; + captured72(g55); + const _1319: rt.u32 = Guard.id(g55); + const _1617: rt.u32 = Guard.id(captured73); + const args96: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_1319, f), (f: rt.Formatter) => rt.u32Display(_1617, f)]; + Log.note(log, rt.fmtFormat(["map ", args96[0], " ", args96[1]])); + return g55; + } catch (e45) { + if (unwind44 === 0) { + throw e45; + } + rt.drop(g55); + throw e45; + } + }, (): void => { + rt.drop(captured73); + })), rt.drop); + unwind = 611; + _1157 = true; + const part32 = map$Option_Guard_u32_folded_closure100(rt.peekablePeek(peek), (g56: Guard.Guard): rt.u32 => { + return Guard.id(g56); + }); + const args32: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part32, f, rt.u32Debug)]; + Log.note(log, rt.fmtFormat(["peek ", args32[0]])); + _1157 = false; + const n8: rt.u32 = rt.iterFold(peek, 0, (n36: rt.u32, g57: Guard.Guard): rt.u32 => { + let unwind45: number = 0; + try { + unwind45 = 6; + const _969: rt.u32 = rt.u32Sub(rt.u32Add(n36, Guard.id(g57)), id); + unwind45 = 0; + rt.drop(g57); + return _969; + } catch (e46) { + if (unwind45 === 0) { + throw e46; + } + rt.drop(g57); + throw e46; + } + }, true); + const _483: rt.Iter = rt.iterFuse(rt.iterSlice(guards(5, 8), rt.drop), true); + _1146 = false; + const captured74 = trip; + const captured75 = d; + const m4: rt.u32 = rt.iterFold(rt.iterFilter(_483, rt.closure((g58: Guard.Guard): boolean => { + captured74(g58); + return Guard.id(g58) !== Guard.id(captured75); + }, (): void => { + rt.drop(captured75); + }), rt.drop), 0, (n37: rt.u32, g59: Guard.Guard): rt.u32 => { + let unwind46: number = 0; + try { + unwind46 = 5; + const _673: rt.u32 = rt.u32Add(n37, Guard.id(g59)); + unwind46 = 0; + rt.drop(g59); + return _673; + } catch (e47) { + if (unwind46 === 0) { + throw e47; + } + rt.drop(g59); + throw e47; + } + }, true); + const args34: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(n8, f), (f: rt.Formatter) => rt.u32Display(m4, f)]; + Log.note(log, rt.fmtFormat(["peek ", args34[0], " ", args34[1]])); + _1157 = false; + } else if (_24 === 16) { + const _504: rt.Iter = rt.iterSlice(guards(1, 5), rt.drop); + _1147 = false; + const captured68 = trip; + const captured69 = c; + const n9: rt.u32 = rt.iterSum(rt.iterMap(rt.iterSkipWhile(_504, rt.closure((g49: Guard.Guard): boolean => { + captured68(g49); + return Guard.id(g49) < rt.u32Sub(Guard.id(captured69), 8); + }, (): void => { + rt.drop(captured69); + }), rt.drop), (g50: Guard.Guard): rt.u32 => { + let unwind41: number = 0; + try { + unwind41 = 5; + const _658: rt.u32 = rt.u32Sub(Guard.id(g50), id); + unwind41 = 0; + rt.drop(g50); + return _658; + } catch (e42) { + if (unwind41 === 0) { + throw e42; + } + rt.drop(g50); + throw e42; + } + }), rt.u32Add, 0, true); + const _516: rt.Iter = rt.iterSlice(guards(5, 8), rt.drop); + const captured70 = trip; + const _515: rt.Iter = rt.iterMap(_516, (g51: Guard.Guard): Guard.Guard => { + let unwind42: number = 0; + try { + unwind42 = 3; + captured70(g51); + return g51; + } catch (e43) { + if (unwind42 === 0) { + throw e43; + } + rt.drop(g51); + throw e43; + } + }); + _1146 = false; + const captured71 = d; + const m5: rt.u32 = rt.iterSum(rt.iterMap(rt.iterTakeWhile(rt.iterSkipWhile(_515, rt.closure((g52: Guard.Guard): boolean => { + return Guard.id(g52) < rt.u32Sub(Guard.id(captured71), 5); + }, (): void => { + rt.drop(captured71); + }), rt.drop), (g53: Guard.Guard): boolean => { + return Guard.id(g53) < rt.u32Add(id, 7); + }, rt.drop), (g54: Guard.Guard): rt.u32 => { + let unwind43: number = 0; + try { + unwind43 = 5; + const _666: rt.u32 = rt.u32Sub(Guard.id(g54), id); + unwind43 = 0; + rt.drop(g54); + return _666; + } catch (e44) { + if (unwind43 === 0) { + throw e44; + } + rt.drop(g54); + throw e44; + } + }), rt.u32Add, 0, true); + const args36: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(n9, f), (f: rt.Formatter) => rt.u32Display(m5, f)]; + Log.note(log, rt.fmtFormat(["skip ", args36[0], " ", args36[1]])); + } else if (_24 === 17) { + const _540: rt.Iter = rt.iterSlice(guards(1, 5), rt.drop); + _1147 = false; + const captured63 = trip; + const captured64 = c; + const captured65 = id; + const n10: rt.u32 = rt.iterSum(rt.iterMapWhile(_540, rt.closure((g47: Guard.Guard): rt.u32 | undefined => { + let unwind40: number = 0; + try { + unwind40 = 8; + captured63(g47); + const _051: rt.u32 | undefined = rt.boolThen(Guard.id(g47) !== rt.u32Sub(Guard.id(captured64), 7), (): rt.u32 => { + return rt.u32Sub(Guard.id(g47), captured65); + }); + unwind40 = 0; + rt.drop(g47); + return _051; + } catch (e41) { + if (unwind40 === 0) { + throw e41; + } + rt.drop(g47); + throw e41; + } + }, (): void => { + rt.drop(captured64); + })), rt.u32Add, 0, true); + const _547: rt.Iter = rt.iterSlice(guards(5, 8), rt.drop); + _1146 = false; + const captured66 = trip; + const captured67 = d; + const m6: rt.usize = rt.ownedCount(rt.iterTakeWhile(_547, rt.closure((g48: Guard.Guard): boolean => { + captured66(g48); + return Guard.id(g48) !== rt.u32Sub(Guard.id(captured67), 4); + }, (): void => { + rt.drop(captured67); + }), rt.drop), rt.drop); + const args38: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(n10, f), (f: rt.Formatter) => rt.usizeDisplay(m6, f)]; + Log.note(log, rt.fmtFormat(["while ", args38[0], " ", args38[1]])); + } else if (_24 === 18) { + const _566: rt.Iter = rt.iterSlice([1, 3, 5]); + _1147 = false; + const captured60 = trips; + const captured61 = guard; + const captured62 = c; + const n11: rt.usize = rt.ownedCount(rt.iterFlatMap(_566, rt.closure((n35: rt.u32): Guard.Guard[] => { + let v5!: Guard.Guard[]; + let v6!: Guard.Guard[]; + let unwind39: number = 0; + try { + captured60(n35); + v6 = []; + unwind39 = 17; + const _1067: Guard.Guard = captured61(n35); + v6.push(_1067); + const _1514: Guard.Guard = captured61(rt.u32Add(n35, 1)); + v6.push(_1514); + unwind39 = 16; + v5 = v6; + const _263: rt.u32 = Guard.id(captured62); + const args94: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(n35, f), (f: rt.Formatter) => rt.u32Display(_263, f)]; + Log.note(log, rt.fmtFormat(["flat ", args94[0], " ", args94[1]])); + return v5; + } catch (e40) { + if (unwind39 === 0) { + throw e40; + } + if (unwind39 === 16) { + rt.dropAll(v5); + } else { + rt.dropAll(v6); + } + throw e40; + } + }, (): void => { + rt.drop(captured62); + }), (value: Guard.Guard[]) => rt.iterSlice(value, rt.drop), true), rt.drop); + const _575: rt.u32 = Guard.id(d); + const args40: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(n11, f), (f: rt.Formatter) => rt.u32Display(_575, f)]; + Log.note(log, rt.fmtFormat(["flat ", args40[0], " ", args40[1]])); + } else if (_24 === 19) { + const _585: rt.Iter = rt.iterSlice(guards(1, 4), rt.drop); + _1147 = false; + const captured52 = trip; + const captured53 = guard; + const captured54 = c; + const captured55 = id; + flat = rt.iterFlatten(rt.iterMap(_585, rt.closure((g43: Guard.Guard): Guard.Guard[] => { + let v3!: Guard.Guard[]; + let _237!: boolean; + let unwind34: number = 0; + try { + unwind34 = 13; + _237 = false; + _237 = true; + captured52(g43); + v3 = []; + unwind34 = 10; + _237 = false; + v3.push(g43); + const _1317: Guard.Guard = captured53(rt.u32Add(rt.u32Sub(Guard.id(captured54), captured55), 1)); + v3.push(_1317); + return v3; + } catch (e35) { + if (unwind34 === 0) { + throw e35; + } + if (unwind34 === 10) { + rt.dropAll(v3); + } + if (_237) { + rt.drop(g43); + } + throw e35; + } + }, (): void => { + rt.drop(captured54); + })), (value: Guard.Guard[]) => rt.iterSlice(value, rt.drop), true); + unwind = 609; + _1156 = true; + const part24 = map$Option_Guard_u32_folded_closure100(rt.iterToOption(flat.next()), (g44: Guard.Guard): rt.u32 => { + let unwind35: number = 0; + try { + unwind35 = 4; + const _046: rt.u32 = Guard.id(g44); + unwind35 = 0; + rt.drop(g44); + return _046; + } catch (e36) { + if (unwind35 === 0) { + throw e36; + } + rt.drop(g44); + throw e36; + } + }); + const args42: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part24, f, rt.u32Debug)]; + Log.note(log, rt.fmtFormat(["front ", args42[0]])); + _1156 = false; + const n12: rt.u32 = rt.iterSum(rt.iterMap(flat, (g45: Guard.Guard): rt.u32 => { + let unwind36: number = 0; + try { + unwind36 = 5; + const _648: rt.u32 = rt.u32Sub(Guard.id(g45), id); + unwind36 = 0; + rt.drop(g45); + return _648; + } catch (e37) { + if (unwind36 === 0) { + throw e37; + } + rt.drop(g45); + throw e37; + } + }), rt.u32Add, 0, true); + const _610: rt.Iter = rt.iterSlice([4, 6]); + _1146 = false; + const captured56 = trips; + const captured57 = guard; + const captured58 = d; + const captured59 = id; + const _619: rt.u32 | undefined = map$Option_Guard_u32_folded_closure100(rt.ownedLast(rt.iterFlatMap(_610, rt.closure((n34: rt.u32): Guard.Guard[] => { + let v4!: Guard.Guard[]; + let unwind37: number = 0; + try { + captured56(n34); + v4 = []; + unwind37 = 11; + const _964: Guard.Guard = captured57(n34); + v4.push(_964); + const _1411: Guard.Guard = captured57(rt.u32Add(rt.u32Sub(Guard.id(captured58), captured59), n34)); + v4.push(_1411); + return v4; + } catch (e38) { + if (unwind37 === 0) { + throw e38; + } + rt.dropAll(v4); + throw e38; + } + }, (): void => { + rt.drop(captured58); + }), (value: Guard.Guard[]) => rt.iterSlice(value, rt.drop), true), rt.drop), (g46: Guard.Guard): rt.u32 => { + let unwind38: number = 0; + try { + unwind38 = 4; + const _049: rt.u32 = Guard.id(g46); + unwind38 = 0; + rt.drop(g46); + return _049; + } catch (e39) { + if (unwind38 === 0) { + throw e39; + } + rt.drop(g46); + throw e39; + } + }); + const args44: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(n12, f), (f: rt.Formatter) => rt.fmtOption(_619, f, rt.u32Debug)]; + Log.note(log, rt.fmtFormat(["flat ", args44[0], " ", args44[1]])); + _1156 = false; + } else if (_24 === 20) { + const held: Guard.Guard[] = guards(1, 5); + _1147 = false; + let captured46 = held; + const captured47 = trip; + const captured48 = c; + const n13: rt.usize = rt.ownedCount(rt.iterFromFn(rt.closure((): rt.u32 | undefined => { + let g40!: Guard.Guard; + let unwind32: number = 0; + try { + const _324: Guard.Guard | undefined = captured46.pop(); + if (_324 !== undefined) { + unwind32 = 12; + g40 = _324; + captured47(g40); + const _1711: rt.u32 = rt.u32Add(Guard.id(g40), Guard.id(captured48)); + unwind32 = 0; + rt.drop(g40); + return _1711; + } + return undefined; + } catch (e33) { + if (unwind32 === 0) { + throw e33; + } + rt.drop(g40); + throw e33; + } + }, (): void => { + let dropped: number = 0; + try { + rt.dropAll(captured46); + dropped = 1; + rt.drop(captured48); + } catch (e) { + if (dropped < 1) { + rt.drop(captured48); + } + throw e; + } + }))); + const _634: Guard.Guard | undefined = guard(5); + _1146 = false; + const captured49 = trip; + const captured50 = id; + const captured51 = d; + const m8: rt.u32 = rt.iterFold(rt.iterSuccessors(_634, rt.closure((g41: Guard.Guard): Guard.Guard | undefined => { + captured49(g41); + return rt.boolThen(Guard.id(g41) < rt.u32Add(captured50, 7), (): Guard.Guard => { + return Guard.new(rt.u32Sub(rt.u32Add(rt.u32Add(Guard.id(g41), 1), Guard.id(captured51)), Guard.id(captured51)), Log.clone$Clone(log)); + }); + }, (): void => { + rt.drop(captured51); + }), rt.drop), 0, (n33: rt.u32, g42: Guard.Guard): rt.u32 => { + let unwind33: number = 0; + try { + unwind33 = 6; + const _963: rt.u32 = rt.u32Sub(rt.u32Add(n33, Guard.id(g42)), id); + unwind33 = 0; + rt.drop(g42); + return _963; + } catch (e34) { + if (unwind33 === 0) { + throw e34; + } + rt.drop(g42); + throw e34; + } + }, true); + const args46: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(n13, f), (f: rt.Formatter) => rt.u32Display(m8, f)]; + Log.note(log, rt.fmtFormat(["lazy ", args46[0], " ", args46[1]])); + } else if (_24 === 21) { + const _656: rt.Iter = rt.iterSlice(guards(1, 5), rt.drop); + _1147 = false; + const captured43 = trip; + const captured44 = c; + const n14: rt.usize = rt.ownedCount(rt.iterSkip(rt.iterMap(_656, rt.closure((g38: Guard.Guard): rt.u32 => { + let unwind30: number = 0; + try { + unwind30 = 7; + captured43(g38); + const _1124: rt.u32 = rt.u32Add(Guard.id(g38), Guard.id(captured44)); + unwind30 = 0; + rt.drop(g38); + return _1124; + } catch (e31) { + if (unwind30 === 0) { + throw e31; + } + rt.drop(g38); + throw e31; + } + }, (): void => { + rt.drop(captured44); + })), 1)); + const _664: rt.Iter = rt.iterSlice(guards(5, 8), rt.drop); + const captured45 = trip; + const m9: rt.usize = rt.ownedCount(rt.iterTake(rt.iterMap(_664, (g39: Guard.Guard): Guard.Guard => { + let unwind31: number = 0; + try { + unwind31 = 3; + captured45(g39); + return g39; + } catch (e32) { + if (unwind31 === 0) { + throw e32; + } + rt.drop(g39); + throw e32; + } + }), 2, rt.drop), rt.drop); + const args48: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(n14, f), (f: rt.Formatter) => rt.usizeDisplay(m9, f)]; + Log.note(log, rt.fmtFormat(["over ", args48[0], " ", args48[1]])); + } else if (_24 === 22) { + const _684: rt.Iter = rt.iterSlice(guards(1, 5), rt.drop); + _1147 = false; + const captured38 = trip; + const captured39 = c; + const captured40 = id; + const n15: rt.u32 = rt.iterFold(rt.iterRev(rt.iterMap(_684, rt.closure((g36: Guard.Guard): rt.u32 => { + let unwind29: number = 0; + try { + unwind29 = 14; + captured38(g36); + const _1315: rt.u32 = Guard.id(g36); + const _1614: rt.u32 = Guard.id(captured39); + const args92: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_1315, f), (f: rt.Formatter) => rt.u32Display(_1614, f)]; + Log.note(log, rt.fmtFormat(["map ", args92[0], " ", args92[1]])); + const _26: rt.u32 = rt.u32Sub(Guard.id(g36), captured40); + unwind29 = 0; + rt.drop(g36); + return _26; + } catch (e30) { + if (unwind29 === 0) { + throw e30; + } + rt.drop(g36); + throw e30; + } + }, (): void => { + rt.drop(captured39); + }))), 0, (n32: rt.u32, k: rt.u32): rt.u32 => { + return rt.u32Add(rt.u32Mul(n32, 10), k); + }, true); + _693 = rt.iterSlice(guards(5, 6), rt.drop); + unwind = 607; + _1155 = true; + const _697: Guard.Guard[] = guards(6, 8); + _1155 = false; + const _692: rt.Iter = rt.iterChain(_693, rt.iterSlice(_697, rt.drop)); + unwind = 626; + _1155 = false; + _1146 = false; + const captured41 = trip; + const captured42 = d; + const m10: rt.usize = rt.ownedCount(rt.iterRev(rt.iterFilter(_692, rt.closure((g37: Guard.Guard): boolean => { + captured41(g37); + return Guard.id(g37) !== rt.u32Sub(Guard.id(captured42), 5); + }, (): void => { + rt.drop(captured42); + }), rt.drop)), rt.drop); + const args50: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(n15, f), (f: rt.Formatter) => rt.usizeDisplay(m10, f)]; + Log.note(log, rt.fmtFormat(["rev ", args50[0], " ", args50[1]])); + } else if (_24 === 23) { + const _717: rt.Iter = rt.iterSlice(guards(1, 6), rt.drop); + _1147 = false; + const captured34 = trip; + const captured35 = c; + const n16: rt.u32 = rt.iterFold(rt.iterRev(rt.iterTake(rt.iterMap(_717, rt.closure((g33: Guard.Guard): Guard.Guard => { + let unwind26: number = 0; + try { + unwind26 = 11; + captured34(g33); + const _1314: rt.u32 = Guard.id(g33); + const _1613: rt.u32 = Guard.id(captured35); + const args90: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_1314, f), (f: rt.Formatter) => rt.u32Display(_1613, f)]; + Log.note(log, rt.fmtFormat(["map ", args90[0], " ", args90[1]])); + return g33; + } catch (e27) { + if (unwind26 === 0) { + throw e27; + } + rt.drop(g33); + throw e27; + } + }, (): void => { + rt.drop(captured35); + })), 3, rt.drop)), 0, (n31: rt.u32, g34: Guard.Guard): rt.u32 => { + let unwind27: number = 0; + try { + unwind27 = 7; + const _1118: rt.u32 = rt.u32Sub(rt.u32Add(rt.u32Mul(n31, 10), Guard.id(g34)), id); + unwind27 = 0; + rt.drop(g34); + return _1118; + } catch (e28) { + if (unwind27 === 0) { + throw e28; + } + rt.drop(g34); + throw e28; + } + }, true); + const _728: rt.Iter = rt.iterSlice(guards(6, 8), rt.drop); + const captured36 = trip; + const captured37 = id; + const m11: rt.u32 = rt.iterSum(rt.iterRev(rt.iterTake(rt.iterMap(_728, (g35: Guard.Guard): rt.u32 => { + let unwind28: number = 0; + try { + unwind28 = 6; + captured36(g35); + const _1041: rt.u32 = rt.u32Sub(Guard.id(g35), captured37); + unwind28 = 0; + rt.drop(g35); + return _1041; + } catch (e29) { + if (unwind28 === 0) { + throw e29; + } + rt.drop(g35); + throw e29; + } + }), 0)), rt.u32Add, 0, true); + const _739: rt.u32 = Guard.id(d); + const args52: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(n16, f), (f: rt.Formatter) => rt.u32Display(m11, f), (f: rt.Formatter) => rt.u32Display(_739, f)]; + Log.note(log, rt.fmtFormat(["take ", args52[0], " ", args52[1], " ", args52[2]])); + } else if (_24 === 24) { + const _754: rt.Iter = rt.iterSlice(guards(1, 7), rt.drop); + _1147 = false; + const captured30 = trip; + const captured31 = c; + const n17: rt.u32 = rt.iterSum(rt.iterMap(rt.iterRev(rt.iterStepBy(rt.iterMap(_754, rt.closure((g30: Guard.Guard): Guard.Guard => { + let unwind24: number = 0; + try { + unwind24 = 11; + captured30(g30); + const _1313: rt.u32 = Guard.id(g30); + const _1612: rt.u32 = Guard.id(captured31); + const args88: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_1313, f), (f: rt.Formatter) => rt.u32Display(_1612, f)]; + Log.note(log, rt.fmtFormat(["map ", args88[0], " ", args88[1]])); + return g30; + } catch (e25) { + if (unwind24 === 0) { + throw e25; + } + rt.drop(g30); + throw e25; + } + }, (): void => { + rt.drop(captured31); + })), 2, rt.drop)), (g31: Guard.Guard): rt.u32 => { + let unwind25: number = 0; + try { + unwind25 = 5; + const _632: rt.u32 = rt.u32Sub(Guard.id(g31), id); + unwind25 = 0; + rt.drop(g31); + return _632; + } catch (e26) { + if (unwind25 === 0) { + throw e26; + } + rt.drop(g31); + throw e26; + } + }), rt.u32Add, 0, true); + const _764: rt.Iter = rt.iterSlice(guards(7, 8), rt.drop); + _1146 = false; + const captured32 = trip; + const captured33 = d; + const m12: rt.usize = rt.ownedCount(rt.iterStepBy(rt.iterFilter(_764, rt.closure((g32: Guard.Guard): boolean => { + captured32(g32); + return Guard.id(g32) !== Guard.id(captured33); + }, (): void => { + rt.drop(captured33); + }), rt.drop), 3, rt.drop), rt.drop); + const args54: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(n17, f), (f: rt.Formatter) => rt.usizeDisplay(m12, f)]; + Log.note(log, rt.fmtFormat(["step ", args54[0], " ", args54[1]])); + } else if (_24 === 25) { + const _783: rt.Iter = rt.iterSlice(guards(1, 5), rt.drop); + _1147 = false; + const captured27 = trip; + const captured28 = c; + peek2 = rt.iterPeekable(rt.iterMap(_783, rt.closure((g24: Guard.Guard): Guard.Guard => { + let unwind20: number = 0; + try { + unwind20 = 11; + captured27(g24); + const _1312: rt.u32 = Guard.id(g24); + const _1611: rt.u32 = Guard.id(captured28); + const args86: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_1312, f), (f: rt.Formatter) => rt.u32Display(_1611, f)]; + Log.note(log, rt.fmtFormat(["map ", args86[0], " ", args86[1]])); + return g24; + } catch (e21) { + if (unwind20 === 0) { + throw e21; + } + rt.drop(g24); + throw e21; + } + }, (): void => { + rt.drop(captured28); + })), rt.drop); + unwind = 605; + _1154 = true; + const part11 = map$Option_Guard_u32_folded_closure100(rt.peekablePeek(peek2), (g25: Guard.Guard): rt.u32 => { + return Guard.id(g25); + }); + const args56: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part11, f, rt.u32Debug)]; + Log.note(log, rt.fmtFormat(["peek ", args56[0]])); + _1154 = false; + const n18: rt.u32 = rt.iterFold(rt.iterRev(peek2), 0, (n30: rt.u32, g26: Guard.Guard): rt.u32 => { + let unwind21: number = 0; + try { + unwind21 = 7; + const _1115: rt.u32 = rt.u32Sub(rt.u32Add(rt.u32Mul(n30, 10), Guard.id(g26)), id); + unwind21 = 0; + rt.drop(g26); + return _1115; + } catch (e22) { + if (unwind21 === 0) { + throw e22; + } + rt.drop(g26); + throw e22; + } + }, true); + const _808: rt.Iter = rt.iterSlice(guards(5, 6), rt.drop); + const captured29 = trip; + ended = rt.iterPeekable(rt.iterMap(_808, (g27: Guard.Guard): Guard.Guard => { + let unwind22: number = 0; + try { + unwind22 = 3; + captured29(g27); + return g27; + } catch (e23) { + if (unwind22 === 0) { + throw e23; + } + rt.drop(g27); + throw e23; + } + }), rt.drop); + unwind = 603; + _1153 = true; + const part13 = map$Option_Guard_u32_folded_closure100(rt.iterToOption(ended.next()), (g28: Guard.Guard): rt.u32 => { + let unwind23: number = 0; + try { + unwind23 = 4; + const _028: rt.u32 = Guard.id(g28); + unwind23 = 0; + rt.drop(g28); + return _028; + } catch (e24) { + if (unwind23 === 0) { + throw e24; + } + rt.drop(g28); + throw e24; + } + }); + const args58: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part13, f, rt.u32Debug)]; + Log.note(log, rt.fmtFormat(["peek ", args58[0]])); + const part14 = map$Option_Guard_u32_folded_closure100(rt.peekablePeek(ended), (g29: Guard.Guard): rt.u32 => { + return Guard.id(g29); + }); + const args60: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part14, f, rt.u32Debug)]; + Log.note(log, rt.fmtFormat(["peek ", args60[0]])); + _1153 = false; + const _845: rt.usize = rt.ownedCount(rt.iterRev(ended), rt.drop); + const _849: rt.u32 = Guard.id(d); + const args62: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(n18, f), (f: rt.Formatter) => rt.usizeDisplay(_845, f), (f: rt.Formatter) => rt.u32Display(_849, f)]; + Log.note(log, rt.fmtFormat(["peek ", args62[0], " ", args62[1], " ", args62[2]])); + _1153 = false; + _1154 = false; + } else if (_24 === 26) { + const _860: rt.Iter = rt.iterSlice(guards(1, 4), rt.drop); + _1147 = false; + const captured22 = trip; + const captured23 = guard; + const captured24 = c; + const captured25 = id; + flat2 = rt.iterFlatten(rt.iterMap(_860, rt.closure((g19: Guard.Guard): Guard.Guard[] => { + let v2!: Guard.Guard[]; + let _235!: boolean; + let unwind15: number = 0; + try { + unwind15 = 13; + _235 = false; + _235 = true; + captured22(g19); + v2 = []; + unwind15 = 10; + _235 = false; + v2.push(g19); + const _1311: Guard.Guard = captured23(rt.u32Add(rt.u32Sub(Guard.id(captured24), captured25), 1)); + v2.push(_1311); + return v2; + } catch (e16) { + if (unwind15 === 0) { + throw e16; + } + if (unwind15 === 10) { + rt.dropAll(v2); + } + if (_235) { + rt.drop(g19); + } + throw e16; + } + }, (): void => { + rt.drop(captured24); + })), (value: Guard.Guard[]) => rt.iterSlice(value, rt.drop), true); + unwind = 601; + _1152 = true; + const part8 = map$Option_Guard_u32_folded_closure100(rt.iterToOption(flat2.nextBack()), (g20: Guard.Guard): rt.u32 => { + let unwind16: number = 0; + try { + unwind16 = 4; + const _020: rt.u32 = Guard.id(g20); + unwind16 = 0; + rt.drop(g20); + return _020; + } catch (e17) { + if (unwind16 === 0) { + throw e17; + } + rt.drop(g20); + throw e17; + } + }); + const args64: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part8, f, rt.u32Debug)]; + Log.note(log, rt.fmtFormat(["back ", args64[0]])); + _1152 = false; + const n19: rt.u32 = rt.iterFold(rt.iterRev(flat2), 0, (n29: rt.u32, g21: Guard.Guard): rt.u32 => { + let unwind17: number = 0; + try { + unwind17 = 7; + const _1114: rt.u32 = rt.u32Sub(rt.u32Add(rt.u32Mul(n29, 100), Guard.id(g21)), id); + unwind17 = 0; + rt.drop(g21); + return _1114; + } catch (e18) { + if (unwind17 === 0) { + throw e18; + } + rt.drop(g21); + throw e18; + } + }, true); + const _887: rt.Iter = rt.iterSlice(guards(4, 8), rt.drop); + const captured26 = trip; + const _898: [rt.usize, rt.u32] | undefined = map$Option_usize_Guard_usize_u32_folded_closure103(rt.ownedLast(rt.iterRev(rt.iterEnumerate(rt.iterMap(_887, (g22: Guard.Guard): Guard.Guard => { + let unwind18: number = 0; + try { + unwind18 = 3; + captured26(g22); + return g22; + } catch (e19) { + if (unwind18 === 0) { + throw e19; + } + rt.drop(g22); + throw e19; + } + }))), drop$usize_Guard), (_2: [rt.usize, Guard.Guard]): [rt.usize, rt.u32] => { + let g23!: Guard.Guard; + let unwind19: number = 0; + try { + unwind19 = 4; + const i: rt.usize = _2[0]; + g23 = _2[1]; + const _564: rt.u32 = Guard.id(g23); + unwind19 = 0; + rt.drop(g23); + return [i, _564] as [rt.usize, rt.u32]; + } catch (e20) { + if (unwind19 === 0) { + throw e20; + } + rt.drop(g23); + throw e20; + } + }); + const _900: rt.u32 = Guard.id(d); + const args66: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(n19, f), (f: rt.Formatter) => rt.fmtOption(_898, f, (value: [rt.usize, rt.u32], f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.usizeDebug(value[0], f), (f: rt.Formatter) => rt.u32Debug(value[1], f)], f)), (f: rt.Formatter) => rt.u32Display(_900, f)]; + Log.note(log, rt.fmtFormat(["flat ", args66[0], " ", args66[1], " ", args66[2]])); + _1152 = false; + } else if (_24 === 27) { + const _912: rt.Iter = rt.iterSlice(guards(1, 5), rt.drop); + _1147 = false; + const captured18 = trip; + const captured19 = c; + kept2 = rt.iterFold(rt.iterRev(rt.iterFilter(_912, rt.closure((g14: Guard.Guard): boolean => { + captured18(g14); + return Guard.id(g14) !== rt.u32Sub(Guard.id(captured19), 8); + }, (): void => { + rt.drop(captured19); + }), rt.drop)), undefined as Guard.Guard | undefined, (kept3: Guard.Guard | undefined, g15: Guard.Guard): Guard.Guard | undefined => { + let _015!: Guard.Guard | undefined; + let _1112!: boolean; + let unwind11: number = 0; + try { + unwind11 = 9; + _1112 = false; + let _1019: boolean = false; + _1112 = true; + _1019 = true; + if (!(rt.u32Rem(Guard.id(g15), 2) === 0)) { + _1112 = false; + _015 = kept3; + } else { + _1019 = false; + _015 = g15; + } + if (_1019) { + unwind11 = 14; + rt.drop(g15); + } + if (_1112) { + unwind11 = 0; + rt.drop(kept3); + return _015; + } + return _015; + } catch (e12) { + if (unwind11 === 0) { + throw e12; + } + if (unwind11 === 9) { + rt.drop(g15); + } + if (_1112) { + rt.drop(kept3); + } + throw e12; + } + }, true, rt.drop); + unwind = 599; + _1151 = true; + const _922: rt.Iter = rt.iterSlice(guards(5, 8), rt.drop); + _1146 = false; + const captured20 = trip; + const captured21 = d; + const n20: rt.u32 = rt.iterSum(rt.iterMap(rt.iterRev(rt.iterFilterMap(_922, rt.closure((g16: Guard.Guard): Guard.Guard | undefined => { + let _1510!: boolean; + let unwind12: number = 0; + try { + unwind12 = 9; + _1510 = false; + _1510 = true; + captured20(g16); + const _740: boolean = Guard.id(g16) !== rt.u32Sub(Guard.id(captured21), 5); + _1510 = false; + return rt.thenSome(_740, g16, rt.drop); + } catch (e13) { + if (unwind12 === 0) { + throw e13; + } + if (_1510) { + rt.drop(g16); + } + throw e13; + } + }, (): void => { + rt.drop(captured21); + }))), (g17: Guard.Guard): rt.u32 => { + let unwind13: number = 0; + try { + unwind13 = 5; + const _626: rt.u32 = rt.u32Sub(Guard.id(g17), id); + unwind13 = 0; + rt.drop(g17); + return _626; + } catch (e14) { + if (unwind13 === 0) { + throw e14; + } + rt.drop(g17); + throw e14; + } + }), rt.u32Add, 0, true); + _1151 = false; + const _935: rt.u32 | undefined = map$Option_Guard_u32_folded_closure100(kept2, (g18: Guard.Guard): rt.u32 => { + let unwind14: number = 0; + try { + unwind14 = 4; + const _018: rt.u32 = Guard.id(g18); + unwind14 = 0; + rt.drop(g18); + return _018; + } catch (e15) { + if (unwind14 === 0) { + throw e15; + } + rt.drop(g18); + throw e15; + } + }); + const args68: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(_935, f, rt.u32Debug), (f: rt.Formatter) => rt.u32Display(n20, f)]; + Log.note(log, rt.fmtFormat(["rev ", args68[0], " ", args68[1]])); + _1151 = false; + } else if (_24 === 28) { + const _946: rt.Iter = rt.iterSlice(guards(1, 5), rt.drop); + _1147 = false; + const captured15 = trip; + const captured16 = c; + const n21: rt.usize = rt.ownedCount(rt.iterRev(rt.iterInspect(_946, rt.closure((g11: Guard.Guard): void => { + captured15(g11); + const _1210: rt.u32 = Guard.id(g11); + const _149: rt.u32 = Guard.id(captured16); + const args84: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_1210, f), (f: rt.Formatter) => rt.u32Display(_149, f)]; + Log.note(log, rt.fmtFormat(["inspect ", args84[0], " ", args84[1]])); + }, (): void => { + rt.drop(captured16); + }), rt.drop)), rt.drop); + const _956: rt.Iter = rt.iterSlice(guards(5, 8), rt.drop); + const captured17 = trip; + const m14: rt.u32 = rt.iterSum(rt.iterMap(rt.iterRev(rt.iterFuse(rt.iterMap(_956, (g12: Guard.Guard): Guard.Guard => { + let unwind9: number = 0; + try { + unwind9 = 3; + captured17(g12); + return g12; + } catch (e10) { + if (unwind9 === 0) { + throw e10; + } + rt.drop(g12); + throw e10; + } + }), true)), (g13: Guard.Guard): rt.u32 => { + let unwind10: number = 0; + try { + unwind10 = 9; + const _1211: rt.u32 = rt.u32Sub(rt.u32Add(rt.u32Sub(Guard.id(g13), id), Guard.id(d)), Guard.id(d)); + unwind10 = 0; + rt.drop(g13); + return _1211; + } catch (e11) { + if (unwind10 === 0) { + throw e11; + } + rt.drop(g13); + throw e11; + } + }), rt.u32Add, 0, true); + const args70: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(n21, f), (f: rt.Formatter) => rt.u32Display(m14, f)]; + Log.note(log, rt.fmtFormat(["rev ", args70[0], " ", args70[1]])); + } else if (_24 === 29) { + const _980: rt.Iter = rt.iterSlice(guards(1, 4), rt.drop); + const captured12 = trip; + _979 = rt.iterMap(_980, (g8: Guard.Guard): Guard.Guard => { + let unwind7: number = 0; + try { + unwind7 = 3; + captured12(g8); + return g8; + } catch (e8) { + if (unwind7 === 0) { + throw e8; + } + rt.drop(g8); + throw e8; + } + }); + unwind = 597; + _1150 = true; + const _986: rt.Iter = rt.iterSlice(guards(4, 7), rt.drop); + _1146 = false; + const captured13 = trip; + const captured14 = d; + const _985: rt.Iter = rt.iterFilter(_986, rt.closure((g9: Guard.Guard): boolean => { + captured13(g9); + return Guard.id(g9) !== rt.u32Sub(Guard.id(captured14), 6); + }, (): void => { + rt.drop(captured14); + }), rt.drop); + _1150 = false; + const _978: rt.Iter = rt.iterChain(_979, _985); + unwind = 626; + _1150 = false; + const n22: rt.u32 = rt.iterFold(rt.iterRev(_978), 0, (n28: rt.u32, g10: Guard.Guard): rt.u32 => { + let unwind8: number = 0; + try { + unwind8 = 7; + const _1110: rt.u32 = rt.u32Sub(rt.u32Add(rt.u32Mul(n28, 10), Guard.id(g10)), id); + unwind8 = 0; + rt.drop(g10); + return _1110; + } catch (e9) { + if (unwind8 === 0) { + throw e9; + } + rt.drop(g10); + throw e9; + } + }, true); + const _999: rt.u32 = Guard.id(c); + const args72: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(n22, f), (f: rt.Formatter) => rt.u32Display(_999, f)]; + Log.note(log, rt.fmtFormat(["rev ", args72[0], " ", args72[1]])); + } else if (_24 === 30) { + const _1012: rt.Iter = rt.iterSlice(guards(1, 6), rt.drop); + _1147 = false; + const captured8 = trip; + const captured9 = c; + const n23: rt.u32 = rt.iterSum(rt.iterMap(rt.iterRev(rt.iterSkip(rt.iterMap(_1012, rt.closure((g4: Guard.Guard): Guard.Guard => { + let unwind4: number = 0; + try { + unwind4 = 11; + captured8(g4); + const _134: rt.u32 = Guard.id(g4); + const _168: rt.u32 = Guard.id(captured9); + const args82: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_134, f), (f: rt.Formatter) => rt.u32Display(_168, f)]; + Log.note(log, rt.fmtFormat(["map ", args82[0], " ", args82[1]])); + return g4; + } catch (e5) { + if (unwind4 === 0) { + throw e5; + } + rt.drop(g4); + throw e5; + } + }, (): void => { + rt.drop(captured9); + })), 2, rt.drop)), (g5: Guard.Guard): rt.u32 => { + let unwind5: number = 0; + try { + unwind5 = 5; + const _613: rt.u32 = rt.u32Sub(Guard.id(g5), id); + unwind5 = 0; + rt.drop(g5); + return _613; + } catch (e6) { + if (unwind5 === 0) { + throw e6; + } + rt.drop(g5); + throw e6; + } + }), rt.u32Add, 0, true); + const _1022: rt.Iter = rt.iterSlice(guards(6, 8), rt.drop); + _1146 = false; + const captured10 = trip; + const captured11 = d; + const m15: rt.u32 = rt.iterFold(rt.iterSkip(rt.iterFilter(_1022, rt.closure((g6: Guard.Guard): boolean => { + captured10(g6); + return Guard.id(g6) !== Guard.id(captured11); + }, (): void => { + rt.drop(captured11); + }), rt.drop), 1, rt.drop), 0, (n27: rt.u32, g7: Guard.Guard): rt.u32 => { + let unwind6: number = 0; + try { + unwind6 = 6; + const _96: rt.u32 = rt.u32Sub(rt.u32Add(n27, Guard.id(g7)), id); + unwind6 = 0; + rt.drop(g7); + return _96; + } catch (e7) { + if (unwind6 === 0) { + throw e7; + } + rt.drop(g7); + throw e7; + } + }, true); + const args74: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(n23, f), (f: rt.Formatter) => rt.u32Display(m15, f)]; + Log.note(log, rt.fmtFormat(["skip ", args74[0], " ", args74[1]])); + } else { + const _1042: rt.u32 = rt.u32Add(id, 12); + const _1044: Log.Log = Log.clone$Clone(log); + unwind = 595; + const _1045: boolean = at === id; + _1149 = true; + bomb = new Bomb.Bomb({ id: _1042, log: _1044, blows: _1045 }); + const _1049: rt.Iter = rt.iterSlice(guards(1, 4), rt.drop); + _1149 = false; + const captured5 = trip; + const captured6 = bomb; + _1048 = rt.iterMap(_1049, rt.closure((g2: Guard.Guard): rt.u32 => { + let unwind2: number = 0; + try { + unwind2 = 7; + captured5(g2); + const _112: rt.u32 = rt.u32Add(Guard.id(g2), bombId(captured6)); + unwind2 = 0; + rt.drop(g2); + return _112; + } catch (e3) { + if (unwind2 === 0) { + throw e3; + } + rt.drop(g2); + throw e3; + } + }, (): void => { + rt.drop(captured6); + })); + unwind = 593; + _1148 = true; + const _1055: rt.Iter = rt.iterSlice(guards(4, 6), rt.drop); + _1147 = false; + const captured7 = c; + const _1054: rt.Iter = rt.iterMap(_1055, rt.closure((g3: Guard.Guard): rt.u32 => { + let unwind3: number = 0; + try { + unwind3 = 6; + const _713: rt.u32 = rt.u32Add(Guard.id(g3), Guard.id(captured7)); + unwind3 = 0; + rt.drop(g3); + return _713; + } catch (e4) { + if (unwind3 === 0) { + throw e4; + } + rt.drop(g3); + throw e4; + } + }, (): void => { + rt.drop(captured7); + })); + _1148 = false; + const _1047: rt.Iter = rt.iterChain(_1048, _1054); + unwind = 595; + _1148 = false; + const n24: rt.usize = rt.ownedCount(_1047); + const _1066: rt.u32 = Guard.id(d); + const args76: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(n24, f), (f: rt.Formatter) => rt.u32Display(_1066, f)]; + Log.note(log, rt.fmtFormat(["done ", args76[0], " ", args76[1]])); + _1149 = false; + } + if (_1146) { + unwind = 587; + rt.drop(d); + } + _1146 = false; + if (_1147) { + unwind = 0; + rt.drop(c); + } + _1147 = false; + } catch (e2) { + b3: { + b4: { + b5: { + b6: { + b7: { + b8: { + b9: { + b10: { + if (unwind === 0) { + throw e2; + } + if (unwind === 580) { + rt.drop(_302); + break b5; + } + if (unwind === 581) { + rt.btreeDrop(tree2, undefined, rt.drop); + break b6; + } + if (unwind === 582) { + break b6; + } + if (unwind === 583) { + rt.btreeDrop(tree, undefined, rt.drop); + break b7; + } + if (unwind === 584) { + break b7; + } + if (unwind === 585) { + rt.dropAll(wider, drop$Guard_u64); + break b8; + } + if (unwind === 586) { + break b8; + } + if (unwind === 587) { + break b4; + } + if (unwind === 588) { + rt.drop(_18); + break b3; + } + if (unwind === 593) { + if (!_1148) { + break b9; + } + rt.drop(_1048); + break b9; + } + if (unwind === 595) { + break b9; + } + if (unwind === 597) { + if (!_1150) { + break b5; + } + rt.drop(_979); + break b5; + } + if (unwind === 599) { + if (!_1151) { + break b5; + } + rt.drop(kept2); + break b5; + } + if (unwind === 601) { + if (!_1152) { + break b5; + } + rt.drop(flat2); + break b5; + } + if (unwind === 603) { + if (!_1153) { + break b10; + } + rt.drop(ended); + break b10; + } + if (unwind === 605) { + break b10; + } + if (unwind === 607) { + if (!_1155) { + break b5; + } + rt.drop(_693); + break b5; + } + if (unwind === 609) { + if (!_1156) { + break b5; + } + rt.drop(flat); + break b5; + } + if (unwind === 611) { + if (!_1157) { + break b5; + } + rt.drop(peek); + break b5; + } + if (unwind === 613) { + if (!_1158) { + break b5; + } + rt.drop(_377); + break b5; + } + if (unwind === 615) { + if (!_1159) { + break b5; + } + rt.drop(_363); + break b5; + } + if (unwind === 617) { + if (!_1160) { + break b5; + } + rt.drop(_332); + break b5; + } + if (unwind === 619) { + if (_1161) { + rt.drop(f); + } + if (!_1162) { + break b5; + } + rt.drop(e); + break b5; + } + if (unwind === 622) { + if (_1163) { + rt.drop(least); + } + } else if (unwind !== 624) { + break b5; + } + if (!_1164) { + break b5; + } + rt.drop(best); + break b5; + } + if (!_1154) { + break b5; + } + rt.drop(peek2); + break b5; + } + if (!_1149) { + break b5; + } + rt.drop(bomb); + break b5; + } + rt.dropAll(same); + break b5; + } + rt.dequeDrop(queue, rt.drop); + break b5; + } + rt.dropAll(v); + } + if (_1146) { + rt.drop(d); + } + } + if (_1147) { + rt.drop(c); + } + } + throw e2; + } +} + +/** + * Run scenario `arg % 9` of what folds back to front and through what wraps a closure + * beside another, panicking as a closure reads item `arg / 9 % 8`, if any, as `folded` does. + */ +export function rfolded(log: Log.Log, id: rt.u32, arg: rt.u8): void { + let c!: Guard.Guard; + let d!: Guard.Guard; + let e!: Guard.Guard; + let _20!: Guard.Guard; + let _23!: Guard.Guard; + let f!: Guard.Guard; + let f2!: Guard.Guard; + let _186!: rt.Iter<[Guard.Guard, rt.u32]>; + let _215!: rt.Iter<[Guard.Guard, rt.u32]>; + let flat!: rt.Iter; + let _351!: boolean; + let _352!: boolean; + let _353!: boolean; + let _354!: boolean; + let _355!: boolean; + let _356!: boolean; + let _357!: boolean; + let _358!: boolean; + let unwind: number = 0; + try { + _358 = false; + _352 = false; + _351 = false; + _357 = false; + _356 = false; + _355 = false; + _354 = false; + _353 = false; + const _10: rt.u32 = rt.u32Add(id, rt.u8Rem(rt.u8Div(arg, 9), 8) as rt.u32); + unwind = 0; + const at: rt.u32 = _10; + const guard: (a0: rt.u32) => Guard.Guard = (n7: rt.u32): Guard.Guard => { + return Guard.new(rt.u32Add(id, n7), Log.clone$Clone(log)); + }; + const guards: (a0: rt.u32, a1: rt.u32) => Guard.Guard[] = (from: rt.u32, to: rt.u32): Guard.Guard[] => { + return rt.iterToArray(rt.iterMap(new rt.Range(from, to), guard), undefined, rt.drop); + }; + const captured = at; + const captured2 = id; + const trip: (a0: Guard.Guard) => void = (g: Guard.Guard): void => { + if (Guard.id(g) === captured) { + const _102: rt.u32 = rt.u32Sub(Guard.id(g), captured2); + const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(captured2, f), (f: rt.Formatter) => rt.u32Display(_102, f)]; + rt.panicFmt(["d", args24[0], " at ", args24[1]]); + } + }; + _20 = guard(10); + unwind = 181; + _23 = guard(11); + unwind = 180; + const _26: Guard.Guard = guard(12); + unwind = 196; + _358 = true; + c = _20; + _352 = true; + d = _23; + _351 = true; + e = _26; + const _29: rt.u8 = rt.u8Rem(arg, 9); + if (_29 === 0) { + const _35: rt.Iter = rt.iterSlice(guards(1, 5), rt.drop); + _358 = false; + const captured38 = trip; + const captured39 = c; + const _33: rt.Iter = rt.iterRev(rt.iterMap(_35, rt.closure((g28: Guard.Guard): Guard.Guard => { + let unwind25: number = 0; + try { + unwind25 = 11; + captured38(g28); + const _1314: rt.u32 = Guard.id(g28); + const _1613: rt.u32 = Guard.id(captured39); + const args38: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_1314, f), (f: rt.Formatter) => rt.u32Display(_1613, f)]; + Log.note(log, rt.fmtFormat(["map ", args38[0], " ", args38[1]])); + return g28; + } catch (e26) { + if (unwind25 === 0) { + throw e26; + } + rt.drop(g28); + throw e26; + } + }, (): void => { + rt.drop(captured39); + }))); + _352 = false; + const captured40 = id; + const captured41 = d; + const n: rt.u32 = rt.iterSum(rt.iterMap(_33, rt.closure((g29: Guard.Guard): rt.u32 => { + let unwind26: number = 0; + try { + unwind26 = 9; + const _1413: rt.u32 = rt.u32Sub(rt.u32Add(rt.u32Sub(Guard.id(g29), captured40), Guard.id(captured41)), Guard.id(captured41)); + unwind26 = 0; + rt.drop(g29); + return _1413; + } catch (e27) { + if (unwind26 === 0) { + throw e27; + } + rt.drop(g29); + throw e27; + } + }, (): void => { + rt.drop(captured41); + })), rt.u32Add, 0, true); + const _47: rt.u32 = Guard.id(e); + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(n, f), (f: rt.Formatter) => rt.u32Display(_47, f)]; + Log.note(log, rt.fmtFormat(["map ", args2[0], " ", args2[1]])); + } else if (_29 === 1) { + const _59: rt.Iter = rt.iterSlice(guards(1, 5), rt.drop); + _358 = false; + const captured31 = trip; + const captured32 = c; + const _57: rt.Iter = rt.iterRev(rt.iterFilter(_59, rt.closure((g24: Guard.Guard): boolean => { + captured31(g24); + return Guard.id(g24) !== Guard.id(captured32); + }, (): void => { + rt.drop(captured32); + }), rt.drop)); + _352 = false; + const captured33 = id; + const captured34 = d; + const n2: rt.u32 = rt.iterSum(rt.iterMap(_57, rt.closure((g25: Guard.Guard): rt.u32 => { + let unwind22: number = 0; + try { + unwind22 = 9; + const _1412: rt.u32 = rt.u32Sub(rt.u32Add(rt.u32Sub(Guard.id(g25), captured33), Guard.id(captured34)), Guard.id(captured34)); + unwind22 = 0; + rt.drop(g25); + return _1412; + } catch (e23) { + if (unwind22 === 0) { + throw e23; + } + rt.drop(g25); + throw e23; + } + }, (): void => { + rt.drop(captured34); + })), rt.u32Add, 0, true); + f = guard(13); + unwind = 194; + _357 = true; + const _72: rt.Iter = rt.iterSlice(guards(5, 8), rt.drop); + _351 = false; + const captured35 = trip; + const captured36 = e; + const _70: rt.Iter = rt.iterRev(rt.iterFilterMap(_72, rt.closure((g26: Guard.Guard): Guard.Guard | undefined => { + let _1313!: boolean; + let unwind23: number = 0; + try { + unwind23 = 8; + _1313 = false; + _1313 = true; + captured35(g26); + const _722: boolean = Guard.id(g26) !== Guard.id(captured36); + _1313 = false; + return rt.thenSome(_722, g26, rt.drop); + } catch (e24) { + if (unwind23 === 0) { + throw e24; + } + if (_1313) { + rt.drop(g26); + } + throw e24; + } + }, (): void => { + rt.drop(captured36); + }))); + _357 = false; + const captured37 = f; + const m: rt.usize = rt.ownedCount(rt.iterMap(_70, rt.closure((g27: Guard.Guard): rt.u32 => { + let unwind24: number = 0; + try { + unwind24 = 6; + const _723: rt.u32 = rt.u32Add(Guard.id(g27), Guard.id(captured37)); + unwind24 = 0; + rt.drop(g27); + return _723; + } catch (e25) { + if (unwind24 === 0) { + throw e25; + } + rt.drop(g27); + throw e25; + } + }, (): void => { + rt.drop(captured37); + }))); + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(n2, f), (f: rt.Formatter) => rt.usizeDisplay(m, f)]; + Log.note(log, rt.fmtFormat(["filter ", args4[0], " ", args4[1]])); + _357 = false; + } else if (_29 === 2) { + const _93: rt.Iter = rt.iterSlice(guards(1, 4), rt.drop); + _358 = false; + const captured25 = trip; + const captured26 = c; + const _92: rt.Iter = rt.iterInspect(_93, rt.closure((g20: Guard.Guard): void => { + captured25(g20); + const _1213: rt.u32 = Guard.id(g20); + const _1410: rt.u32 = Guard.id(captured26); + const args34: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_1213, f), (f: rt.Formatter) => rt.u32Display(_1410, f)]; + Log.note(log, rt.fmtFormat(["inspect ", args34[0], " ", args34[1]])); + }, (): void => { + rt.drop(captured26); + }), rt.drop); + _352 = false; + const captured27 = d; + const n3: rt.usize = rt.ownedCount(rt.iterMap(_92, rt.closure((g21: Guard.Guard): rt.u32 => { + let unwind20: number = 0; + try { + unwind20 = 6; + const _717: rt.u32 = rt.u32Add(Guard.id(g21), Guard.id(captured27)); + unwind20 = 0; + rt.drop(g21); + return _717; + } catch (e21) { + if (unwind20 === 0) { + throw e21; + } + rt.drop(g21); + throw e21; + } + }, (): void => { + rt.drop(captured27); + }))); + f2 = guard(13); + unwind = 192; + _356 = true; + const _106: rt.Iter = rt.iterSlice(guards(4, 8), rt.drop); + _351 = false; + const captured28 = trip; + const captured29 = e; + const _104: rt.Iter = rt.iterRev(rt.iterInspect(_106, rt.closure((g22: Guard.Guard): void => { + captured28(g22); + const _1214: rt.u32 = Guard.id(g22); + const _1411: rt.u32 = Guard.id(captured29); + const args36: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_1214, f), (f: rt.Formatter) => rt.u32Display(_1411, f)]; + Log.note(log, rt.fmtFormat(["inspect ", args36[0], " ", args36[1]])); + }, (): void => { + rt.drop(captured29); + }), rt.drop)); + _356 = false; + const captured30 = f2; + const m2: rt.usize = rt.ownedCount(rt.iterMap(_104, rt.closure((g23: Guard.Guard): rt.u32 => { + let unwind21: number = 0; + try { + unwind21 = 6; + const _719: rt.u32 = rt.u32Add(Guard.id(g23), Guard.id(captured30)); + unwind21 = 0; + rt.drop(g23); + return _719; + } catch (e22) { + if (unwind21 === 0) { + throw e22; + } + rt.drop(g23); + throw e22; + } + }, (): void => { + rt.drop(captured30); + }))); + const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(n3, f), (f: rt.Formatter) => rt.usizeDisplay(m2, f)]; + Log.note(log, rt.fmtFormat(["inspect ", args6[0], " ", args6[1]])); + _356 = false; + } else if (_29 === 3) { + const _128: rt.Iter = rt.iterSlice(guards(1, 5), rt.drop); + _358 = false; + const captured23 = trip; + const captured24 = c; + const _139: [rt.usize, rt.u32] | undefined = map$Option_usize_Guard_usize_u32_folded_closure103(rt.ownedLast(rt.iterRev(rt.iterEnumerate(rt.iterMap(_128, rt.closure((g18: Guard.Guard): Guard.Guard => { + let unwind18: number = 0; + try { + unwind18 = 11; + captured23(g18); + const _1312: rt.u32 = Guard.id(g18); + const _1612: rt.u32 = Guard.id(captured24); + const args32: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_1312, f), (f: rt.Formatter) => rt.u32Display(_1612, f)]; + Log.note(log, rt.fmtFormat(["map ", args32[0], " ", args32[1]])); + return g18; + } catch (e19) { + if (unwind18 === 0) { + throw e19; + } + rt.drop(g18); + throw e19; + } + }, (): void => { + rt.drop(captured24); + })))), drop$usize_Guard), (_2: [rt.usize, Guard.Guard]): [rt.usize, rt.u32] => { + let g19!: Guard.Guard; + let unwind19: number = 0; + try { + unwind19 = 4; + const i: rt.usize = _2[0]; + g19 = _2[1]; + const _522: rt.u32 = Guard.id(g19); + unwind19 = 0; + rt.drop(g19); + return [i, _522] as [rt.usize, rt.u32]; + } catch (e20) { + if (unwind19 === 0) { + throw e20; + } + rt.drop(g19); + throw e20; + } + }); + const _141: rt.u32 = Guard.id(d); + const _144: rt.u32 = Guard.id(e); + const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(_139, f, (value: [rt.usize, rt.u32], f: rt.Formatter) => rt.fmtTuple([(f: rt.Formatter) => rt.usizeDebug(value[0], f), (f: rt.Formatter) => rt.u32Debug(value[1], f)], f)), (f: rt.Formatter) => rt.u32Display(_141, f), (f: rt.Formatter) => rt.u32Display(_144, f)]; + Log.note(log, rt.fmtFormat(["enumerate ", args8[0], " ", args8[1], " ", args8[2]])); + } else if (_29 === 4) { + const _156: rt.Iter = rt.iterSlice(guards(1, 5), rt.drop); + _358 = false; + const captured19 = trip; + const captured20 = c; + const n4: rt.usize = rt.ownedCount(rt.iterRev(rt.iterRev(rt.iterMap(_156, rt.closure((g16: Guard.Guard): rt.u32 => { + let unwind16: number = 0; + try { + unwind16 = 7; + captured19(g16); + const _1114: rt.u32 = rt.u32Add(Guard.id(g16), Guard.id(captured20)); + unwind16 = 0; + rt.drop(g16); + return _1114; + } catch (e17) { + if (unwind16 === 0) { + throw e17; + } + rt.drop(g16); + throw e17; + } + }, (): void => { + rt.drop(captured20); + }))))); + const _164: rt.Iter = rt.iterSlice(guards(5, 8), rt.drop); + _352 = false; + const captured21 = trip; + const captured22 = d; + const m3: rt.u32 = rt.iterFold(rt.iterSkip(rt.iterMap(_164, rt.closure((g17: Guard.Guard): rt.u32 => { + let unwind17: number = 0; + try { + unwind17 = 7; + captured21(g17); + const _1115: rt.u32 = rt.u32Add(Guard.id(g17), Guard.id(captured22)); + unwind17 = 0; + rt.drop(g17); + return _1115; + } catch (e18) { + if (unwind17 === 0) { + throw e18; + } + rt.drop(g17); + throw e18; + } + }, (): void => { + rt.drop(captured22); + })), 1), 0, (n8: rt.u32, k: rt.u32): rt.u32 => { + return rt.u32Add(n8, k); + }, true); + const _175: rt.u32 = Guard.id(e); + const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(n4, f), (f: rt.Formatter) => rt.u32Display(m3, f), (f: rt.Formatter) => rt.u32Display(_175, f)]; + Log.note(log, rt.fmtFormat(["twice ", args10[0], " ", args10[1], " ", args10[2]])); + } else if (_29 === 5) { + const _189: rt.Iter = rt.iterSlice(guards(1, 5), rt.drop); + _358 = false; + const captured16 = trip; + const captured17 = c; + const _187: rt.Iter = rt.iterStepBy(rt.iterMap(_189, rt.closure((g12: Guard.Guard): Guard.Guard => { + let unwind12: number = 0; + try { + unwind12 = 11; + captured16(g12); + const _1311: rt.u32 = Guard.id(g12); + const _1611: rt.u32 = Guard.id(captured17); + const args30: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_1311, f), (f: rt.Formatter) => rt.u32Display(_1611, f)]; + Log.note(log, rt.fmtFormat(["map ", args30[0], " ", args30[1]])); + return g12; + } catch (e13) { + if (unwind12 === 0) { + throw e13; + } + rt.drop(g12); + throw e13; + } + }, (): void => { + rt.drop(captured17); + })), 2, rt.drop); + _352 = false; + const captured18 = d; + _186 = rt.iterMap(_187, rt.closure((g13: Guard.Guard): [Guard.Guard, rt.u32] => { + let _318!: Guard.Guard; + let unwind13: number = 0; + try { + unwind13 = 3; + _318 = g13; + return [_318, Guard.id(captured18)] as [Guard.Guard, rt.u32]; + } catch (e14) { + if (unwind13 === 0) { + throw e14; + } + rt.drop(_318); + throw e14; + } + }, (): void => { + rt.drop(captured18); + })); + unwind = 190; + _355 = true; + const _195: Guard.Guard | undefined = guard(20); + _355 = false; + const kept: Guard.Guard | undefined = rt.iterFold(_186, _195, (kept4: Guard.Guard | undefined, _319: [Guard.Guard, rt.u32]): Guard.Guard | undefined => { + let _015!: Guard.Guard | undefined; + let g14!: Guard.Guard; + let _1212!: boolean; + let unwind14: number = 0; + try { + unwind14 = 9; + _1212 = false; + let _1113: boolean = false; + _1212 = true; + _1113 = true; + g14 = _319[0]; + if (!(rt.u32Rem(Guard.id(g14), 2) === 1)) { + _1212 = false; + _015 = kept4; + } else { + _1113 = false; + _015 = g14; + } + if (_1113) { + unwind14 = 14; + rt.drop(g14); + } + _1113 = false; + if (_1212) { + unwind14 = 0; + rt.drop(kept4); + return _015; + } + return _015; + } catch (e15) { + if (unwind14 === 0) { + throw e15; + } + if (unwind14 === 9) { + rt.drop(g14); + } + if (_1212) { + rt.drop(kept4); + } + throw e15; + } + }, true, rt.drop); + unwind = 196; + _355 = false; + const _205: rt.u32 | undefined = map$Option_Guard_u32_folded_closure100(kept, (g15: Guard.Guard): rt.u32 => { + let unwind15: number = 0; + try { + unwind15 = 4; + const _016: rt.u32 = Guard.id(g15); + unwind15 = 0; + rt.drop(g15); + return _016; + } catch (e16) { + if (unwind15 === 0) { + throw e16; + } + rt.drop(g15); + throw e16; + } + }); + const _207: rt.u32 = Guard.id(e); + const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(_205, f, rt.u32Debug), (f: rt.Formatter) => rt.u32Display(_207, f)]; + Log.note(log, rt.fmtFormat(["step ", args12[0], " ", args12[1]])); + } else if (_29 === 6) { + const _219: rt.Iter = rt.iterSlice(guards(1, 6), rt.drop); + _358 = false; + const captured13 = trip; + const captured14 = c; + const _216: rt.Iter = rt.iterRev(rt.iterStepBy(rt.iterMap(_219, rt.closure((g8: Guard.Guard): Guard.Guard => { + let unwind8: number = 0; + try { + unwind8 = 11; + captured13(g8); + const _1310: rt.u32 = Guard.id(g8); + const _1610: rt.u32 = Guard.id(captured14); + const args28: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_1310, f), (f: rt.Formatter) => rt.u32Display(_1610, f)]; + Log.note(log, rt.fmtFormat(["map ", args28[0], " ", args28[1]])); + return g8; + } catch (e9) { + if (unwind8 === 0) { + throw e9; + } + rt.drop(g8); + throw e9; + } + }, (): void => { + rt.drop(captured14); + })), 2, rt.drop)); + _352 = false; + const captured15 = d; + _215 = rt.iterMap(_216, rt.closure((g9: Guard.Guard): [Guard.Guard, rt.u32] => { + let _310!: Guard.Guard; + let unwind9: number = 0; + try { + unwind9 = 3; + _310 = g9; + return [_310, Guard.id(captured15)] as [Guard.Guard, rt.u32]; + } catch (e10) { + if (unwind9 === 0) { + throw e10; + } + rt.drop(_310); + throw e10; + } + }, (): void => { + rt.drop(captured15); + })); + unwind = 188; + _354 = true; + const _225: Guard.Guard | undefined = guard(20); + _354 = false; + const kept2: Guard.Guard | undefined = rt.iterFold(_215, _225, (kept3: Guard.Guard | undefined, _314: [Guard.Guard, rt.u32]): Guard.Guard | undefined => { + let _011!: Guard.Guard | undefined; + let g10!: Guard.Guard; + let _1211!: boolean; + let unwind10: number = 0; + try { + unwind10 = 9; + _1211 = false; + let _1112: boolean = false; + _1211 = true; + _1112 = true; + g10 = _314[0]; + if (!(rt.u32Rem(Guard.id(g10), 2) === 1)) { + _1211 = false; + _011 = kept3; + } else { + _1112 = false; + _011 = g10; + } + if (_1112) { + unwind10 = 14; + rt.drop(g10); + } + _1112 = false; + if (_1211) { + unwind10 = 0; + rt.drop(kept3); + return _011; + } + return _011; + } catch (e11) { + if (unwind10 === 0) { + throw e11; + } + if (unwind10 === 9) { + rt.drop(g10); + } + if (_1211) { + rt.drop(kept3); + } + throw e11; + } + }, true, rt.drop); + unwind = 196; + _354 = false; + const _235: rt.u32 | undefined = map$Option_Guard_u32_folded_closure100(kept2, (g11: Guard.Guard): rt.u32 => { + let unwind11: number = 0; + try { + unwind11 = 4; + const _012: rt.u32 = Guard.id(g11); + unwind11 = 0; + rt.drop(g11); + return _012; + } catch (e12) { + if (unwind11 === 0) { + throw e12; + } + rt.drop(g11); + throw e12; + } + }); + const _237: rt.u32 = Guard.id(e); + const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(_235, f, rt.u32Debug), (f: rt.Formatter) => rt.u32Display(_237, f)]; + Log.note(log, rt.fmtFormat(["step ", args14[0], " ", args14[1]])); + } else if (_29 === 7) { + const _247: rt.Iter = rt.iterSlice(guards(1, 5), rt.drop); + _358 = false; + const captured8 = trip; + const captured9 = id; + const captured10 = c; + const n5: rt.u32 = rt.iterSum(rt.iterFuse(rt.iterMap(_247, rt.closure((g6: Guard.Guard): rt.u32 => { + let unwind6: number = 0; + try { + unwind6 = 10; + captured8(g6); + const _184: rt.u32 = rt.u32Sub(rt.u32Add(rt.u32Sub(Guard.id(g6), captured9), Guard.id(captured10)), Guard.id(captured10)); + unwind6 = 0; + rt.drop(g6); + return _184; + } catch (e7) { + if (unwind6 === 0) { + throw e7; + } + rt.drop(g6); + throw e7; + } + }, (): void => { + rt.drop(captured10); + })), true), rt.u32Add, 0, true); + const _256: rt.Iter = rt.iterSlice(guards(5, 8), rt.drop); + _352 = false; + const captured11 = trip; + const captured12 = d; + const m4: rt.usize = rt.ownedCount(rt.iterRev(rt.iterFuse(rt.iterMap(_256, rt.closure((g7: Guard.Guard): rt.u32 => { + let unwind7: number = 0; + try { + unwind7 = 7; + captured11(g7); + const _1111: rt.u32 = rt.u32Add(Guard.id(g7), Guard.id(captured12)); + unwind7 = 0; + rt.drop(g7); + return _1111; + } catch (e8) { + if (unwind7 === 0) { + throw e8; + } + rt.drop(g7); + throw e8; + } + }, (): void => { + rt.drop(captured12); + })), true))); + const _267: rt.u32 = Guard.id(e); + const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(n5, f), (f: rt.Formatter) => rt.usizeDisplay(m4, f), (f: rt.Formatter) => rt.u32Display(_267, f)]; + Log.note(log, rt.fmtFormat(["fuse ", args16[0], " ", args16[1], " ", args16[2]])); + } else { + const _279: rt.Iter = rt.iterSlice(guards(1, 4), rt.drop); + _358 = false; + const captured3 = c; + const captured4 = guard; + const captured5 = id; + flat = rt.iterFlatten(rt.iterMap(_279, rt.closure((g2: Guard.Guard): Guard.Guard[] => { + let v!: Guard.Guard[]; + let _382!: boolean; + let unwind2: number = 0; + try { + unwind2 = 20; + _382 = false; + _382 = true; + const _95: rt.u32 = Guard.id(g2); + const _124: rt.u32 = Guard.id(captured3); + const args26: rt.Fmt[] = [(f: rt.Formatter) => rt.u32Display(_95, f), (f: rt.Formatter) => rt.u32Display(_124, f)]; + Log.note(log, rt.fmtFormat(["map ", args26[0], " ", args26[1]])); + v = []; + unwind2 = 17; + const _227: Guard.Guard = captured4(rt.u32Add(rt.u32Sub(Guard.id(g2), captured5), 3)); + v.push(_227); + _382 = false; + v.push(g2); + return v; + } catch (e3) { + if (unwind2 === 0) { + throw e3; + } + if (unwind2 === 17) { + rt.dropAll(v); + } + if (_382) { + rt.drop(g2); + } + throw e3; + } + }, (): void => { + rt.drop(captured3); + })), (value: Guard.Guard[]) => rt.iterSlice(value, rt.drop), true); + unwind = 186; + _353 = true; + const part2 = map$Option_Guard_u32_folded_closure100(rt.iterToOption(flat.next()), (g3: Guard.Guard): rt.u32 => { + let unwind3: number = 0; + try { + unwind3 = 4; + const _04: rt.u32 = Guard.id(g3); + unwind3 = 0; + rt.drop(g3); + return _04; + } catch (e4) { + if (unwind3 === 0) { + throw e4; + } + rt.drop(g3); + throw e4; + } + }); + const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part2, f, rt.u32Debug)]; + Log.note(log, rt.fmtFormat(["ends ", args18[0]])); + const part3 = map$Option_Guard_u32_folded_closure100(rt.iterToOption(flat.nextBack()), (g4: Guard.Guard): rt.u32 => { + let unwind4: number = 0; + try { + unwind4 = 4; + const _05: rt.u32 = Guard.id(g4); + unwind4 = 0; + rt.drop(g4); + return _05; + } catch (e5) { + if (unwind4 === 0) { + throw e5; + } + rt.drop(g4); + throw e5; + } + }); + const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtOption(part3, f, rt.u32Debug)]; + Log.note(log, rt.fmtFormat(["ends ", args20[0]])); + _353 = false; + const _312: rt.Iter = flat; + _352 = false; + const captured6 = trip; + const captured7 = d; + const n6: rt.usize = rt.ownedCount(rt.iterMap(_312, rt.closure((g5: Guard.Guard): rt.u32 => { + let unwind5: number = 0; + try { + unwind5 = 7; + captured6(g5); + const _118: rt.u32 = rt.u32Add(Guard.id(g5), Guard.id(captured7)); + unwind5 = 0; + rt.drop(g5); + return _118; + } catch (e6) { + if (unwind5 === 0) { + throw e6; + } + rt.drop(g5); + throw e6; + } + }, (): void => { + rt.drop(captured7); + }))); + const _320: rt.u32 = Guard.id(e); + const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(n6, f), (f: rt.Formatter) => rt.u32Display(_320, f)]; + Log.note(log, rt.fmtFormat(["flat ", args22[0], " ", args22[1]])); + _353 = false; + } + if (_351) { + unwind = 178; + rt.drop(e); + } + _351 = false; + if (_352) { + unwind = 179; + rt.drop(d); + } + _352 = false; + _358 = false; + } catch (e2) { + b3: { + b4: { + b5: { + b6: { + if (unwind === 0) { + throw e2; + } + if (unwind === 178) { + break b5; + } + if (unwind === 179) { + break b4; + } + if (unwind === 180) { + rt.drop(_23); + break b6; + } + if (unwind === 181) { + break b6; + } + if (unwind === 186) { + if (_353) { + rt.drop(flat); + } + } else if (unwind === 188) { + if (_354) { + rt.drop(_215); + } + } else if (unwind === 190) { + if (_355) { + rt.drop(_186); + } + } else if (unwind === 192) { + if (_356) { + rt.drop(f2); + } + } else if (unwind === 194) { + if (_357) { + rt.drop(f); + } + } + if (!_351) { + break b5; + } + rt.drop(e); + break b5; + } + rt.drop(_20); + break b3; + } + if (_352) { + rt.drop(d); + } + } + if (_358) { + rt.drop(c); + } + } + throw e2; + } +} + +//# sourceMappingURL=folds.ts.map diff --git a/ts/fixtures/task/expected/drops/iters.ts b/ts/fixtures/task/expected/drops/iters.ts index 90a91b843..daeeb78f1 100644 --- a/ts/fixtures/task/expected/drops/iters.ts +++ b/ts/fixtures/task/expected/drops/iters.ts @@ -179,7 +179,7 @@ export function looped(log: Log.Log, id: rt.u32, at: rt.u8): void { check(2); } return rt.u32Rem(Guard.id(g4), 2) === 0; - }, rt.drop), true, rt.drop, rt.drop); + }, rt.drop), "place", rt.drop); unwind = 327; const part3 = even.length; const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(part3, f)]; @@ -220,7 +220,7 @@ export function looped(log: Log.Log, id: rt.u32, at: rt.u8): void { Log.note(log, rt.fmtFormat(["next ", args8[0]])); check(3); _610 = false; - const part5 = rt.ownedCount(rest, rt.drop, rt.drop); + const part5 = rt.ownedCount(rest, rt.drop); const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(part5, f)]; Log.note(log, rt.fmtFormat(["count ", args10[0]])); v4 = []; @@ -270,7 +270,7 @@ export function looped(log: Log.Log, id: rt.u32, at: rt.u8): void { const pairs: rt.Iter<[Guard.Guard, Guard.Guard]> = rt.iterZip(_237, rt.iterSlice(_255, rt.drop), false, rt.drop, rt.drop); unwind = 323; _608 = false; - const part6 = rt.ownedCount(pairs, rt.drop, drop$Guard_Guard); + const part6 = rt.ownedCount(pairs, drop$Guard_Guard); const args14: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(part6, f)]; Log.note(log, rt.fmtFormat(["zip ", args14[0]])); v7 = []; @@ -330,7 +330,7 @@ export function looped(log: Log.Log, id: rt.u32, at: rt.u8): void { unwind = 348; best = rt.iterMaxByKey(rt.iterSlice(v9, rt.drop), (g9: Guard.Guard): rt.u32 => { return rt.u32Rem(Guard.id(g9), 2); - }, rt.drop, rt.drop); + }, true, rt.drop); unwind = 346; _605 = true; v10 = []; @@ -398,7 +398,7 @@ export function looped(log: Log.Log, id: rt.u32, at: rt.u8): void { rt.drop(g12); throw e5; } - }, rt.drop); + }, true); v12 = []; unwind = 312; const _408: Guard.Guard = guard(36); @@ -408,7 +408,7 @@ export function looped(log: Log.Log, id: rt.u32, at: rt.u8): void { const _418: Guard.Guard = guard(38); v12.push(_418); unwind = 314; - const _427: rt.u32 = mapOr$Option_Guard_u32_drained_closure4(rt.ownedLast(rt.iterStepBy(rt.iterSlice(v12, rt.drop), 2, rt.drop), rt.drop, rt.drop), 0, (g13: Guard.Guard): rt.u32 => { + const _427: rt.u32 = mapOr$Option_Guard_u32_drained_closure4(rt.ownedLast(rt.iterStepBy(rt.iterSlice(v12, rt.drop), 2, rt.drop), rt.drop), 0, (g13: Guard.Guard): rt.u32 => { let unwind6: number = 0; try { unwind6 = 4; @@ -616,7 +616,7 @@ export function looped(log: Log.Log, id: rt.u32, at: rt.u8): void { }); unwind = 344; rt.drop(_539); - const counted: rt.usize = rt.ownedCount(rt.iterTake(rt.iterRev(rt.iterSlice(five(74), rt.drop)), 3, rt.drop), rt.drop, rt.drop); + const counted: rt.usize = rt.ownedCount(rt.iterTake(rt.iterRev(rt.iterSlice(five(74), rt.drop)), 3, rt.drop), rt.drop); const far: boolean = rt.iterNthBack(rt.iterStepBy(new rt.Range(0, 10), 4294967295), 4294967295) === undefined; const args24: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtBool(skipped, f), (f: rt.Formatter) => rt.u32Display(stepped, f), (f: rt.Formatter) => rt.u32Display(taken, f), (f: rt.Formatter) => rt.u32Display(passed, f), (f: rt.Formatter) => rt.u32Display(strode, f), (f: rt.Formatter) => rt.usizeDisplay(counted, f), (f: rt.Formatter) => rt.fmtBool(far, f)]; Log.note(log, rt.fmtFormat(["back ", args24[0], " ", args24[1], " ", args24[2], " ", args24[3], " ", args24[4], " ", args24[5], " ", args24[6]])); @@ -949,7 +949,7 @@ export function collected(log: Log.Log, id: rt.u32, at: rt.u8): void { rt.drop(g); throw e2; } - }), true, rt.drop, rt.drop); + }), "place", rt.drop); unwind = 164; v2 = []; unwind = 163; @@ -975,7 +975,7 @@ export function collected(log: Log.Log, id: rt.u32, at: rt.u8): void { rt.drop(g2); throw e3; } - }), false, rt.drop, drop$Guard_u32); + }), "fold", drop$Guard_u32); unwind = 162; v3 = []; unwind = 161; @@ -1013,7 +1013,7 @@ export function collected(log: Log.Log, id: rt.u32, at: rt.u8): void { rt.drop(g3); throw e4; } - }), false, rt.drop, rt.drop); + }), "fold", rt.drop); unwind = 159; const _89: rt.usize = same.length; const _92: rt.usize = wider.length; @@ -1044,7 +1044,7 @@ export function collected(log: Log.Log, id: rt.u32, at: rt.u8): void { rt.drop(g4); throw e5; } - }), (values: rt.Iter) => rt.iterToArray(values, true, rt.drop, rt.drop), drop$Vec_Guard, rt.drop); + }), (values: rt.Iter) => rt.iterToArray(values, "place", rt.drop), drop$Vec_Guard, rt.drop); unwind = 168; _320 = true; const part = results.ok; @@ -1077,7 +1077,7 @@ export function collected(log: Log.Log, id: rt.u32, at: rt.u8): void { rt.drop(g5); throw e6; } - }), (values: rt.Iter) => rt.iterToArray(values, true, rt.drop, rt.drop), drop$Vec_Guard), 0, (v12: Guard.Guard[]): rt.usize => { + }), (values: rt.Iter) => rt.iterToArray(values, "place", rt.drop), drop$Vec_Guard), 0, (v12: Guard.Guard[]): rt.usize => { let unwind7: number = 0; try { unwind7 = 4; @@ -1105,7 +1105,7 @@ export function collected(log: Log.Log, id: rt.u32, at: rt.u8): void { v7.push(_191); unwind = 168; const _174: rt.Iter<[rt.u32, Guard.Guard]> = rt.iterSlice(v7, drop$u32_Guard); - tree = rt.btreeCollect(rt.btreeNew(rt.cmp) as rt.BTreeMap, rt.iterToArray(_174, true, rt.drop, drop$u32_Guard), undefined, rt.drop); + tree = rt.btreeCollect(rt.btreeNew(rt.cmp) as rt.BTreeMap, rt.iterToArray(_174, "place", drop$u32_Guard), undefined, rt.drop); unwind = 155; const part3 = rt.btreeLen(tree); const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(part3, f)]; @@ -1135,7 +1135,7 @@ export function collected(log: Log.Log, id: rt.u32, at: rt.u8): void { rt.drop(g6); throw e8; } - }), true, rt.drop); + }), "place"); unwind = 153; const part4 = refs.length; const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(part4, f)]; @@ -1164,7 +1164,7 @@ export function collected(log: Log.Log, id: rt.u32, at: rt.u8): void { throw e9; } }); - queue = rt.dequeExtend(rt.dequeNew() as rt.VecDeque, rt.iterSlice(rt.iterToArray(_239, true, rt.drop, rt.drop))); + queue = rt.dequeExtend(rt.dequeNew() as rt.VecDeque, rt.iterSlice(rt.iterToArray(_239, "place", rt.drop))); unwind = 151; v10 = []; unwind = 150; @@ -1190,7 +1190,7 @@ export function collected(log: Log.Log, id: rt.u32, at: rt.u8): void { throw e11; } }); - hashed = rt.hashExtend(rt.hashNew() as rt.HashMap, _257, undefined, rt.drop, rt.drop, true); + hashed = rt.hashExtend(rt.hashNew() as rt.HashMap, _257, undefined, rt.drop, "fold", true); unwind = 149; v11 = []; unwind = 148; @@ -1200,7 +1200,7 @@ export function collected(log: Log.Log, id: rt.u32, at: rt.u8): void { v11.push(_287); unwind = 149; const _277: rt.Iter = rt.iterSlice(v11, rt.drop); - set = rt.hashExtendKeys(rt.hashNew(rt.hashing(Key.hash$Hash_DefaultHasher, Key.eq$PartialEq)) as rt.HashSet, _277, rt.drop, rt.drop, true); + set = rt.hashExtendKeys(rt.hashNew(rt.hashing(Key.hash$Hash_DefaultHasher, Key.eq$PartialEq)) as rt.HashSet, _277, rt.drop, "fold", true); unwind = 147; const _296: rt.usize = queue.n; const _299: rt.usize = rt.hashLen(hashed); @@ -1461,7 +1461,7 @@ export function drained(log: Log.Log, id: rt.u32, at: rt.u8): void { rt.drop(it); _300 = false; drop$Option_Key_Guard(back); - keys = rt.iterToArray(rt.btreeKeys(tree(5), rt.drop, rt.drop, true), false, rt.drop, rt.drop); + keys = rt.iterToArray(rt.btreeKeys(tree(5), rt.drop, rt.drop, true), "fold", rt.drop); unwind = 159; check(2); values = rt.btreeValues(tree(9), rt.drop, rt.drop); @@ -1641,7 +1641,7 @@ export function drained(log: Log.Log, id: rt.u32, at: rt.u8): void { _290 = true; check(7); _291 = false; - const _249: rt.usize = rt.ownedCount(values2, rt.drop, rt.drop); + const _249: rt.usize = rt.ownedCount(values2, rt.drop); const _252: boolean = one !== undefined; const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(_249, f), (f: rt.Formatter) => rt.fmtBool(_252, f)]; Log.note(log, rt.fmtFormat(["rest ", args16[0], " ", args16[1]])); @@ -1910,7 +1910,7 @@ export function extended(log: Log.Log, id: rt.u32, at: rt.u8): void { throw e2; } }); - rt.iterExtend(list, _20, rt.drop); + rt.iterExtend(list, _20, "fold"); v3 = []; unwind = 134; const _50: Guard.Guard = guard(5); @@ -1926,7 +1926,7 @@ export function extended(log: Log.Log, id: rt.u32, at: rt.u8): void { } return Guard.id(g2) !== rt.u32Add(id, 5); }, rt.drop); - rt.iterExtend(list, _44, rt.drop); + rt.iterExtend(list, _44, "next"); const part = list.length; const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(part, f)]; Log.note(log, rt.fmtFormat(["list ", args2[0]])); @@ -1971,7 +1971,7 @@ export function extended(log: Log.Log, id: rt.u32, at: rt.u8): void { throw e4; } }); - rt.hashExtend(map, _89, rt.drop, rt.drop, rt.drop); + rt.hashExtend(map, _89, rt.drop, rt.drop, "fold"); set = rt.hashNew(rt.hashing(Key.hash$Hash_DefaultHasher, Key.eq$PartialEq)) as rt.HashSet; unwind = 129; const _117: Key.Key = key(11); @@ -1983,7 +1983,7 @@ export function extended(log: Log.Log, id: rt.u32, at: rt.u8): void { const _131: Key.Key = key(11); v5.push(_131); unwind = 129; - rt.hashExtendKeys(set, rt.iterSlice(v5, rt.drop), rt.drop, rt.drop); + rt.hashExtendKeys(set, rt.iterSlice(v5, rt.drop), rt.drop, "fold"); const _140: rt.usize = rt.hashLen(map); const _143: rt.usize = rt.hashLen(set); const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.usizeDisplay(_140, f), (f: rt.Formatter) => rt.usizeDisplay(_143, f)]; @@ -2034,7 +2034,7 @@ export function extended(log: Log.Log, id: rt.u32, at: rt.u8): void { throw e6; } }); - rt.btreeExtend(tree, _161, false, rt.drop, rt.drop, rt.drop); + rt.btreeExtend(tree, _161, false, rt.drop, rt.drop, "fold"); check(5); ordered = rt.btreeNew(Key.cmp$Ord) as rt.BTreeSet; unwind = 122; @@ -2047,7 +2047,7 @@ export function extended(log: Log.Log, id: rt.u32, at: rt.u8): void { const _215: Key.Key = key(16); v7.push(_215); unwind = 122; - rt.btreeExtendKeys(ordered, rt.iterSlice(v7, rt.drop), false, rt.drop, rt.drop); + rt.btreeExtendKeys(ordered, rt.iterSlice(v7, rt.drop), false, rt.drop, "fold"); queue = rt.dequeNew() as rt.VecDeque; unwind = 120; const _221: Guard.Guard = guard(18); @@ -2076,7 +2076,7 @@ export function extended(log: Log.Log, id: rt.u32, at: rt.u8): void { throw e7; } }); - rt.dequeExtend(queue, _226, rt.drop); + rt.dequeExtend(queue, _226, "fold"); check(7); const _252: rt.usize = rt.btreeLen(tree); const _255: rt.usize = rt.btreeLen(ordered); @@ -2287,7 +2287,7 @@ export function bombed(log: Log.Log, id: rt.u32, at: rt.u8): void { unwind = 0; rt.ownedCount(rt.iterFilter(rt.iterSlice(v3, rt.drop), (b: Bomb.Bomb): boolean => { return !b.blows; - }, rt.drop), rt.drop, rt.drop); + }, rt.drop), rt.drop); } else if (at === 3) { _194 = true; map = rt.btreeNew(rt.cmp) as rt.BTreeMap; @@ -2332,7 +2332,7 @@ export function bombed(log: Log.Log, id: rt.u32, at: rt.u8): void { v4.push(_132); unwind = 0; const _115: rt.Iter<[rt.u32, Bomb.Bomb]> = rt.iterSlice(v4, drop$u32_Bomb); - rt.btreeDrop(rt.btreeCollect(rt.btreeNew(rt.cmp) as rt.BTreeMap, rt.iterToArray(_115, true, rt.drop, drop$u32_Bomb), undefined, rt.drop), undefined, rt.drop); + rt.btreeDrop(rt.btreeCollect(rt.btreeNew(rt.cmp) as rt.BTreeMap, rt.iterToArray(_115, "place", drop$u32_Bomb), undefined, rt.drop), undefined, rt.drop); } else if (at === 6) { v5 = []; unwind = 109; @@ -2343,7 +2343,7 @@ export function bombed(log: Log.Log, id: rt.u32, at: rt.u8): void { const _153: Bomb.Bomb = bomb(3, false); v5.push(_153); unwind = 0; - rt.ownedCount(rt.iterTake(rt.iterSlice(v5, rt.drop), 2, rt.drop), rt.drop, rt.drop); + rt.ownedCount(rt.iterTake(rt.iterSlice(v5, rt.drop), 2, rt.drop), rt.drop); } else { v6 = []; unwind = 108; @@ -2513,7 +2513,7 @@ export function spent(log: Log.Log, id: rt.u32, at: rt.u8): void { rt.drop(rt.hashInsert(map, n, _23, undefined, rt.drop)); } _176 = false; - rt.ownedCount(rt.hashIter(map, undefined, rt.drop), rt.drop, drop$u32_First); + rt.ownedCount(rt.hashIter(map, undefined, rt.drop), drop$u32_First); _176 = false; } else if (at === 1) { unwind = 114; @@ -2527,7 +2527,7 @@ export function spent(log: Log.Log, id: rt.u32, at: rt.u8): void { rt.hashAdd(set, _40, rt.drop); } _175 = false; - rt.ownedCount(rt.hashKeys(set, rt.drop), rt.drop, rt.drop); + rt.ownedCount(rt.hashKeys(set, rt.drop), rt.drop); _175 = false; } else if (at === 2) { unwind = 114; @@ -2540,7 +2540,7 @@ export function spent(log: Log.Log, id: rt.u32, at: rt.u8): void { const _64: First.First = first(2); v.push(_64); unwind = 114; - rt.ownedCount(rt.iterSkip(rt.iterSlice(v, rt.drop), 1, rt.drop), rt.drop, rt.drop); + rt.ownedCount(rt.iterSkip(rt.iterSlice(v, rt.drop), 1, rt.drop), rt.drop); } else if (at === 3) { unwind = 114; v2 = []; @@ -2557,7 +2557,7 @@ export function spent(log: Log.Log, id: rt.u32, at: rt.u8): void { _174 = true; rt.peekablePeek(peek) !== undefined; _174 = false; - rt.ownedCount(peek, rt.drop, rt.drop); + rt.ownedCount(peek, rt.drop); _174 = false; } else if (at === 4) { unwind = 114; @@ -2581,7 +2581,7 @@ export function spent(log: Log.Log, id: rt.u32, at: rt.u8): void { const _95: rt.Iter = rt.iterChain(_96, rt.iterSlice(_104, rt.drop)); unwind = 114; _173 = false; - rt.ownedCount(_95, rt.drop, rt.drop); + rt.ownedCount(_95, rt.drop); } else if (at === 5) { unwind = 114; map2 = rt.btreeNew(rt.cmp) as rt.BTreeMap; @@ -2595,7 +2595,7 @@ export function spent(log: Log.Log, id: rt.u32, at: rt.u8): void { rt.drop(rt.btreeInsert(map2, n3, _126, undefined, rt.drop)); } _172 = false; - rt.ownedCount(rt.btreeIter(map2, undefined, rt.drop), rt.drop, drop$u32_First); + rt.ownedCount(rt.btreeIter(map2, undefined, rt.drop), drop$u32_First); _172 = false; } else if (at === 6) { unwind = 114; @@ -2609,7 +2609,7 @@ export function spent(log: Log.Log, id: rt.u32, at: rt.u8): void { rt.dequePushBack(queue, _143); } _171 = false; - rt.ownedCount(rt.dequeIter(queue, rt.drop), rt.drop, rt.drop); + rt.ownedCount(rt.dequeIter(queue, rt.drop), rt.drop); _171 = false; } else { unwind = 114; @@ -2622,7 +2622,7 @@ export function spent(log: Log.Log, id: rt.u32, at: rt.u8): void { const _160: First.First = first(n5); rt.drop(rt.hashInsert(map3, n5, _160, undefined, rt.drop)); } - rt.ownedCount(rt.hashDrain(map3, undefined, rt.drop), rt.drop, drop$u32_First); + rt.ownedCount(rt.hashDrain(map3, undefined, rt.drop), drop$u32_First); unwind = 114; rt.hashDrop(map3, undefined, rt.drop); } diff --git a/ts/fixtures/task/expected/lib.ts b/ts/fixtures/task/expected/lib.ts index be333c2d0..11666a4dd 100644 --- a/ts/fixtures/task/expected/lib.ts +++ b/ts/fixtures/task/expected/lib.ts @@ -99,6 +99,10 @@ export function drop$Guard_u32(_1: [Guard.Guard, rt.u32]): void { rt.drop(_1[0]); } +export function drop$Guard_u64(_1: [Guard.Guard, rt.u64]): void { + rt.drop(_1[0]); +} + export function drop$Held(_1: Held.Held): void { let unwind: number = 0; try { @@ -390,4 +394,8 @@ export function drop$u32_Guard(_1: [rt.u32, Guard.Guard]): void { rt.drop(_1[1]); } +export function drop$usize_Guard(_1: [rt.usize, Guard.Guard]): void { + rt.drop(_1[1]); +} + //# sourceMappingURL=lib.ts.map diff --git a/ts/fixtures/task/src/drops.rs b/ts/fixtures/task/src/drops.rs index a15b35163..c58eb2a33 100644 --- a/ts/fixtures/task/src/drops.rs +++ b/ts/fixtures/task/src/drops.rs @@ -22,6 +22,7 @@ macro_rules! list { } mod closures; +mod folds; mod iters; mod objects; mod once; @@ -905,6 +906,18 @@ fn grown(log: &Log, id: u32, at: u8, tree: bool) { log.note(format!("unreached")); } +/// Run scenario `arg % 32` of what std's by-value consumers drop of adaptors that hold +/// closures that drop, panicking as a closure reads item `arg / 32`, if any. +pub fn folded(log: &Log, id: u32, arg: u8) { + folds::folded(log, id, arg); +} + +/// Run scenario `arg % 9` of what folds back to front, and through what wraps a closure +/// beside another, panicking as a closure reads item `arg / 9 % 8`, if any. +pub fn rfolded(log: &Log, id: u32, arg: u8) { + folds::rfolded(log, id, arg); +} + /// What a `Vec`'s edits, its and a tuple's `clone`, and `Ord`'s defaults drop, scenario /// `at`'s alone, and what is left to drop when a closure, a clone, a drop, or an index /// panics partway. diff --git a/ts/fixtures/task/src/drops/folds.rs b/ts/fixtures/task/src/drops/folds.rs new file mode 100644 index 000000000..191b5cdbb --- /dev/null +++ b/ts/fixtures/task/src/drops/folds.rs @@ -0,0 +1,803 @@ +//! What std's by-value consumers drop of an iterator whose adaptors hold closures that +//! drop beside items that drop: `fold` drops each adaptor's closure as its own fold ends, +//! before the source it wraps, where dropping the adaptor drops it after. Each closure +//! panics as it reads the item `at` names, if any, to show what unwinding drops. + +use std::collections::{BTreeMap, VecDeque}; + +use super::Bomb; +use crate::log::Log; +use crate::model::Guard; + +/// The id of `bomb`, which a closure that calls it captures whole. +fn bomb_id(bomb: &Bomb) -> u32 { + bomb.id +} + +/// Run scenario `arg % 32`, panicking as a closure reads item `arg / 32`, if any. Items +/// are guards 1 to 7; what closures own, 10 and up. +pub(super) fn folded(log: &Log, id: u32, arg: u8) { + let at = id + u32::from(arg / 32); + let guard = |n: u32| Guard::new(id + n, log.clone()); + let guards = |from: u32, to: u32| (from..to).map(guard).collect::>(); + let trip = move |g: &Guard| { + if g.id() == at { + panic!("d{id} at {}", g.id() - id); + } + }; + let trips = move |n: u32| { + if id + n == at { + panic!("d{id} at {n}"); + } + }; + let (c, d) = (guard(10), guard(11)); + match arg % 32 { + 0 => { + let n = guards(1, 5) + .into_iter() + .map(move |g| { + trip(&g); + g.id() + c.id() + }) + .count(); + let sum: u32 = guards(5, 8) + .into_iter() + .map(move |g| { + trip(&g); + g.id() - id + d.id() - id + }) + .sum(); + log.note(format!("count {n} {sum}")); + } + 1 => { + // An accumulator that drops, which a panic in the closure drops after the item. + let kept = guards(1, 7) + .into_iter() + .filter(move |g| { + trip(g); + g.id() % 2 == c.id() % 2 + }) + .fold(None, |kept: Option, g| { + log.note(format!("fold {} {:?}", g.id(), kept.as_ref().map(|k| k.id()))); + if g.id() % 4 == 0 { kept } else { Some(g) } + }); + log.note(format!("fold {:?} {}", kept.map(|k| k.id()), d.id())); + } + 2 => { + guards(1, 7) + .into_iter() + .filter_map(move |g| { + trip(&g); + (g.id() % 3 != c.id() % 3).then_some(g) + }) + .for_each(|g| log.note(format!("each {}", g.id()))); + log.note(format!("each {}", d.id())); + } + 3 => { + let last = guards(1, 5) + .into_iter() + .inspect(move |g| { + trip(g); + log.note(format!("inspect {} {}", g.id(), c.id())); + }) + .last(); + log.note(format!("last {:?} {}", last.map(|g| g.id()), d.id())); + } + 4 => { + let best = guards(1, 6) + .into_iter() + .map(move |g| { + trip(&g); + log.note(format!("map {} {}", g.id(), c.id())); + g + }) + .max_by_key(|g| g.id() % 3); + let least = guards(6, 8) + .into_iter() + .map(move |g| { + trip(&g); + g + }) + .min_by_key(|g| g.id() + d.id()); + log.note(format!("best {:?} {:?}", best.map(|g| g.id()), least.map(|g| g.id()))); + } + 5 => { + let max = guards(1, 4) + .into_iter() + .map(move |g| { + trip(&g); + g.id() % c.id() + }) + .max(); + let product: u32 = guards(4, 7) + .into_iter() + .map(move |g| { + trip(&g); + g.id() - id + d.id() - d.id() + }) + .product(); + log.note(format!("max {max:?} {product}")); + } + 6 => { + // In place of the `Vec` it reads, and not. + let same: Vec = guards(1, 4) + .into_iter() + .map(move |g| { + trip(&g); + log.note(format!("map {} {}", g.id(), c.id())); + g + }) + .collect(); + let wider: Vec<(Guard, u64)> = guards(4, 7) + .into_iter() + .map(move |g| { + trip(&g); + (g, u64::from(d.id())) + }) + .collect(); + log.note(format!("collected {} {}", same.len(), wider.len())); + } + 7 => { + let queue: VecDeque = guards(1, 4) + .into_iter() + .map(move |g| { + trip(&g); + log.note(format!("map {} {}", g.id(), c.id())); + g + }) + .collect(); + let tree: BTreeMap = guards(4, 7) + .into_iter() + .map(move |g| { + trip(&g); + (g.id() + d.id(), g) + }) + .collect(); + log.note(format!("collected {} {}", queue.len(), tree.len())); + } + 8 => { + let mut v = guards(1, 2); + v.extend(guards(2, 4).into_iter().map(move |g| { + trip(&g); + log.note(format!("map {} {}", g.id(), c.id())); + g + })); + let mut tree = BTreeMap::new(); + tree.extend(guards(4, 7).into_iter().map(move |g| { + trip(&g); + (g.id() + d.id(), g) + })); + log.note(format!("extended {} {}", v.len(), tree.len())); + } + 9 => { + // Two closures that drop, and nothing else. + let n = [1u32, 2, 3, 4, 5] + .iter() + .map(move |&n| { + trips(n); + n + c.id() + }) + .filter(move |n| n % 2 == d.id() % 2) + .count(); + log.note(format!("count {n}")); + } + 10 => { + // Two closures beside items: a `filter`'s drops before what it folds into. + let n: u32 = guards(1, 5) + .into_iter() + .filter(move |g| { + trip(g); + g.id() != c.id() + }) + .map(move |g| g.id() - id + d.id() - d.id()) + .sum(); + let (e, f) = (guard(12), guard(13)); + let m = guards(5, 8) + .into_iter() + .filter_map(move |g| { + trip(&g); + (g.id() != e.id()).then_some(g) + }) + .inspect(move |g| log.note(format!("inspect {} {}", g.id(), f.id()))) + .count(); + log.note(format!("two {n} {m}")); + } + 11 => { + // Through a chain, which folds each half in turn. + let n: u32 = guards(1, 3) + .into_iter() + .chain(guards(3, 5)) + .map(move |g| { + trip(&g); + g.id() - id + c.id() - id + }) + .sum(); + let m = guards(5, 7) + .into_iter() + .map(move |g| { + trip(&g); + g.id() + d.id() + }) + .chain([1u32, 2]) + .count(); + log.note(format!("chain {n} {m}")); + } + 12 => { + let n = guards(1, 4) + .into_iter() + .chain(guards(4, 7).into_iter().filter(move |g| { + trip(g); + g.id() != c.id() + })) + .fold(0, |n, g| n + g.id() - id); + let m = guards(7, 8) + .into_iter() + .map(move |g| { + trip(&g); + g + }) + .chain(Vec::new()) + .last(); + log.note(format!("chain {n} {:?} {}", m.map(|g| g.id()), d.id())); + } + 13 => { + // Through what reads past items or reorders them. + let n = guards(1, 8) + .into_iter() + .map(move |g| { + trip(&g); + log.note(format!("map {} {}", g.id(), c.id())); + g + }) + .rev() + .skip(1) + .step_by(2) + .take(2) + .fold(0, |n, g| n + g.id() - id); + log.note(format!("read {n} {}", d.id())); + } + 14 => { + let n: usize = guards(1, 4) + .into_iter() + .enumerate() + .map(move |(i, g)| { + trip(&g); + i + c.id() as usize + }) + .sum(); + let last = guards(4, 7) + .into_iter() + .map(move |g| { + trip(&g); + log.note(format!("map {} {}", g.id(), d.id())); + g + }) + .enumerate() + .last(); + log.note(format!("enumerate {n} {:?}", last.map(|(i, g)| (i, g.id())))); + } + 15 => { + // A peeked item, and a fuse. + let mut peek = guards(1, 5) + .into_iter() + .map(move |g| { + trip(&g); + log.note(format!("map {} {}", g.id(), c.id())); + g + }) + .peekable(); + log.note(format!("peek {:?}", peek.peek().map(|g| g.id()))); + let n = peek.fold(0, |n, g| n + g.id() - id); + let m = guards(5, 8) + .into_iter() + .fuse() + .filter(move |g| { + trip(g); + g.id() != d.id() + }) + .fold(0, |n, g| n + g.id()); + log.note(format!("peek {n} {m}")); + } + 16 => { + // A `skip_while` folds what it wraps, and drops its closure after. + let n: u32 = guards(1, 5) + .into_iter() + .skip_while(move |g| { + trip(g); + g.id() < c.id() - 8 + }) + .map(|g| g.id() - id) + .sum(); + let m: u32 = guards(5, 8) + .into_iter() + .map(move |g| { + trip(&g); + g + }) + .skip_while(move |g| g.id() < d.id() - 5) + .take_while(|g| g.id() < id + 7) + .map(|g| g.id() - id) + .sum(); + log.note(format!("skip {n} {m}")); + } + 17 => { + // What std folds by `try_fold`, which leaves its closure to the adaptor. + let n: u32 = guards(1, 5) + .into_iter() + .map_while(move |g| { + trip(&g); + (g.id() != c.id() - 7).then(|| g.id() - id) + }) + .sum(); + let m = guards(5, 8) + .into_iter() + .take_while(move |g| { + trip(g); + g.id() != d.id() - 4 + }) + .count(); + log.note(format!("while {n} {m}")); + } + 18 => { + // What a `flat_map` folds: its closure, and each iterator it makes. + let n = [1u32, 3, 5] + .into_iter() + .flat_map(move |n| { + trips(n); + let v = list![guard(n), guard(n + 1)]; + log.note(format!("flat {n} {}", c.id())); + v + }) + .count(); + log.note(format!("flat {n} {}", d.id())); + } + 19 => { + let mut flat = guards(1, 4) + .into_iter() + .map(move |g| { + trip(&g); + list![g, guard(c.id() - id + 1)] + }) + .flatten(); + log.note(format!("front {:?}", flat.next().map(|g| g.id()))); + let n: u32 = flat.map(|g| g.id() - id).sum(); + let m = [4u32, 6] + .into_iter() + .flat_map(move |n| { + trips(n); + list![guard(n), guard(d.id() - id + n)] + }) + .last(); + log.note(format!("flat {n} {:?}", m.map(|g| g.id()))); + } + 20 => { + // Lazy sources, which hold their closure and what it made. + let mut held = guards(1, 5); + let n = std::iter::from_fn(move || { + let g = held.pop()?; + trip(&g); + Some(g.id() + c.id()) + }) + .count(); + let m = std::iter::successors(Some(guard(5)), move |g| { + trip(g); + (g.id() < id + 7).then(|| Guard::new(g.id() + 1 + d.id() - d.id(), log.clone())) + }) + .fold(0, |n, g| n + g.id() - id); + log.note(format!("lazy {n} {m}")); + } + 21 => { + // A consumer over the adaptor that holds the closure. + let n = guards(1, 5) + .into_iter() + .map(move |g| { + trip(&g); + g.id() + c.id() + }) + .skip(1) + .count(); + let m = guards(5, 8) + .into_iter() + .map(move |g| { + trip(&g); + g + }) + .take(2) + .count(); + log.note(format!("over {n} {m}")); + } + 22 => { + // Back to front. + let n = guards(1, 5) + .into_iter() + .map(move |g| { + trip(&g); + log.note(format!("map {} {}", g.id(), c.id())); + g.id() - id + }) + .rev() + .fold(0, |n, k| n * 10 + k); + let m = guards(5, 6) + .into_iter() + .chain(guards(6, 8)) + .filter(move |g| { + trip(g); + g.id() != d.id() - 5 + }) + .rev() + .count(); + log.note(format!("rev {n} {m}")); + } + 23 => { + let n = guards(1, 6) + .into_iter() + .map(move |g| { + trip(&g); + log.note(format!("map {} {}", g.id(), c.id())); + g + }) + .take(3) + .rev() + .fold(0, |n, g| n * 10 + g.id() - id); + let m: u32 = guards(6, 8) + .into_iter() + .map(move |g| { + trip(&g); + g.id() - id + }) + .take(0) + .rev() + .sum(); + log.note(format!("take {n} {m} {}", d.id())); + } + 24 => { + let n: u32 = guards(1, 7) + .into_iter() + .map(move |g| { + trip(&g); + log.note(format!("map {} {}", g.id(), c.id())); + g + }) + .step_by(2) + .rev() + .map(|g| g.id() - id) + .sum(); + let m = guards(7, 8) + .into_iter() + .filter(move |g| { + trip(g); + g.id() != d.id() + }) + .step_by(3) + .count(); + log.note(format!("step {n} {m}")); + } + 25 => { + let mut peek = guards(1, 5) + .into_iter() + .map(move |g| { + trip(&g); + log.note(format!("map {} {}", g.id(), c.id())); + g + }) + .peekable(); + log.note(format!("peek {:?}", peek.peek().map(|g| g.id()))); + let n = peek.rev().fold(0, |n, g| n * 10 + g.id() - id); + let mut ended = guards(5, 6) + .into_iter() + .map(move |g| { + trip(&g); + g + }) + .peekable(); + log.note(format!("peek {:?}", ended.next().map(|g| g.id()))); + log.note(format!("peek {:?}", ended.peek().map(|g| g.id()))); + log.note(format!("peek {n} {} {}", ended.rev().count(), d.id())); + } + 26 => { + let mut flat = guards(1, 4) + .into_iter() + .map(move |g| { + trip(&g); + list![g, guard(c.id() - id + 1)] + }) + .flatten(); + log.note(format!("back {:?}", flat.next_back().map(|g| g.id()))); + let n = flat.rev().fold(0, |n, g| n * 100 + g.id() - id); + let m = guards(4, 8) + .into_iter() + .map(move |g| { + trip(&g); + g + }) + .enumerate() + .rev() + .last(); + log.note(format!("flat {n} {:?} {}", m.map(|(i, g)| (i, g.id())), d.id())); + } + 27 => { + let kept = guards(1, 5) + .into_iter() + .filter(move |g| { + trip(g); + g.id() != c.id() - 8 + }) + .rev() + .fold( + None, + |kept: Option, g| if g.id() % 2 == 0 { Some(g) } else { kept }, + ); + let n: u32 = guards(5, 8) + .into_iter() + .filter_map(move |g| { + trip(&g); + (g.id() != d.id() - 5).then_some(g) + }) + .rev() + .map(|g| g.id() - id) + .sum(); + log.note(format!("rev {:?} {n}", kept.map(|g| g.id()))); + } + 28 => { + let n = guards(1, 5) + .into_iter() + .inspect(move |g| { + trip(g); + log.note(format!("inspect {} {}", g.id(), c.id())); + }) + .rev() + .count(); + let m: u32 = guards(5, 8) + .into_iter() + .map(move |g| { + trip(&g); + g + }) + .fuse() + .rev() + .map(|g| g.id() - id + d.id() - d.id()) + .sum(); + log.note(format!("rev {n} {m}")); + } + 29 => { + // Two closures beside items, back to front. + let n = guards(1, 4) + .into_iter() + .map(move |g| { + trip(&g); + g + }) + .chain(guards(4, 7).into_iter().filter(move |g| { + trip(g); + g.id() != d.id() - 6 + })) + .rev() + .fold(0, |n, g| n * 10 + g.id() - id); + log.note(format!("rev {n} {}", c.id())); + } + 30 => { + let n: u32 = guards(1, 6) + .into_iter() + .map(move |g| { + trip(&g); + log.note(format!("map {} {}", g.id(), c.id())); + g + }) + .skip(2) + .rev() + .map(|g| g.id() - id) + .sum(); + let m = guards(6, 8) + .into_iter() + .filter(move |g| { + trip(g); + g.id() != d.id() + }) + .skip(1) + .fold(0, |n, g| n + g.id() - id); + log.note(format!("skip {n} {m}")); + } + _ => { + // A closure that panics as it drops, after a fold: what it wraps still drops, + // and so does what the rest of the chain holds. + let bomb = Bomb { + id: id + 12, + log: log.clone(), + blows: at == id, + }; + let n = guards(1, 4) + .into_iter() + .map(move |g| { + trip(&g); + g.id() + bomb_id(&bomb) + }) + .chain(guards(4, 6).into_iter().map(move |g| g.id() + c.id())) + .count(); + log.note(format!("done {n} {}", d.id())); + } + } +} + +/// Run scenario `arg % 9` of what folds back to front and through what wraps a closure +/// beside another, panicking as a closure reads item `arg / 9 % 8`, if any, as `folded` does. +pub(super) fn rfolded(log: &Log, id: u32, arg: u8) { + let at = id + u32::from(arg / 9 % 8); + let guard = |n: u32| Guard::new(id + n, log.clone()); + let guards = |from: u32, to: u32| (from..to).map(guard).collect::>(); + let trip = move |g: &Guard| { + if g.id() == at { + panic!("d{id} at {}", g.id() - id); + } + }; + let (c, d, e) = (guard(10), guard(11), guard(12)); + match arg % 9 { + 0 => { + let n: u32 = guards(1, 5) + .into_iter() + .map(move |g| { + trip(&g); + log.note(format!("map {} {}", g.id(), c.id())); + g + }) + .rev() + .map(move |g| g.id() - id + d.id() - d.id()) + .sum(); + log.note(format!("map {n} {}", e.id())); + } + 1 => { + let n: u32 = guards(1, 5) + .into_iter() + .filter(move |g| { + trip(g); + g.id() != c.id() + }) + .rev() + .map(move |g| g.id() - id + d.id() - d.id()) + .sum(); + let f = guard(13); + let m = guards(5, 8) + .into_iter() + .filter_map(move |g| { + trip(&g); + (g.id() != e.id()).then_some(g) + }) + .rev() + .map(move |g| g.id() + f.id()) + .count(); + log.note(format!("filter {n} {m}")); + } + 2 => { + let n = guards(1, 4) + .into_iter() + .inspect(move |g| { + trip(g); + log.note(format!("inspect {} {}", g.id(), c.id())); + }) + .map(move |g| g.id() + d.id()) + .count(); + let f = guard(13); + let m = guards(4, 8) + .into_iter() + .inspect(move |g| { + trip(g); + log.note(format!("inspect {} {}", g.id(), e.id())); + }) + .rev() + .map(move |g| g.id() + f.id()) + .count(); + log.note(format!("inspect {n} {m}")); + } + 3 => { + let last = guards(1, 5) + .into_iter() + .map(move |g| { + trip(&g); + log.note(format!("map {} {}", g.id(), c.id())); + g + }) + .enumerate() + .rev() + .last(); + log.note(format!( + "enumerate {:?} {} {}", + last.map(|(i, g)| (i, g.id())), + d.id(), + e.id() + )); + } + 4 => { + let n = guards(1, 5) + .into_iter() + .map(move |g| { + trip(&g); + g.id() + c.id() + }) + .rev() + .rev() + .count(); + let m = guards(5, 8) + .into_iter() + .map(move |g| { + trip(&g); + g.id() + d.id() + }) + .skip(1) + .fold(0, |n, k| n + k); + log.note(format!("twice {n} {m} {}", e.id())); + } + 5 => { + // The first step's panic drops the accumulator after what folds into it. + let kept = guards(1, 5) + .into_iter() + .map(move |g| { + trip(&g); + log.note(format!("map {} {}", g.id(), c.id())); + g + }) + .step_by(2) + .map(move |g| (g, d.id())) + .fold( + Some(guard(20)), + |kept, (g, _)| if g.id() % 2 == 1 { Some(g) } else { kept }, + ); + log.note(format!("step {:?} {}", kept.map(|g| g.id()), e.id())); + } + 6 => { + let kept = guards(1, 6) + .into_iter() + .map(move |g| { + trip(&g); + log.note(format!("map {} {}", g.id(), c.id())); + g + }) + .step_by(2) + .rev() + .map(move |g| (g, d.id())) + .fold( + Some(guard(20)), + |kept, (g, _)| if g.id() % 2 == 1 { Some(g) } else { kept }, + ); + log.note(format!("step {:?} {}", kept.map(|g| g.id()), e.id())); + } + 7 => { + let n: u32 = guards(1, 5) + .into_iter() + .map(move |g| { + trip(&g); + g.id() - id + c.id() - c.id() + }) + .fuse() + .sum(); + let m = guards(5, 8) + .into_iter() + .map(move |g| { + trip(&g); + g.id() + d.id() + }) + .fuse() + .rev() + .count(); + log.note(format!("fuse {n} {m} {}", e.id())); + } + _ => { + // A panic folding the front iterator: what folds into it drops, then the + // source, then the back. + let mut flat = guards(1, 4) + .into_iter() + .map(move |g| { + log.note(format!("map {} {}", g.id(), c.id())); + list![guard(g.id() - id + 3), g] + }) + .flatten(); + log.note(format!("ends {:?}", flat.next().map(|g| g.id()))); + log.note(format!("ends {:?}", flat.next_back().map(|g| g.id()))); + let n = flat + .map(move |g| { + trip(&g); + g.id() + d.id() + }) + .count(); + log.note(format!("flat {n} {}", e.id())); + } + } +} diff --git a/ts/fixtures/task/src/harness.rs b/ts/fixtures/task/src/harness.rs index 197d3c39e..3f41617b4 100644 --- a/ts/fixtures/task/src/harness.rs +++ b/ts/fixtures/task/src/harness.rs @@ -139,6 +139,12 @@ fn steps() -> Vec<(&'static str, Step)> { ("cells", |log, exec, _, arg| { drops::cells(log, 1000 * exec.len() as u32, arg) }), + ("folded", |log, exec, _, arg| { + drops::folded(log, 1000 * exec.len() as u32, arg) + }), + ("rfolded", |log, exec, _, arg| { + drops::rfolded(log, 1000 * exec.len() as u32, arg) + }), ] } diff --git a/ts/fixtures/task/ts.toml b/ts/fixtures/task/ts.toml index 32e929d5f..d2a3f5ac3 100644 --- a/ts/fixtures/task/ts.toml +++ b/ts/fixtures/task/ts.toml @@ -13,6 +13,8 @@ roots = [ "drops::edited", "drops::dyns", "drops::cells", + "drops::folded", + "drops::rfolded", "futures::helpers", "futures::boxed", ] diff --git a/ts/runtime/rt/collections.ts b/ts/runtime/rt/collections.ts index be4efa96f..af1524e1c 100644 --- a/ts/runtime/rt/collections.ts +++ b/ts/runtime/rt/collections.ts @@ -16,8 +16,8 @@ import { type None, type Place, panic } from "../rt.ts"; import { type Limbs, lt } from "./int.ts"; -import { DONE, type Done, Iter, iterMap, iterSlice, type RangeInclusive } from "./iter.ts"; -import { type Arc, dropAll } from "./task.ts"; +import { DONE, type Done, Iter, iterMap, iterSlice, type RangeInclusive, type Take } from "./iter.ts"; +import { type Arc, drop as dispose, dropAll } from "./task.ts"; // Ordering @@ -829,23 +829,27 @@ function taken(m: HashMap): HashMap { } /** - * Run `f`, which extends `c` from `items`, and then drop `items` by `dropIt`, as std's - * `extend` drops the iterator it takes. A panic drops `items`, and then, if `c` is - * `fresh`, one `collect` made, `c` by `drop`. + * Extend `c` by `add` of each of `items`, taken as `take` says, as std's `extend` takes + * the iterator. A panic drops `items`, and then, if `c` is `fresh`, one `collect` made, + * `c` by `drop`. */ -function extending(c: C, items: Iter, f: () => void, dropIt?: (it: Iter) => void, fresh = false, drop?: (c: C) => void): C { - if (dropIt === undefined && !fresh) { - f(); +function extending(c: C, items: Iter, add: (item: T) => void, take?: Take, fresh = false, drop?: (c: C) => void): C { + if (take === undefined && !fresh) { + for (let item = items.next(); item !== DONE; item = items.next()) add(item); return c; } + const all = () => { + if (take === "fold") items.fold(undefined, (_, item) => add(item)); + else for (let item = items.next(); item !== DONE; item = items.next()) add(item); + }; try { try { - f(); + all(); } catch (e) { - dropIt?.(items); + if (take === "next") dispose(items); throw e; } - dropIt?.(items); + if (take === "next") dispose(items); } catch (e) { if (fresh) drop?.(c); throw e; @@ -863,24 +867,19 @@ export function hashExtend( items: Iter<[K, V]>, k?: (key: K) => void, v?: (value: V) => void, - dropIt?: (it: Iter<[K, V]>) => void, + take?: Take, fresh = false, ): HashMap { - const f = () => { - for (let item = items.next(); item !== DONE; item = items.next()) { - const old = hashInsert(m, item[0], item[1], k, v); - if (old !== undefined) v?.(old); - } + const add = (item: [K, V]) => { + const old = hashInsert(m, item[0], item[1], k, v); + if (old !== undefined) v?.(old); }; - return extending(m, items, f, dropIt, fresh, (m) => hashDrop(m, k, v)); + return extending(m, items, add, take, fresh, (m) => hashDrop(m, k, v)); } /** `extend` of a set with keys, and `collect` into one, as `hashExtend`: a key already there drops. */ -export function hashExtendKeys(m: HashSet, keys: Iter, k?: (key: K) => void, dropIt?: (it: Iter) => void, fresh = false): HashSet { - const f = () => { - for (let key = keys.next(); key !== DONE; key = keys.next()) hashAdd(m, key, k); - }; - return extending(m, keys, f, dropIt, fresh, (m) => hashDrop(m, k)); +export function hashExtendKeys(m: HashSet, keys: Iter, k?: (key: K) => void, take?: Take, fresh = false): HashSet { + return extending(m, keys, (key) => hashAdd(m, key, k), take, fresh, (m) => hashDrop(m, k)); } /** `clone`, with each key and value through its `Clone`, or as itself without one. */ @@ -1586,7 +1585,7 @@ function edge(m: BTreeMap, key: K, past: boolean): [Leaf, numb /** * `extend` of a map with `[key, value]`s, which keeps an equal key already there and drops - * the one given, then the value it replaced, and drops `items` by `dropIt` once done. With + * the one given, then the value it replaced, and takes `items` as `take` says. With * `last`, `collect` and `from` of entries that drop nothing into an empty one, which keep * the last of equal keys, as `btreeCollect` does. */ @@ -1596,42 +1595,38 @@ export function btreeExtend( last = false, k?: (key: K) => void, v?: (value: V) => void, - dropIt?: (it: Iter<[K, V]>) => void, + take?: Take, ): BTreeMap { - const f = () => { - for (let item = items.next(); item !== DONE; item = items.next()) { - if (!last) { - const old = btreeInsert(m, item[0], item[1], k, v); - if (old !== undefined) v?.(old); - continue; - } - const l = leafOf(m, item[0]); - const i = search(l.k, item[0], m.c); - if (i < 0) insertAt(m, l, ~i, item[0], item[1]); - else { - l.k[i] = item[0]; - l.v[i] = item[1]; - } + const add = (item: [K, V]) => { + if (!last) { + const old = btreeInsert(m, item[0], item[1], k, v); + if (old !== undefined) v?.(old); + return; + } + const l = leafOf(m, item[0]); + const i = search(l.k, item[0], m.c); + if (i < 0) insertAt(m, l, ~i, item[0], item[1]); + else { + l.k[i] = item[0]; + l.v[i] = item[1]; } }; - return extending(m, items, f, dropIt); + return extending(m, items, add, take); } /** `extend` of a set with keys, and with `last`, `collect` and `from`, as `btreeExtend`. */ -export function btreeExtendKeys(m: BTreeSet, keys: Iter, last = false, k?: (key: K) => void, dropIt?: (it: Iter) => void): BTreeSet { - const f = () => { - for (let key = keys.next(); key !== DONE; key = keys.next()) { - if (!last) { - btreeAdd(m, key, k); - continue; - } - const l = leafOf(m, key); - const i = search(l.k, key, m.c); - if (i < 0) insertAt(m, l, ~i, key, undefined); - else l.k[i] = key; +export function btreeExtendKeys(m: BTreeSet, keys: Iter, last = false, k?: (key: K) => void, take?: Take): BTreeSet { + const add = (key: K) => { + if (!last) { + btreeAdd(m, key, k); + return; } + const l = leafOf(m, key); + const i = search(l.k, key, m.c); + if (i < 0) insertAt(m, l, ~i, key, undefined); + else l.k[i] = key; }; - return extending(m, keys, f, dropIt); + return extending(m, keys, add, take); } /** @@ -2143,12 +2138,9 @@ export function dequeDrain(q: VecDeque, r: Bounds, drop?: (item: T return new DequeIter(taken, 0, taken.n, drop); } -/** `extend`, and `collect` into a deque through `dequeNew`, which drops `items` by `dropIt` once done. */ -export function dequeExtend(q: VecDeque, items: Iter, dropIt?: (it: Iter) => void): VecDeque { - const f = () => { - for (let item = items.next(); item !== DONE; item = items.next()) dequePushBack(q, item); - }; - return extending(q, items, f, dropIt); +/** `extend`, and `collect` into a deque through `dequeNew`, which takes `items` as `take` says. */ +export function dequeExtend(q: VecDeque, items: Iter, take?: Take): VecDeque { + return extending(q, items, (item) => dequePushBack(q, item), take); } /** `clone`, with each item through its `Clone`, or as itself without one. */ diff --git a/ts/runtime/rt/iter.ts b/ts/runtime/rt/iter.ts index e0df4c084..c70c18db5 100644 --- a/ts/runtime/rt/iter.ts +++ b/ts/runtime/rt/iter.ts @@ -81,12 +81,101 @@ export abstract class Iter implements Iterable { return this.advanceBackBy(n, drop) === 0 ? this.nextBack() : DONE; } + /** + * `fold`, as std's of its kind, which takes the iterator by value and drops what it + * holds as std's does, a panic included. `release` drops what `f` owns, as std drops + * the closure it was given: as its fold ends, before the iterator. The accumulator + * drops by `dropAcc` where a panic leaves it to the fold rather than to `f`. + */ + fold(acc: A, f: (acc: A, item: T) => A, dropAcc?: Drop, release?: () => void): A { + return foldBy(this, false, acc, f, dropAcc, release); + } + + /** `rfold`, from the back, as `fold`. */ + rfold(acc: A, f: (acc: A, item: T) => A, dropAcc?: Drop, release?: () => void): A { + return foldBy(this, true, acc, f, dropAcc, release); + } + /** Its items, for a JS `for ... of`. */ *[Symbol.iterator](): Iterator { for (let item = this.next(); item !== DONE; item = this.next()) yield item; } } +/** + * std's default `fold`, or `rfold` if `back`: each item by `next`, the accumulator dropped + * by `dropAcc` if reading one panics, and then `release` and `it`. + */ +function foldBy(it: Iter, back: boolean, acc: A, f: (acc: A, item: T) => A, dropAcc?: Drop, release?: () => void): A { + try { + for (;;) { + let item: T | Done; + try { + item = back ? it.nextBack() : it.next(); + } catch (e) { + dropAcc?.(acc); + throw e; + } + if (item === DONE) break; + acc = f(acc, item); + } + } catch (e) { + ended(it, release); + throw e; + } + // A panic here leaks the accumulator, as std's unwinding does a returned value. + ended(it, release); + return acc; +} + +/** + * What a panic unwinding a fold drops before the fold took its accumulator: its closure by + * `release`, the accumulator by `dropAcc`, and then `it`, as std's drop its parameters. + */ +function unwound(it: unknown, acc: A, dropAcc?: Drop, release?: () => void): void { + release?.(); + dropAcc?.(acc); + dispose(it); +} + +/** + * The first step of a fold that reads an item by `read` before it folds the rest: whether + * `it` ended, which drops `release` and then `it` as the fold returns, and the accumulator, + * then `f` of the item. A panic drops what std's unwinding of the fold does. + */ +function foldFirst(it: unknown, read: () => T | Done, acc: A, f: (acc: A, item: T) => A, dropAcc?: Drop, release?: () => void): [boolean, A] { + let item: T | Done; + try { + item = read(); + } catch (e) { + unwound(it, acc, dropAcc, release); + throw e; + } + if (item === DONE) { + ended(it, release); + return [true, acc]; + } + try { + return [false, f(acc, item)]; + } catch (e) { + ended(it, release); + throw e; + } +} + +/** `release`, then `it` dropped, as a fold's closure drops and then its iterator. */ +function ended(it: unknown, release?: () => void): void { + if (release === undefined) dispose(it); + else both(release, () => dispose(it)); +} + +/** What drops `a`'s and then `b`'s, as a closure that captured them in that order drops. */ +function then(a: (() => void) | undefined, b: (() => void) | undefined): (() => void) | undefined { + if (a === undefined) return b; + if (b === undefined) return a; + return () => both(a, b); +} + /** An adaptor of `inner`, which drops with it. */ abstract class Adaptor extends Iter implements Disposable { readonly inner: Iter; @@ -114,6 +203,12 @@ abstract class Calling extends Adaptor { this.f = f; } + /** What drops `f`, which a fold of `inner` takes from it: dropping it then drops nothing. */ + protected take(): () => void { + this.dropped = true; + return () => dispose(this.f); + } + override [Symbol.dispose](): void { if (this.dropped) return; this.dropped = true; @@ -199,26 +294,22 @@ export function iterBorrow(it: Iter): Iter { return new Borrowed(it); } -/** `Extend::extend` of a `Vec`, which drops `items` by `dropIt` once done or a panic. */ -export function iterExtend(v: T[], items: Iter, dropIt?: Drop>): void { - if (dropIt === undefined) { +/** `Extend::extend` of a `Vec`, which takes `items` as `take` says. */ +export function iterExtend(v: T[], items: Iter, take?: Take): void { + if (take === undefined) { for (let item = items.next(); item !== DONE; item = items.next()) v.push(item); return; } - try { - for (let item = items.next(); item !== DONE; item = items.next()) v.push(item); - } finally { - dropIt(items); - } + each(items, (item) => v.push(item), take); } /** `Extend::extend` of a `Vec`. */ -export function iterExtendBytes(v: ByteVec, items: Iter, dropIt?: Drop>): void { - try { +export function iterExtendBytes(v: ByteVec, items: Iter, take?: Take): void { + if (take === undefined) { for (let item = items.next(); item !== DONE; item = items.next()) byteVecPush(v, item); - } finally { - dropIt?.(items); + return; } + each(items, (item) => byteVecPush(v, item), take); } // Adaptors @@ -341,8 +432,26 @@ export function iterFlatten(it: Iter, into?: (value: T) => Iter, fus return new FlattenIter(it, into ?? (itself as (value: T) => Iter), fused); } -// Consumers. Each that takes the iterator by value drops it by `dropIt` once done, or as -// a panic unwinds through it. +// Consumers. Each that takes an iterator by value that `drops` takes it as std's does: by +// its own `fold` where std's folds, which drops what it holds as it goes, or as `take` +// says, and else by `next`, dropping it once done or as a panic unwinds through it. + +/** + * How a consumer takes an iterator by value that drops, where std's may either way: by + * `next`, as std's does one it can't trust the length of, or by its own `fold`. + */ +export type Take = "next" | "fold"; + +/** `it`, taken as `take` says: `f` of each item, and then it dropped, a panic included. */ +function each(it: Iter, f: (item: T) => void, take: Take | undefined): void { + if (take === "fold") { + it.fold(undefined, (_, item) => f(item)); + return; + } + consumed(it, () => { + for (let item = it.next(); item !== DONE; item = it.next()) f(item); + }); +} /** `Iterator::count` of an iterator that drops nothing. */ export function iterCount(it: Iter): number { @@ -443,84 +552,62 @@ export function iterPosition(it: Iter, f: (item: T) => boolean): number | * `Iterator::fold`. A panic reading an item drops the accumulator by `dropAcc`; one in * `f`, which took it, leaves it to `f`. */ -export function iterFold(it: Iter, init: A, f: (acc: A, item: T) => A, dropIt?: Drop>, dropAcc?: Drop): A { - let acc = init; - if (dropIt === undefined && dropAcc === undefined) { +export function iterFold(it: Iter, init: A, f: (acc: A, item: T) => A, drops = false, dropAcc?: Drop): A { + if (!drops && dropAcc === undefined) { + let acc = init; for (let item = it.next(); item !== DONE; item = it.next()) acc = f(acc, item); return acc; } - try { - for (;;) { - let item: T | Done; - try { - item = it.next(); - } catch (e) { - dropAcc?.(acc); - throw e; - } - if (item === DONE) break; - acc = f(acc, item); - } - } catch (e) { - dropIt?.(it); - throw e; - } - // A panic here leaks the accumulator, as std's unwinding does a returned value. - dropIt?.(it); - return acc; + return it.fold(init, f, dropAcc); } /** `Iterator::for_each`. */ -export function iterForEach(it: Iter, f: (item: T) => void, dropIt?: Drop>): void { - if (dropIt === undefined) { +export function iterForEach(it: Iter, f: (item: T) => void, drops = false): void { + if (!drops) { for (let item = it.next(); item !== DONE; item = it.next()) f(item); return; } - try { - for (let item = it.next(); item !== DONE; item = it.next()) f(item); - } finally { - dropIt(it); - } + it.fold(undefined, (_, item) => f(item)); } /** `sum`, adding with an integer type's checked `add`, so overflow panics as Rust's does. */ -export function iterSum(it: Iter, add: (a: T, b: T) => T, zero: T, dropIt?: Drop>): T { - return iterFold(it, zero, add, dropIt); +export function iterSum(it: Iter, add: (a: T, b: T) => T, zero: T, drops = false): T { + return iterFold(it, zero, add, drops); } /** `product`, multiplying with an integer type's checked `mul`. */ -export function iterProduct(it: Iter, mul: (a: T, b: T) => T, one: T, dropIt?: Drop>): T { - return iterFold(it, one, mul, dropIt); +export function iterProduct(it: Iter, mul: (a: T, b: T) => T, one: T, drops = false): T { + return iterFold(it, one, mul, drops); } /** `max` of integers or booleans: the last of the greatest, as `Ord::max` keeps it. */ -export function iterMax(it: Iter, dropIt?: Drop>): K | undefined { - return iterMaxByKey(it, (item) => item, dropIt); +export function iterMax(it: Iter, drops = false): K | undefined { + return iterMaxByKey(it, (item) => item, drops); } /** `min` of integers or booleans: the first of the least. */ -export function iterMin(it: Iter, dropIt?: Drop>): K | undefined { - return iterMinByKey(it, (item) => item, dropIt); +export function iterMin(it: Iter, drops = false): K | undefined { + return iterMinByKey(it, (item) => item, drops); } /** `max_by_key` with an integer or boolean key, each item's taken once, dropping the others by `drop`. */ -export function iterMaxByKey(it: Iter, f: (item: T) => K, dropIt?: Drop>, drop?: Drop): T | undefined { - return best(it, f, false, dropIt, drop); +export function iterMaxByKey(it: Iter, f: (item: T) => K, drops = false, drop?: Drop): T | undefined { + return best(it, f, false, drops, drop); } /** `min_by_key` with an integer or boolean key, each item's taken once, dropping the others by `drop`. */ -export function iterMinByKey(it: Iter, f: (item: T) => K, dropIt?: Drop>, drop?: Drop): T | undefined { - return best(it, f, true, dropIt, drop); +export function iterMinByKey(it: Iter, f: (item: T) => K, drops = false, drop?: Drop): T | undefined { + return best(it, f, true, drops, drop); } /** * The item of the greatest key, the last of equal ones, or of the least if `least`, the - * first, as std's `reduce` keeps it: each other drops as it loses. A panic in `f` drops - * its item, then the best, then the iterator; one dropping a loser leaks the winner, as - * std's unwinding does a returned value. + * first, as std's `reduce` keeps it: the first by `next`, and the rest by `fold`, each + * other dropped as it loses. A panic in `f` drops its item, then the best; one dropping + * a loser leaks the winner, as std's unwinding does a returned value. */ -function best(it: Iter, f: (item: T) => K, least: boolean, dropIt?: Drop>, drop?: Drop): T | undefined { - if (dropIt === undefined && drop === undefined) { +function best(it: Iter, f: (item: T) => K, least: boolean, drops: boolean, drop?: Drop): T | undefined { + if (!drops && drop === undefined) { let best = it.next(); if (best === DONE) return undefined; let key = f(best); @@ -530,66 +617,68 @@ function best(it: Iter, f: (item: T) = } return best; } - let best: T | Done = DONE; - let key: K | undefined; + let first: [K, T] | Done = DONE; try { - for (let item = it.next(); item !== DONE; item = it.next()) { + const item = it.next(); + if (item !== DONE) first = [drop === undefined ? f(item) : test(f, item, drop), item]; + } catch (e) { + dispose(it); + throw e; + } + if (first === DONE) { + dispose(it); + return undefined; + } + const [, item] = it.fold( + first, + (best, item) => { let k: K; try { k = f(item); } catch (e) { drop?.(item); + drop?.(best[1]); throw e; } - if (best === DONE) { - [best, key] = [item, k]; - continue; - } - const wins = least ? lt(k, key as K) : !lt(k, key as K); - const loser = wins ? best : item; - if (wins) [best, key] = [item, k]; - if (drop !== undefined) { - const held: T | Done = best; - best = DONE; - drop(loser); - best = held; - } - } - } catch (e) { - try { - if (best !== DONE) drop?.(best); - } finally { - dropIt?.(it); - } - throw e; - } - // A panic here leaks the best, as std's unwinding does a returned value. - dropIt?.(it); - return iterToOption(best); + const wins = least ? lt(k, best[0]) : !lt(k, best[0]); + drop?.(wins ? best[1] : item); + return wins ? [k, item] : best; + }, + (best) => drop?.(best[1]), + ); + return item; } /** - * `collect` into a `Vec`. A panic drops `it` by `dropIt` and then what it collected by - * `drop`, or with `inPlace`, as std's collects into the source `Vec`'s buffer, the other - * way around. + * `collect` into a `Vec`, taking `it` as `take` says, or in `place` of the `Vec` its items + * come from. A panic drops `it` and then what it collected by `drop`, or in place, as + * std's collects into the source `Vec`'s buffer, the other way around. */ -export function iterToArray(it: Iter, inPlace = false, dropIt?: Drop>, drop?: Drop): T[] { +export function iterToArray(it: Iter, take?: Take | "place", drop?: Drop): T[] { const out: T[] = []; - if (dropIt === undefined && drop === undefined) { + if (take === undefined && drop === undefined) { for (let item = it.next(); item !== DONE; item = it.next()) out.push(item); return out; } // Not `dropAll`'s default, which would drop what a collected reference points to. const collected = () => drop !== undefined && dropAll(out, drop); + if (take !== "place") { + try { + each(it, (item) => out.push(item), take); + } catch (e) { + collected(); + throw e; + } + return out; + } try { for (let item = it.next(); item !== DONE; item = it.next()) out.push(item); } catch (e) { - if (inPlace) both(collected, () => dropIt?.(it)); - else both(() => dropIt?.(it), collected); + both(collected, () => dispose(it)); throw e; } try { - dropIt?.(it); + dispose(it); } catch (e) { collected(); throw e; @@ -597,19 +686,15 @@ export function iterToArray(it: Iter, inPlace = false, dropIt?: Drop`. */ -export function iterToByteVec(it: Iter, dropIt?: Drop>): ByteVec { +/** `collect` into a `Vec`, taking `it` as `take` says. */ +export function iterToByteVec(it: Iter, take?: Take): ByteVec { const out = new ByteVec(); // Its own loop: through `iterExtendBytes`, JavaScriptCore took 1.9x as long. - if (dropIt === undefined) { + if (take === undefined) { for (let item = it.next(); item !== DONE; item = it.next()) byteVecPush(out, item); return out; } - try { - for (let item = it.next(); item !== DONE; item = it.next()) byteVecPush(out, item); - } finally { - dropIt?.(it); - } + each(it, (item) => byteVecPush(out, item), take); return out; } @@ -647,73 +732,61 @@ export function iterCollectOption(it: Iter, into: (values: // kind, rather than as methods every iterator would carry, and the translation calls them // only where an item or the iterator drops. -/** `Iterator::count` of an iterator that drops what it holds: each item by `drop`, as its own `count` does, and then it by `dropIt`, a panic included. */ -export function ownedCount(it: Iter, dropIt?: Drop>, drop?: Drop): number { - try { - return count(it, drop); - } finally { - dropIt?.(it); - } +/** `Iterator::count` of an iterator that drops what it holds: each item by `drop`, as its own `count` does, and then it, a panic included. */ +export function ownedCount(it: Iter, drop?: Drop): number { + return count(it, drop); } -/** `Iterator::last` of an iterator that drops what it holds: each item but the last by `drop`, as its own `last` does, and then it by `dropIt`. */ -export function ownedLast(it: Iter, dropIt?: Drop>, drop?: Drop): T | undefined { - let item: T | Done; - try { - item = last(it, drop); - } catch (e) { - dropIt?.(it); - throw e; - } - // A panic here leaks the last, as std's unwinding does a returned value. - dropIt?.(it); - return iterToOption(item); +/** `Iterator::last` of an iterator that drops what it holds: each item but the last by `drop`, as its own `last` does, and then it. */ +export function ownedLast(it: Iter, drop?: Drop): T | undefined { + return iterToOption(last(it, drop)); } -/** `count`, dropping each item by `drop`. */ +/** `count`, dropping each item by `drop`, and then `it`, as std's of its kind does. */ function count(it: Iter, drop: Drop | undefined): number { if (it instanceof EnumerateIter) return count(it.inner, items(drop)); if (it instanceof ChainIter) { // std's: each iterator's own `count`, the first's first. - const a = it.a; - it.a = undefined; - const n = a === undefined ? 0 : consumed(a, () => count(a, drop)); - const b = it.b; - it.b = undefined; - return n + (b === undefined ? 0 : consumed(b, () => count(b, drop))); + const { a, b } = it; + it.a = it.b = undefined; + let n = 0; + try { + if (a !== undefined) n = count(a, drop); + } catch (e) { + dispose(b); + throw e; + } + return n + (b === undefined ? 0 : count(b, drop)); } if (it instanceof SkipIter) { // std's: past what it skips by `nth`, and then its iterator's own `count`. - if (skipped(it, drop)) return 0; - return consumed(it.inner, () => count(it.inner, drop)); + return skipped(it, drop) ? 0 : count(it.inner, drop); } if (it instanceof TakeIter) { // std's: its iterator advanced through the limit, dropping what it passes. - if (it.n === 0) return 0; const n = it.n; it.n = 0; - return n - it.inner.advanceBy(n, drop); + return consumed(it.inner, () => (n === 0 ? 0 : n - it.inner.advanceBy(n, drop))); } if (it instanceof FuseIter) { const inner = it.inner; it.inner = undefined; - return inner === undefined ? 0 : consumed(inner, () => count(inner, drop)); + return inner === undefined ? 0 : count(inner, drop); } if (it instanceof FlattenIter) { - // std's: each iterator's own `count` in turn, each dropped once counted. - let n = 0; - flattenEach(it, (inner) => { - n += consumed(inner, () => count(inner, drop)); - }); - return n; + // std's: each iterator's own `count` in turn. + return flattenFold(it as FlattenIter, false, 0, (n, inner) => n + count(inner, drop)); } if (it instanceof Peekable) { // std's: the item it peeked drops after its iterator is counted. - if (!it.peeked) return consumed(it.inner, () => count(it.inner, drop)); + if (!it.peeked) return count(it.inner, drop); const peeked = it.take(); - if (peeked === DONE) return 0; + if (peeked === DONE) { + dispose(it.inner); + return 0; + } try { - return 1 + consumed(it.inner, () => count(it.inner, drop)); + return 1 + count(it.inner, drop); } finally { drop?.(peeked); } @@ -724,18 +797,17 @@ function count(it: Iter, drop: Drop | undefined): number { dispose(it); return n; } - let n = 0; - for (let item = it.next(); item !== DONE; item = it.next()) { + return it.fold(0, (n, item) => { drop?.(item); - n++; - } - return n; + return n + 1; + }); } /** - * `last`, as std's `fold` takes it: each item drops by `drop` as the next replaces it. - * A panic reading the next drops the last; one dropping it leaks the next, as std's - * unwinding leaves a returned value. + * `last`, dropping each item but the last by `drop`, and then `it`, as std's of its kind + * does. By `fold`, each item drops as the next replaces it. A panic reading the next + * drops the last; one dropping it leaks the next, as std's unwinding leaves a returned + * value. */ function last(it: Iter, drop: Drop | undefined): T | Done { if ((it instanceof SliceIter && drop !== undefined) || (it instanceof BTreeIter && it.back)) { @@ -749,72 +821,77 @@ function last(it: Iter, drop: Drop | undefined): T | Done { if (it instanceof ChainIter) { // std's: each iterator's last, the first's held while the second is read, and // dropped once the second has one. - const a = it.a; - it.a = undefined; - const aLast = a === undefined ? DONE : consumed(a, () => last(a, drop)); - const b = it.b; - it.b = undefined; - if (b === undefined) return aLast; - let bLast: T | Done; + const { a, b } = it; + it.a = it.b = undefined; + let aLast: T | Done = DONE; try { - bLast = consumed(b, () => last(b, drop)); + if (a !== undefined) aLast = last(a, drop); } catch (e) { - if (aLast !== DONE) drop?.(aLast); + dispose(b); throw e; } - if (bLast === DONE) return aLast; - // A panic here leaks the second's, as std's unwinding does a returned value. - if (aLast !== DONE) drop?.(aLast); - return bLast; + if (b === undefined) return aLast; + return or(() => last(b, drop), aLast, drop); } if (it instanceof SkipIter) { // std's: past what it skips by `nth`, and then its iterator's own `last`. - if (skipped(it, drop)) return DONE; - return consumed(it.inner, () => last(it.inner, drop)); + return skipped(it, drop) ? DONE : last(it.inner, drop); } if (it instanceof FuseIter) { const inner = it.inner; it.inner = undefined; - return inner === undefined ? DONE : consumed(inner, () => last(inner, drop)); + return inner === undefined ? DONE : last(inner, drop); + } + if (it instanceof FlattenIter) { + // std's: the last of each iterator in turn, the last so far dropped once a later + // one has one. + const flat = it as FlattenIter; + return flattenFold( + flat, + false, + DONE, + (prev, inner) => or(() => last(inner, drop), prev, drop), + drop && ((prev) => prev !== DONE && drop(prev)), + ); } - if (it instanceof FlattenIter) return flattenLast(it, drop); if (it instanceof Peekable) { // std's: the item it peeked, unless its iterator has a last, which drops it after. let peeked: T | Done = DONE; if (it.peeked) { peeked = it.take(); - if (peeked === DONE) return DONE; - } - let item: T | Done; - try { - item = consumed(it.inner, () => last(it.inner, drop)); - } catch (e) { - if (peeked !== DONE) drop?.(peeked); - throw e; + if (peeked === DONE) { + dispose(it.inner); + return DONE; + } } - if (item === DONE) return peeked; - // A panic here leaks the last, as std's unwinding does a returned value. - if (peeked !== DONE) drop?.(peeked); - return item; + return or(() => last(it.inner, drop), peeked, drop); } - let item: T | Done = DONE; - if (drop === undefined) { - for (let next = it.next(); next !== DONE; next = it.next()) item = next; - return item; - } - for (;;) { - let next: T | Done; - try { - next = it.next(); - } catch (e) { - if (item !== DONE) drop(item); - throw e; - } - if (next === DONE) return item; - const prev = item; - item = next; - if (prev !== DONE) drop(prev); + return it.fold( + DONE, + (prev, item) => { + if (prev !== DONE) drop?.(prev); + return item; + }, + drop && ((prev) => prev !== DONE && drop(prev)), + ); +} + +/** + * `read().or(prev)`: what `read` returns, unless that is `DONE`, and then `prev`, which + * drops by `drop` if `read` panics or returns an item. A panic dropping it leaks the item, + * as std's unwinding does a returned value. + */ +function or(read: () => T | Done, prev: T | Done, drop: Drop | undefined): T | Done { + let item: T | Done; + try { + item = read(); + } catch (e) { + if (prev !== DONE) drop?.(prev); + throw e; } + if (item === DONE) return prev; + if (prev !== DONE) drop?.(prev); + return item; } /** @@ -838,71 +915,61 @@ function items(drop: Drop | undefined): Drop | undefined { return drop === undefined ? undefined : (item) => drop([0, item] as never); } -/** Read past what `it` still skips, as `nth` reads, and whether its iterator ended first. */ +/** + * Read past what `it` still skips, as `nth` reads, and whether its iterator ended first, + * which then drops, as it does if that panics. + */ function skipped(it: SkipIter, drop: Drop | undefined): boolean { if (it.n === 0) return false; const n = it.n; it.n = 0; - const item = it.inner.nth(n - 1, drop); - if (item === DONE) return true; - drop?.(item); - return false; -} - -/** - * Run `f` on each iterator of `it` in turn, the front, each of the source's, and the back, - * as std's `fold` takes them by value; the source drops once read through. - */ -function flattenEach(it: FlattenIter, f: (inner: Iter) => void, onPanic?: () => void): void { - const front = it.front; - it.front = undefined; - if (front !== undefined) f(front); - const outer = it.outer; - it.outer = undefined; - if (outer !== undefined) { - consumed(outer, () => { - for (;;) { - let inner: T | Done; - try { - inner = outer.next(); - } catch (e) { - onPanic?.(); - throw e; - } - if (inner === DONE) return; - f(it.into(inner)); - } - }); + let item: T | Done; + try { + item = it.inner.nth(n - 1, drop); + if (item !== DONE) drop?.(item); + } catch (e) { + dispose(it.inner); + throw e; } - const back = it.back; - it.back = undefined; - if (back !== undefined) f(back); + if (item === DONE) dispose(it.inner); + return item === DONE; } /** - * `Flatten::last`, std's: the last of each iterator in turn, each dropped once read, and - * the last so far dropped once a later one has one. + * std's `iter_fold` of a flatten, or `iter_rfold` if `back`: `g` of each iterator it holds + * in turn, the front, then each of its source's by the source's own fold, and the back. + * `release` drops what `g` owns as it ends, before what it still holds. */ -function flattenLast(it: FlattenIter, drop: Drop | undefined): V | Done { - let item: V | Done = DONE; - const take = (inner: Iter): void => { - let next: V | Done; - try { - next = consumed(inner, () => last(inner, drop)); - } catch (e) { - if (item !== DONE) drop?.(item); - throw e; +function flattenFold(it: FlattenIter, back: boolean, acc: A, g: (acc: A, inner: Iter) => A, dropAcc?: Drop, release?: () => void): A { + const { outer } = it; + const [first, rest] = back ? [it.back, it.front] : [it.front, it.back]; + it.outer = it.front = it.back = undefined; + try { + if (first !== undefined) acc = g(acc, first); + } catch (e) { + release?.(); + dispose(outer); + dispose(rest); + throw e; + } + try { + if (outer !== undefined) { + const each = (acc: A, item: T) => g(acc, it.into(item)); + acc = back ? outer.rfold(acc, each, dropAcc) : outer.fold(acc, each, dropAcc); } - if (next === DONE) return; - const prev = item; - item = next; - // A panic here leaks the later one, as std's unwinding does a returned value. - if (prev !== DONE) drop?.(prev); - }; - flattenEach(it, take, () => { - if (item !== DONE) drop?.(item); - }); - return item; + } catch (e) { + ended(rest, release); + throw e; + } + try { + if (rest !== undefined) acc = g(acc, rest); + } catch (e) { + release?.(); + throw e; + } + // A panic here leaks the accumulator, as std's unwinding does a returned value. + release?.(); + return acc; } // Iterators. One has `[Symbol.dispose]` if it owns items or wraps an iterator: what holds @@ -1154,6 +1221,30 @@ class MapIter extends Calling U> { override len(): number { return this.inner.len(); } + + /** std's: `inner`'s, by a closure that drops `release`'s and then `f`. */ + override fold(acc: A, g: (acc: A, item: U) => A, dropAcc?: Drop, release?: () => void): A { + return this.inner.fold(acc, mapFold(this.f, g, dropAcc), dropAcc, then(release, this.take())); + } + + override rfold(acc: A, g: (acc: A, item: U) => A, dropAcc?: Drop, release?: () => void): A { + return this.inner.rfold(acc, mapFold(this.f, g, dropAcc), dropAcc, then(release, this.take())); + } +} + +/** std's `map_fold`: `g` of what `f` makes of each item, the accumulator dropped if `f` panics. */ +function mapFold(f: (item: T) => U, g: (acc: A, item: U) => A, dropAcc?: Drop): (acc: A, item: T) => A { + if (dropAcc === undefined) return (acc, item) => g(acc, f(item)); + return (acc, item) => { + let mapped: U; + try { + mapped = f(item); + } catch (e) { + dropAcc(acc); + throw e; + } + return g(acc, mapped); + }; } /** `Copied` of items JS copies by a function: a `map` whose `nth` and `advance_by` are its iterator's. */ @@ -1187,6 +1278,33 @@ class FilterIter extends Calling boolean> { override nextBack(): T | Done { return rfindItem(this.inner, this.f, this.drop); } + + /** std's: `inner`'s, by a closure that drops `f` and then `release`'s. */ + override fold(acc: A, g: (acc: A, item: T) => A, dropAcc?: Drop, release?: () => void): A { + return this.inner.fold(acc, this.filterFold(g, dropAcc), dropAcc, then(this.take(), release)); + } + + override rfold(acc: A, g: (acc: A, item: T) => A, dropAcc?: Drop, release?: () => void): A { + return this.inner.rfold(acc, this.filterFold(g, dropAcc), dropAcc, then(this.take(), release)); + } + + /** std's `filter_fold`: `g` of each item `f` keeps. One `f` panics on drops, then the accumulator. */ + private filterFold(g: (acc: A, item: T) => A, dropAcc?: Drop): (acc: A, item: T) => A { + const { f, drop } = this; + return (acc, item) => { + let keep: boolean; + try { + keep = f(item); + } catch (e) { + drop?.(item); + dropAcc?.(acc); + throw e; + } + if (keep) return g(acc, item); + drop?.(item); + return acc; + }; + } } class FilterMapIter extends Calling U | undefined> { @@ -1210,6 +1328,21 @@ class FilterMapIter extends Calling U | undefined> { } return DONE; } + + /** std's: `inner`'s, by a closure that drops `f` and then `release`'s. */ + override fold(acc: A, g: (acc: A, item: U) => A, dropAcc?: Drop, release?: () => void): A { + return this.inner.fold(acc, this.filterMapFold(g, dropAcc), dropAcc, then(this.take(), release)); + } + + override rfold(acc: A, g: (acc: A, item: U) => A, dropAcc?: Drop, release?: () => void): A { + return this.inner.rfold(acc, this.filterMapFold(g, dropAcc), dropAcc, then(this.take(), release)); + } + + /** std's `filter_map_fold`: `g` of each value `f` makes, the accumulator dropped if `f` panics. */ + private filterMapFold(g: (acc: A, item: U) => A, dropAcc?: Drop): (acc: A, item: T) => A { + const f = this.f; + return mapFold(f, (acc, mapped: U | undefined) => (mapped === undefined ? acc : g(acc, mapped)), dropAcc); + } } class EnumerateIter extends Adaptor { @@ -1253,6 +1386,16 @@ class EnumerateIter extends Adaptor { const item = this.inner.nthBack(n, items(drop)); return item === DONE ? DONE : [this.index + this.inner.len(), item]; } + + override fold(acc: A, g: (acc: A, item: [number, T]) => A, dropAcc?: Drop, release?: () => void): A { + let i = this.index; + return this.inner.fold(acc, (acc, item) => g(acc, [i++, item]), dropAcc, release); + } + + override rfold(acc: A, g: (acc: A, item: [number, T]) => A, dropAcc?: Drop, release?: () => void): A { + let i = this.index + this.inner.len(); + return this.inner.rfold(acc, (acc, item) => g(acc, [--i, item]), dropAcc, release); + } } /** @@ -1349,6 +1492,40 @@ class ChainIter extends Iter implements Disposable { } return this.a === undefined ? DONE : this.a.nthBack(n, drop); } + + /** std's: the first's fold and then the second's, which drops `release`'s as it ends. */ + override fold(acc: A, f: (acc: A, item: T) => A, dropAcc?: Drop, release?: () => void): A { + const { a, b } = this; + this.a = this.b = undefined; + if (a !== undefined) { + try { + acc = a.fold(acc, f, dropAcc); + } catch (e) { + ended(b, release); + throw e; + } + } + if (b !== undefined) return b.fold(acc, f, dropAcc, release); + // A panic here leaks the accumulator, as std's unwinding does a returned value. + release?.(); + return acc; + } + + override rfold(acc: A, f: (acc: A, item: T) => A, dropAcc?: Drop, release?: () => void): A { + const { a, b } = this; + this.a = this.b = undefined; + if (b !== undefined) { + try { + acc = b.rfold(acc, f, dropAcc); + } catch (e) { + ended(a, release); + throw e; + } + } + if (a !== undefined) return a.rfold(acc, f, dropAcc, release); + release?.(); + return acc; + } } class ZipIter extends Iter<[A, B]> implements Disposable { @@ -1473,6 +1650,14 @@ class RevIter extends Adaptor { override nthBack(n: number, drop?: Drop): T | Done { return this.inner.nth(n, drop); } + + override fold(acc: A, f: (acc: A, item: T) => A, dropAcc?: Drop, release?: () => void): A { + return this.inner.rfold(acc, f, dropAcc, release); + } + + override rfold(acc: A, f: (acc: A, item: T) => A, dropAcc?: Drop, release?: () => void): A { + return this.inner.fold(acc, f, dropAcc, release); + } } /** `Skip`, whose items drop by `drop` as its iterator's own `nth` skips them. */ @@ -1534,6 +1719,25 @@ class SkipIter extends Adaptor { return this.inner.nth(n, drop); } + /** std's: past what it skips by `nth`, and then its iterator's own. */ + override fold(acc: A, f: (acc: A, item: T) => A, dropAcc?: Drop, release?: () => void): A { + if (this.n > 0) { + let item: T | Done; + try { + item = this.inner.nth(this.n - 1, this.drop); + if (item !== DONE) this.drop?.(item); + } catch (e) { + unwound(this.inner, acc, dropAcc, release); + throw e; + } + if (item === DONE) { + ended(this.inner, release); + return acc; + } + } + return this.inner.fold(acc, f, dropAcc, release); + } + /** std's: past what it doesn't skip, its iterator read from the back through what it does. */ override nthBack(n: number, drop?: Drop): T | Done { const len = this.len(); @@ -1603,6 +1807,26 @@ class TakeIter extends Adaptor { return DONE; } + /** std's: past what its iterator holds beyond the limit by `nth_back`, and then its iterator's own. */ + override rfold(acc: A, f: (acc: A, item: T) => A, dropAcc?: Drop, release?: () => void): A { + const len = this.n === 0 ? 0 : this.inner.len(); + if (this.n === 0 || len > this.n) { + let item: T | Done = DONE; + try { + if (this.n > 0) item = this.inner.nthBack(len - this.n - 1, this.drop); + if (item !== DONE) this.drop?.(item); + } catch (e) { + unwound(this.inner, acc, dropAcc, release); + throw e; + } + if (item === DONE) { + ended(this.inner, release); + return acc; + } + } + return this.inner.rfold(acc, f, dropAcc, release); + } + /** std's: past the limit, it reads the whole rest from the back, even at a limit of 0. */ override nthBack(n: number, drop?: Drop): T | Done { const len = this.inner.len(); @@ -1641,6 +1865,25 @@ class SkipWhileIter extends Calling boolean> { this.drop, ); } + + /** std's: its first item by `next`, and then its iterator's fold, after which `f` drops. */ + override fold(acc: A, f: (acc: A, item: T) => A, dropAcc?: Drop, release?: () => void): A { + if (!this.flag) { + let done: boolean; + [done, acc] = foldFirst(this, () => this.next(), acc, f, dropAcc, release); + if (done) return acc; + } + const pred = this.take(); + try { + acc = this.inner.fold(acc, f, dropAcc, release); + } catch (e) { + pred(); + throw e; + } + // A panic here leaks the accumulator, as std's unwinding does a returned value. + pred(); + return acc; + } } class TakeWhileIter extends Calling boolean> { @@ -1752,6 +1995,34 @@ class StepByIter extends Adaptor { const steps = Math.min(n * (this.step + 1), USIZE_MAX); return this.inner.nthBack(Math.min(steps + this.backIndex(), USIZE_MAX), drop); } + + /** std's: the first item by `next`, then each step by `nth`, as `next` reads past it. */ + override fold(acc: A, f: (acc: A, item: T) => A, dropAcc?: Drop, release?: () => void): A { + if (this.firstTake) { + this.firstTake = false; + let done: boolean; + [done, acc] = foldFirst(this.inner, () => this.inner.next(), acc, f, dropAcc, release); + if (done) return acc; + } + return foldBy(this, false, acc, f, dropAcc, release); + } + + /** std's: the last item by `next_back`, then each step back by `nth_back`. */ + override rfold(acc: A, f: (acc: A, item: T) => A, dropAcc?: Drop, release?: () => void): A { + let done: boolean; + [done, acc] = foldFirst(this.inner, () => this.nextBack(), acc, f, dropAcc, release); + if (done) return acc; + const steps = new FromNext(this.inner, (inner) => inner.nthBack(this.step, this.drop)); + try { + acc = foldBy(steps, false, acc, f, dropAcc, release); + } catch (e) { + dispose(this.inner); + throw e; + } + // A panic here leaks the accumulator, as std's unwinding does a returned value. + dispose(this.inner); + return acc; + } } class InspectIter extends Calling void> { @@ -1781,6 +2052,30 @@ class InspectIter extends Calling void> { override len(): number { return this.inner.len(); } + + /** std's: `inner`'s, by a closure that drops `f` and then `release`'s. */ + override fold(acc: A, g: (acc: A, item: T) => A, dropAcc?: Drop, release?: () => void): A { + return this.inner.fold(acc, this.inspectFold(g, dropAcc), dropAcc, then(this.take(), release)); + } + + override rfold(acc: A, g: (acc: A, item: T) => A, dropAcc?: Drop, release?: () => void): A { + return this.inner.rfold(acc, this.inspectFold(g, dropAcc), dropAcc, then(this.take(), release)); + } + + /** std's `inspect_fold`: `f` of each item, then `g`. One `f` panics on drops, then the accumulator. */ + private inspectFold(g: (acc: A, item: T) => A, dropAcc?: Drop): (acc: A, item: T) => A { + const { f, drop } = this; + return (acc, item) => { + try { + f(item); + } catch (e) { + drop?.(item); + dropAcc?.(acc); + throw e; + } + return g(acc, item); + }; + } } class FuseIter extends Iter implements Disposable { @@ -1829,6 +2124,23 @@ class FuseIter extends Iter implements Disposable { override nthBack(n: number, drop?: Drop): T | Done { return this.inner === undefined ? DONE : this.clear(this.inner.nthBack(n, drop)); } + + override fold(acc: A, f: (acc: A, item: T) => A, dropAcc?: Drop, release?: () => void): A { + const inner = this.inner; + this.inner = undefined; + if (inner !== undefined) return inner.fold(acc, f, dropAcc, release); + // A panic here leaks the accumulator, as std's unwinding does a returned value. + release?.(); + return acc; + } + + override rfold(acc: A, f: (acc: A, item: T) => A, dropAcc?: Drop, release?: () => void): A { + const inner = this.inner; + this.inner = undefined; + if (inner !== undefined) return inner.rfold(acc, f, dropAcc, release); + release?.(); + return acc; + } } /** @@ -1934,6 +2246,14 @@ class FlattenIter extends Iter implements Disposable { ); } + override fold(acc: A, f: (acc: A, item: V) => A, dropAcc?: Drop, release?: () => void): A { + return flattenFold(this, false, acc, (acc, inner) => inner.fold(acc, f, dropAcc), dropAcc, release); + } + + override rfold(acc: A, f: (acc: A, item: V) => A, dropAcc?: Drop, release?: () => void): A { + return flattenFold(this, true, acc, (acc, inner) => inner.rfold(acc, f, dropAcc), dropAcc, release); + } + /** * std's, by `try_fold`: each iterator in turn advanced by its own `advance_by`, one * that falls short dropped only as the next replaces it, and the source dropped once @@ -2046,6 +2366,42 @@ export class Peekable extends Adaptor { ); } + /** std's: the item it peeked, and then its iterator's fold. */ + override fold(acc: A, f: (acc: A, item: T) => A, dropAcc?: Drop, release?: () => void): A { + if (this.peeked) { + let done: boolean; + [done, acc] = foldFirst(this.inner, () => this.take(), acc, f, dropAcc, release); + if (done) return acc; + } + return this.inner.fold(acc, f, dropAcc, release); + } + + /** std's: its iterator's from the back, and then the item it peeked, which drops if that panics. */ + override rfold(acc: A, f: (acc: A, item: T) => A, dropAcc?: Drop, release?: () => void): A { + if (!this.peeked) return this.inner.rfold(acc, f, dropAcc, release); + const peeked = this.take(); + if (peeked === DONE) { + ended(this.inner, release); + return acc; + } + try { + acc = this.inner.rfold(acc, f, dropAcc); + } catch (e) { + this.drop?.(peeked); + release?.(); + throw e; + } + try { + acc = f(acc, peeked); + } catch (e) { + release?.(); + throw e; + } + // A panic here leaks the accumulator, as std's unwinding does a returned value. + release?.(); + return acc; + } + /** std's: the item it peeked drops after what its iterator skips. */ override nth(n: number, drop?: Drop): T | Done { if (!this.peeked) return this.inner.nth(n, drop); diff --git a/ts/runtime/rt/time.ts b/ts/runtime/rt/time.ts index 6d3718f11..a5bc08c49 100644 --- a/ts/runtime/rt/time.ts +++ b/ts/runtime/rt/time.ts @@ -306,7 +306,7 @@ export function durationDiv(d: Duration, n: u32): Duration { * into them only when it would overflow and at the end, each overflow past `u64::MAX` * seconds a panic. */ -export function durationSum(it: Iter, dropIt?: (it: Iter) => void): Duration { +export function durationSum(it: Iter, drops = false): Duration { const overflow = "sum over duration iterator should not overflow u64::MAX"; let secs = 0 as u64; let nanos = 0 as u64; @@ -323,7 +323,7 @@ export function durationSum(it: Iter, dropIt?: (it: Iter) => nanos = (u64Rem(nanos, NANOS_PER_SEC) as number) + d.nanos; } }, - dropIt, + drops, ); secs = u64CheckedAdd(secs, u64Div(nanos, NANOS_PER_SEC)) ?? panic(overflow); return { secs, nanos: u64Rem(nanos, NANOS_PER_SEC) as number }; diff --git a/ts/src/lower/collections.rs b/ts/src/lower/collections.rs index 35bcdb9f4..103e7892f 100644 --- a/ts/src/lower/collections.rs +++ b/ts/src/lower/collections.rs @@ -456,7 +456,8 @@ fn hash_extend<'tcx>( span: Span, ) -> Expr { let mut droppers = entry_droppers(b, coll, span); - droppers.push(super::iter::iter_dropper(b, iter, span)); + // By `for_each`. + droppers.push(super::iter::iter_take(b, iter, true, span)); droppers.push(Expr::lit(if fresh && b.t.drops(coll) { "true" } else { "false" })); let f = match b.t.std_of(coll) { Some(Std::HashSet) => "hashExtendKeys", @@ -693,7 +694,8 @@ fn btree<'tcx>( let (source, iter) = extend_source(b, coll, call, owner, values.pop()?)?; let mut droppers = vec![Expr::lit("false")]; droppers.extend(entry_droppers(b, coll, span)); - droppers.push(super::iter::iter_dropper(b, iter, span)); + // By `for_each`. + droppers.push(super::iter::iter_take(b, iter, true, span)); let target = values.pop()?; let f = if set { "btreeExtendKeys" } else { "btreeExtend" }; Expr::rt(f, super::iter::tail(vec![target, source], droppers)) @@ -720,7 +722,9 @@ fn btree_collect<'tcx>(b: &mut Body<'_, '_, 'tcx>, coll: Ty<'tcx>, source: Expr, if !set { droppers.push(Expr::undefined()); } - droppers.push(super::iter::iter_dropper(b, iter, span)); + // Into a `Vec` first. + let folds = super::iter::implements(b.t, iter, "TrustedLen"); + droppers.push(super::iter::iter_take(b, iter, folds, span)); let f = if set { "btreeExtendKeys" } else { "btreeExtend" }; return Expr::rt(f, super::iter::tail(vec![target, source], droppers)); } @@ -849,8 +853,10 @@ fn deque<'tcx>( "From" => deque_new(b, coll, span), _ => values.pop()?, }; - let dropper = super::iter::iter_dropper(b, iter, span); - Expr::rt("dequeExtend", super::iter::tail(vec![target, source], vec![dropper])) + // Of a `TrustedLen` iterator, by `for_each`. + let folds = super::iter::implements(b.t, iter, "TrustedLen"); + let take = super::iter::iter_take(b, iter, folds, span); + Expr::rt("dequeExtend", super::iter::tail(vec![target, source], vec![take])) } _ => return None, }; @@ -869,8 +875,6 @@ fn extend_source<'tcx>( // `Extend::extend::` and `From::from`. let ty = library::targ(call.args, if owner == "Extend" { 2 } else { 1 }); let iter = super::iter::iter_of(b.t, ty)?; - // Each but a `Vec`'s, by `for_each`. - super::iter::folds(b, iter, owner, call.span); let Some(items) = super::iter::into_iter(b, ty, source, call.span) else { return Some(( b.err(call.span, format!("`{owner}` from `{ty}`, which is not supported yet")), @@ -1289,8 +1293,9 @@ pub fn collect<'tcx>(b: &mut Body<'_, '_, 'tcx>, ty: Ty<'tcx>, iter: Expr, from: let target = deque_new(b, ty, span); let item = arg(ty, 0); if !b.t.drops(item) { - let dropper = super::iter::iter_dropper(b, from, span); - Expr::rt("dequeExtend", super::iter::tail(vec![target, iter], vec![dropper])) + let folds = super::iter::implements(b.t, from, "TrustedLen"); + let take = super::iter::iter_take(b, from, folds, span); + Expr::rt("dequeExtend", super::iter::tail(vec![target, iter], vec![take])) } else { let items = super::iter::to_array(b, iter, from, item, span); Expr::rt("dequeExtend", vec![target, Expr::rt("iterSlice", vec![items])]) diff --git a/ts/src/lower/iter.rs b/ts/src/lower/iter.rs index 4616453f5..320cbd350 100644 --- a/ts/src/lower/iter.rs +++ b/ts/src/lower/iter.rs @@ -310,10 +310,6 @@ pub fn call<'tcx>( } let [v, items] = <[Expr; 2]>::try_from(args).ok()?; let iter = iter_of(b.t, source)?; - // Of a `TrustedLen` iterator, by `for_each`. - if implements(b.t, iter, "TrustedLen") { - folds(b, iter, "extend", span); - } let mut items = into_iter(b, source, items, span)?; // `Extend<&T>` copies each element. if item != vec_args.type_at(0) @@ -325,8 +321,9 @@ pub fn call<'tcx>( ty::Uint(ty::UintTy::U8) => "iterExtendBytes", _ => "iterExtend", }; - let dropper = iter_dropper(b, iter, span); - return Some(Expr::rt(extend, tail(vec![v, items], vec![dropper]))); + // Of a `TrustedLen` iterator, by `for_each`. + let take = iter_take(b, iter, implements(b.t, iter, "TrustedLen"), span); + return Some(Expr::rt(extend, tail(vec![v, items], vec![take]))); } let self_ty = match (owner, name) { @@ -371,19 +368,15 @@ pub fn call<'tcx>( }; Some(Expr::rt_of(of, name).call([vec![recv.clone()], args].concat())) }; - // `rt.owned`, which drops by `droppers` as std's own does, where any drops: else - // `rt.iter`, so a bundle that never drops doesn't carry it. - let owned = |name: &str, args: Vec, droppers: Vec| match droppers.iter().all(undefined) { - true => method(name, args), - false => Some(Expr::rt_of("owned", name).call([vec![recv.clone()], args, tail(Vec::new(), droppers)].concat())), + // `rt.owned`, which drops what `self_ty` holds and its items by `dropper` as std's + // own does, where either drops: else `rt.iter`, so a bundle that never drops + // doesn't carry it. + let owned = |b: &mut Body<'_, '_, 'tcx>, name: &str, dropper: Expr| match drops_iter(b, self_ty, span) + || !undefined(&dropper) + { + true => Some(Expr::rt_of("owned", name).call(tail(vec![recv.clone()], vec![dropper]))), + false => method(name, Vec::new()), }; - // Each consumer that takes the iterator by value drops it, by `fold` but for `nth`'s. - if matches!( - name, - "count" | "last" | "fold" | "for_each" | "sum" | "product" | "max" | "min" | "max_by_key" | "min_by_key" - ) { - folds(b, self_ty, name, span); - } let camel = super::camel(name); match name { "map" | "filter_map" | "enumerate" | "rev" | "map_while" | "any" | "all" | "find_map" | "position" => { @@ -398,20 +391,20 @@ pub fn call<'tcx>( let fused = fused(b, self_ty, None); method(name, tail(rest, vec![fused])) } - "count" => { - let droppers = vec![iter_dropper(b, self_ty, span), b.t.dropper(item, span)]; - owned(name, rest, droppers) + "count" | "last" => { + let dropper = b.t.dropper(item, span); + owned(b, name, dropper) } "for_each" => { - let dropper = iter_dropper(b, self_ty, span); - method(&camel, tail(rest, vec![dropper])) + let drops = iter_drops(b, self_ty, span); + method(&camel, tail(rest, vec![drops])) } // std's `Sum` and `Product` are of the type or a reference to it: another is the crate's. "sum" | "product" if item.peel_refs() != targ(1)? => None, // `Duration`'s carries its nanoseconds and panics as std's does, not as `+` would. "sum" if b.t.std_of(targ(1)?) == Some(Std::Duration) => { - let dropper = iter_dropper(b, self_ty, span); - Some(Expr::rt("durationSum", tail(vec![recv.clone()], vec![dropper]))) + let drops = iter_drops(b, self_ty, span); + Some(Expr::rt("durationSum", tail(vec![recv.clone()], vec![drops]))) } // std's float sum starts from -0.0, so a sum of none, or of -0.0s, is -0.0. "sum" | "product" if super::float::is(targ(1)?) => { @@ -419,10 +412,10 @@ pub fn call<'tcx>( "sum" => ("add", -0.0), _ => ("mul", 1.0), }; - let dropper = iter_dropper(b, self_ty, span); + let drops = iter_drops(b, self_ty, span); method( name, - tail(vec![Expr::rt_of("f64", op), super::float::lit(unit)], vec![dropper]), + tail(vec![Expr::rt_of("f64", op), super::float::lit(unit)], vec![drops]), ) } "sum" | "product" => { @@ -431,20 +424,16 @@ pub fn call<'tcx>( "sum" => ("add", 0), _ => ("mul", 1), }; - let dropper = iter_dropper(b, self_ty, span); - method(name, tail(vec![int.func(op), int.lit(unit)], vec![dropper])) + let drops = iter_drops(b, self_ty, span); + method(name, tail(vec![int.func(op), int.lit(unit)], vec![drops])) } // `fold::`, whose accumulator drops if reading an item panics. "fold" => { - let droppers = vec![iter_dropper(b, self_ty, span), b.t.dropper(targ(1)?, span)]; + let droppers = vec![iter_drops(b, self_ty, span), b.t.dropper(targ(1)?, span)]; method(name, tail(rest, droppers)) } // `ExactSizeIterator::len` is each iterator's own. "len" => Some(recv.member("len").call(rest)), - "last" => { - let droppers = vec![iter_dropper(b, self_ty, span), b.t.dropper(item, span)]; - owned(name, rest, droppers) - } "nth" => { let dropper = b.t.dropper(item, span); method(name, tail(rest, vec![dropper])) @@ -467,11 +456,11 @@ pub fn call<'tcx>( format!("`{name}` of `{self_ty}`, which drops its values, which is not supported yet"), )); } - let dropper = iter_dropper(b, self_ty, span); - method(name, tail(rest, vec![dropper])) + let drops = iter_drops(b, self_ty, span); + method(name, tail(rest, vec![drops])) } "max_by_key" | "min_by_key" if primitive(targ(1)?) => { - let droppers = vec![iter_dropper(b, self_ty, span), b.t.dropper(item, span)]; + let droppers = vec![iter_drops(b, self_ty, span), b.t.dropper(item, span)]; method(&camel, tail(rest, droppers)) } "chain" => { @@ -638,87 +627,6 @@ 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. 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()) - .filter(|&t| { - std_iter_path(tcx, t).is_some_and(|p| { - p.len() == 4 - && p[..3] == ["iter", "adapters", "flatten"] - && matches!(p[3].as_str(), "Flatten" | "FlatMap") - }) - }) - .collect(); - for t in flattens { - let ty::Adt(_, args) = t.kind() else { - continue; - }; - let outer = args.type_at(0); - // `Flatten` of `I::Item`s, or `FlatMap` of `U`s by `F`. - let (outer_drops, inner) = match args.types().count() { - 1 => (b.t.drops(outer), b.t.iter_item(outer).and_then(|i| iter_of(b.t, i))), - _ => ( - b.t.drops(outer) || b.t.drops(args.type_at(2)), - iter_of(b.t, args.type_at(1)), - ), - }; - if outer_drops && inner.is_some_and(|i| b.t.drops(i)) { - b.t.err( - span, - format!( - "`{name}` of `{ty}`, which folds a `flatten` whose source and iterators both drop, which is not supported yet" - ), - ); - return; - } - } -} - -/// 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. @@ -792,15 +700,11 @@ fn collect<'tcx>( return None; }; let std = Std::of(tcx, adt.did())?; - // Into a `Vec` of a `TrustedLen` iterator, and into any other collection, by `for_each`. - if !matches!(std, Std::Result | Std::Option) && (std != Std::Vec || implements(b.t, from, "TrustedLen")) { - folds(b, from, "collect", span); - } match std { Std::Vec => Some(match args.type_at(0).kind() { ty::Uint(ty::UintTy::U8) => { - let dropper = iter_dropper(b, from, span); - Expr::rt("iterToByteVec", tail(vec![iter], vec![dropper])) + let take = iter_take(b, from, implements(b.t, from, "TrustedLen"), span); + Expr::rt("iterToByteVec", tail(vec![iter], vec![take])) } _ => to_array(b, iter, from, args.type_at(0), span), }), @@ -839,17 +743,36 @@ fn collect<'tcx>( } } -/// What drops an iterator of type `ty` that a runtime function takes by value: `rt.drop`, -/// since each is an `rt.Iter`, or `undefined` for one that drops nothing. -pub(super) fn iter_dropper<'tcx>(b: &mut Body<'_, '_, 'tcx>, ty: Ty<'tcx>, span: Span) -> Expr { +/// Whether an iterator of type `ty` that a runtime function takes by value drops what it +/// holds, which its `rt.Iter` drops as std's does: `true`, or `undefined` for one that +/// drops nothing. +pub(super) fn iter_drops<'tcx>(b: &mut Body<'_, '_, 'tcx>, ty: Ty<'tcx>, span: Span) -> Expr { + match drops_iter(b, ty, span) { + true => Expr::lit("true"), + false => Expr::undefined(), + } +} + +/// How a runtime function takes an iterator of type `ty` by value, as `rt.Take` says: by its +/// own `fold` where std's `folds` it, else by `next`, or `undefined` for one that drops +/// nothing. +pub(super) fn iter_take<'tcx>(b: &mut Body<'_, '_, 'tcx>, ty: Ty<'tcx>, folds: bool, span: Span) -> Expr { + match drops_iter(b, ty, span) { + true => Expr::Str(if folds { "fold" } else { "next" }.into()), + false => Expr::undefined(), + } +} + +/// Whether an iterator of type `ty` drops, refusing one it can't drop: the crate's own +/// drops through `rt.iterFrom`. +fn drops_iter<'tcx>(b: &mut Body<'_, '_, 'tcx>, ty: Ty<'tcx>, span: Span) -> bool { if !b.t.drops(ty) { - return Expr::undefined(); + return false; } - // The crate's own drops through `rt.iterFrom`; any other refuses one it can't drop. if own_next(b, ty).is_none() { b.t.dropper(ty, span); } - Expr::Rt("drop".into()) + true } /// `rt.iterToArray` of `iter`, an iterator of type `from`, collected into a `Vec` as @@ -861,19 +784,20 @@ pub(super) fn to_array<'tcx>( elem: Ty<'tcx>, span: Span, ) -> Expr { - let drop_it = iter_dropper(b, from, span); + let take = iter_take(b, from, implements(b.t, from, "TrustedLen"), span); let drop_elem = b.t.dropper(elem, span); - let drops = !matches!(&drop_it, Expr::Lit(l) if l == "undefined") - || !matches!(&drop_elem, Expr::Lit(l) if l == "undefined"); - let in_place = drops && in_place(b.t, from, elem); + let in_place = (!undefined(&take) || !undefined(&drop_elem)) && in_place(b.t, from, elem); if in_place && let Some(zip) = zip_holding(b, from) { return b.err( span, format!("a `collect` in place of `{zip}`, whose second iterator drops, which is not supported yet"), ); } - let droppers = vec![Expr::lit(if in_place { "true" } else { "false" }), drop_it, drop_elem]; - Expr::rt("iterToArray", tail(vec![iter], droppers)) + let take = match in_place { + true => Expr::Str("place".into()), + false => take, + }; + Expr::rt("iterToArray", tail(vec![iter], vec![take, drop_elem])) } /// A `Zip` in `ty` whose second iterator drops, which std's `collect` in place drops after diff --git a/ts/tests/task.ts b/ts/tests/task.ts index 1cde43b45..fb21e5750 100644 --- a/ts/tests/task.ts +++ b/ts/tests/task.ts @@ -52,6 +52,8 @@ export interface Fixture { edited(log: Log, id: number, at: number): void; dyns(log: Log, id: number, arg: number): void; cells(log: Log, id: number, at: number): void; + folded(log: Log, id: number, arg: number): void; + rfolded(log: Log, id: number, arg: number): void; }; futures: { helpers(rx: Consumer, guard: Guard): Future; @@ -289,6 +291,8 @@ export const steps: [string, (r: Run, arg: number) => void][] = [ ], ["dyns", (r, arg) => r.f.drops.dyns(r.log, 1000 * r.exec.tasks.length, arg)], ["cells", (r, arg) => r.f.drops.cells(r.log, 1000 * r.exec.tasks.length, arg)], + ["folded", (r, arg) => r.f.drops.folded(r.log, 1000 * r.exec.tasks.length, arg)], + ["rfolded", (r, arg) => r.f.drops.rfolded(r.log, 1000 * r.exec.tasks.length, arg)], ]; /** @@ -377,4 +381,7 @@ export const cases: Uint8Array[] = [ ...Array.from({ length: 12 }, (_, arg) => script(["dyns", arg])), // What one-time cells drop, for every argument, which picks the scenario. ...Array.from({ length: 256 }, (_, at) => script(["cells", at])), + // Each scenario of adaptors' closures that drop, folded either way, panicking at each item or none. + ...Array.from({ length: 256 }, (_, arg) => script(["folded", arg])), + ...Array.from({ length: 72 }, (_, arg) => script(["rfolded", arg])), ];