diff --git a/quest/m3/README.md b/quest/m3/README.md index 845f5374f..fcdb6f56f 100644 --- a/quest/m3/README.md +++ b/quest/m3/README.md @@ -26,5 +26,5 @@ generic std gap is planned here even when moq never calls it. - [Binding gaps](/quest/m3/ts-bind-gaps.md) - bound types as keys, unit returns checked, renamed dependencies - [Drop order in std's folds and iterators](/quest/m3/ts-drop-order.md) - the values that drop still refused in std's folds, zips, flattens, and collects drop as std's do - [Slice windows and chunks, Vec drain, and the order of byte arrays](/quest/m3/ts-slice-gaps.md) - `windows`, `chunks`, `Vec::drain`, and byte arrays' order translate -- [Return a std iterator's next from a generic function](/quest/m3/ts-next-return.md) - `it.next()` returned from a generic function is an `Option`, as `tsc` expects +- [Iterator consumers over items whose None is rt.None](/quest/m3/ts-option-items.md) - `nth`, `last`, and `find` of an iterator of `Option` keep `None` apart from `Some(None)` - [Port the workflow guard to kixelated/quest](/quest/m3/quest-workflow-guard.md) - quest's environment guard parses YAML as this repository's does diff --git a/quest/m3/ts-next-return.md b/quest/m3/ts-next-return.md deleted file mode 100644 index 8fe098f83..000000000 --- a/quest/m3/ts-next-return.md +++ /dev/null @@ -1,15 +0,0 @@ -# [S] Return a std iterator's next from a generic function - -## Goal - -rust2-ts translates a generic function that returns `next` of a std iterator it was given, -`fn first>(mut it: I) -> Option { it.next() }` with `I` a -`Copied>`, proven by a differential test against native Rust. - -## Plan - -Found while testing `&mut &mut I` on 2026-10-29: the translation is `return it.next();`, -the protocol's item or `rt.DONE` rather than the `Option` the signature declares, so `tsc` -refuses it. A `next` read into a local first, as `it.next().unwrap_or(0)`, converts. - -Public API: the translator's output. diff --git a/quest/m3/ts-option-items.md b/quest/m3/ts-option-items.md new file mode 100644 index 000000000..1cfa9fada --- /dev/null +++ b/quest/m3/ts-option-items.md @@ -0,0 +1,17 @@ +# [S] Iterator consumers over items whose None is rt.None + +## Goal + +`nth`, `last`, `find`, `max`, `min`, and std's other iterator consumers that return an +`Option` of the item translate over an iterator whose item's `None` is `rt.None`, such as +`Option`, keeping `None` apart from `Some(None)`, proven by a differential test against +native Rust. + +## Plan + +Found while fixing a returned `next` on 2026-10-30: `it.nth(n)` and `it.last()` of an +iterator of `Option` are refused at their span, as `src/lower/library.rs`'s +`takes_none` lists only `next`, `next_back`, and `nth_back` among iterator methods. +Each runtime consumer needs the item's `None` passed in, as `rt.iterToOption` takes it. + +Public API: the translator's output. diff --git a/ts/fixtures/lang/expected/core/option.ts b/ts/fixtures/lang/expected/core/option.ts index 8d3ac7730..8373765c1 100644 --- a/ts/fixtures/lang/expected/core/option.ts +++ b/ts/fixtures/lang/expected/core/option.ts @@ -564,6 +564,13 @@ export function mapOr$Option_Vec_u8_u8_library_closure5(self: rt.ByteVec | undef return f(self); } +export function mapOr$Option_char_u32_from(self: rt.char | undefined, default_: rt.u32, _: (a0: rt.char) => rt.u32): rt.u32 { + if (self === undefined) { + return default_; + } + return self as rt.u32; +} + export function mapOr$Option_u16_u16_edits_closure21(self: rt.u16 | undefined, default_: rt.u16, f: (a0: rt.u16) => rt.u16): rt.u16 { if (self === undefined) { return default_; diff --git a/ts/fixtures/lang/expected/core/result.ts b/ts/fixtures/lang/expected/core/result.ts index 3773d001a..2580eb80e 100644 --- a/ts/fixtures/lang/expected/core/result.ts +++ b/ts/fixtures/lang/expected/core/result.ts @@ -207,6 +207,13 @@ export function unwrapOr$Result_isize_isize(self: rt.Result, return default_; } +export function unwrapOr$Result_str_Utf8Error(self: rt.Result, default_: string): string { + if (self.ok) { + return self.value; + } + return default_; +} + export function unwrapOr$Result_u16_TryFromIntError(self: rt.Result, default_: rt.u16): rt.u16 { if (self.ok) { return self.value; diff --git a/ts/fixtures/lang/expected/harness.ts b/ts/fixtures/lang/expected/harness.ts index 238dafc31..99af56220 100644 --- a/ts/fixtures/lang/expected/harness.ts +++ b/ts/fixtures/lang/expected/harness.ts @@ -22,7 +22,7 @@ import { ints, strings, derived, written, counts, rounding, panics, wrapped } fr import { methods } from "./generics.ts"; import { holds } from "./holds.ts"; import { u8Op, u16Op, u32Op, u64Op, u128Op, usizeOp, i8Op, i16Op, i32Op, i64Op, i128Op, isizeOp, i8Neg, i16Neg, i32Neg, i64Neg, i128Neg, isizeNeg, cast as ints_cast, convert } from "./ints.ts"; -import { adaptors, consumers, skips, ranked, ranges, options, own, values } from "./iters.ts"; +import { adaptors, consumers, skips, ranked, ranges, options, own, values, returned } from "./iters.ts"; import { keys, overrides } from "./keys.ts"; import { locals } from "./locals.ts"; import { locks, relock, rwlocks } from "./locks.ts"; @@ -153,6 +153,8 @@ export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) copies(data53, out54); }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["statics::cells", (_2154: rt.u8, data54: rt.ByteSlice, out55: rt.ByteVec): void => { statics_cells(data54, out55); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["iters::returned", (_2155: rt.u8, data55: rt.ByteSlice, out56: rt.ByteVec): void => { + returned(data55, out56); }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void]]).map(copy$str_forabfnu8au8bmutstdvecVecu8); } diff --git a/ts/fixtures/lang/expected/iters.ts b/ts/fixtures/lang/expected/iters.ts index 3ee3ec3d6..eccf6d73a 100644 --- a/ts/fixtures/lang/expected/iters.ts +++ b/ts/fixtures/lang/expected/iters.ts @@ -3,7 +3,8 @@ import * as rt from "./rt.ts"; import { copy$Bumped, copy$Option_u8_Reverse_Option_u8, copy$Option_usize_u8, copy$u8_u8 } from "./lib.ts"; import { thenSome$bool_u16, thenSome$bool_u8 } from "./core/bool.ts"; -import { unwrapOr$Option_NonZero_u64, unwrapOr$Option_i64, unwrapOr$Option_u8, unwrapOr$Option_usize_u8, map$Option_u8_u8_elements_closure8, mapOr$Option_Tilt_u8_ranked_closure11_closure0, mapOr$Option_Vec_u16_u8_consumers_closure23, mapOr$Option_u8_u8_btree_maps_closure5, mapOr$Option_u8_u8_u8_btree_maps_closure0, mapOr$Option_u8_usize_iters_closure1, mapOr$Option_u8s_u8_skips_closure44, mapOr$Option_usize_u8_consumers_closure8, mapOr$Option_usize_u8_u8_heaps_closure0, filter$Option_u8_combinators_closure0 } from "./core/option.ts"; +import { unwrapOr$Option_NonZero_u64, unwrapOr$Option_i64, unwrapOr$Option_u8, unwrapOr$Option_usize_u8, map$Option_u8_u8_elements_closure8, mapOr$Option_Tilt_u8_ranked_closure11_closure0, mapOr$Option_Vec_u16_u8_consumers_closure23, mapOr$Option_char_u32_from, mapOr$Option_u8_u8_btree_maps_closure5, mapOr$Option_u8_u8_u8_btree_maps_closure0, mapOr$Option_u8_usize_iters_closure1, mapOr$Option_u8s_u8_skips_closure44, mapOr$Option_usize_u8_consumers_closure8, mapOr$Option_usize_u8_u8_heaps_closure0, filter$Option_u8_combinators_closure0 } from "./core/option.ts"; +import { unwrapOr$Result_str_Utf8Error } from "./core/result.ts"; import * as Bumped from "./iters.Bumped.ts"; import * as Countdown from "./iters.Countdown.ts"; import * as Doubled from "./iters.Doubled.ts"; @@ -1213,4 +1214,160 @@ export function values(data: rt.ByteSlice, out: rt.ByteVec): void { })); } +/** + * What std's `Option`-returning calls give, returned as is: an `Option`, whose `None` + * stays apart from an item's own. + */ +export function returned(data: rt.ByteSlice, out: rt.ByteVec): void { + const _3: (a0: rt.u8 | undefined, a1: rt.ByteVec) => void = (b: rt.u8 | undefined, out2: rt.ByteVec): void => { + rt.byteVecPush(out2, mapOr$Option_u8_u8_btree_maps_closure5(b, 170, (b2: rt.u8): rt.u8 => { + return b2; + })); + }; + const _4: (a0: rt.u8 | undefined | rt.None, a1: rt.ByteVec) => void = (b3: rt.u8 | undefined | rt.None, out3: rt.ByteVec): void => { + if (b3 === rt.None) { + rt.byteVecPush(out3, 187); + } else if (b3 === undefined) { + rt.byteVecPush(out3, 204); + } else { + rt.byteVecPush(out3, b3); + } + }; + const n: rt.usize = mapOr$Option_u8_usize_iters_closure1(rt.byteSliceFirst(data), 0, (_2: rt.u8): rt.usize => { + return rt.u8Rem(_2, 4) as rt.usize; + }); + const part = first$Copied_Iter_u8(rt.iterSlice(rt.byteSliceView(data))); + _3(part, out); + const part2 = back$Copied_Iter_u8(rt.iterSlice(rt.byteSliceView(data))); + _3(part2, out); + const part3 = nth$Copied_Iter_u8(rt.iterSlice(rt.byteSliceView(data)), n); + _3(part3, out); + const part4 = last$Copied_Iter_u8(rt.iterSlice(rt.byteSliceView(data))); + _3(part4, out); + const part5 = first$Map_Iter_u8_returned_closure0(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (b6: rt.u8): rt.u8 | undefined => { + if (!(rt.u8Rem(b6, 3) === 0)) { + return b6; + } + return undefined; + })); + _4(part5, out); + const part6 = back$Map_Iter_u8_returned_closure0(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (b7: rt.u8): rt.u8 | undefined => { + if (!(rt.u8Rem(b7, 3) === 0)) { + return b7; + } + return undefined; + })); + _4(part6, out); + const part7 = first$Gaps({ data, at: n }); + _4(part7, out); + const part8 = first$Countdown({ left: n & 0xff, step: 1 }); + _3(part8, out); + rt.iterExtendBytes(out, rt.iterSlice(rt.u32ToBeBytes(mapOr$Option_char_u32_from(first$Chars(rt.strChars(unwrapOr$Result_str_Utf8Error(rt.strFromUtf8(data), "é"))), 0, (a0: rt.char): rt.u32 => { + return a0 as rt.u32; + })).reverse())); + const part9 = byMut$Copied_Iter_u8(rt.iterSlice(rt.byteSliceView(data))); + _3(part9, out); + const gaps: Gaps.Gaps = { data, at: 0 }; + const part10 = byMut$Gaps(gaps); + _4(part10, out); + const part11 = byMut$Gaps(gaps); + _4(part11, out); + const it: rt.Iter = rt.iterSlice(rt.byteSliceView(data)); + const part12 = borrowed(it); + _3(part12, out); + const part13 = borrowed(it); + _3(part13, out); + const part14 = secondOf(data); + _3(part14, out); + const part15 = fromOne(n & 0xff); + _3(part15, out); + const part16 = peeked$Copied_Iter_u8(rt.iterPeekable(rt.iterSlice(rt.byteSliceView(data)))); + _3(part16, out); + const part17 = at$u8(data, n); + _3(part17, out); + const part18 = at$Option_u8(rt.iterToArray(rt.iterMap(rt.iterSlice(rt.byteSliceView(data)), (b8: rt.u8): rt.u8 | undefined => { + if (!(rt.u8Rem(b8, 3) === 0)) { + return b8; + } + return undefined; + })), n); + _4(part18, out); +} + +export function first$Chars(it: rt.Iter): rt.char | undefined { + return rt.iterToOption(it.next()); +} + +export function first$Copied_Iter_u8(it: rt.Iter): rt.u8 | undefined { + return rt.iterToOption(it.next()); +} + +export function first$Countdown(it: Countdown.Countdown): rt.u8 | undefined { + return rt.iterToOption(Countdown.next$Iterator(it)); +} + +export function first$Gaps(it: Gaps.Gaps): rt.u8 | undefined | rt.None { + return rt.iterToOption(Gaps.next$Iterator(it), rt.None); +} + +export function first$Map_Iter_u8_returned_closure0(it: rt.Iter): rt.u8 | undefined | rt.None { + return rt.iterToOption(it.next(), rt.None); +} + +export function back$Copied_Iter_u8(it: rt.Iter): rt.u8 | undefined { + return rt.iterToOption(it.nextBack()); +} + +export function back$Map_Iter_u8_returned_closure0(it: rt.Iter): rt.u8 | undefined | rt.None { + return rt.iterToOption(it.nextBack(), rt.None); +} + +export function nth$Copied_Iter_u8(it: rt.Iter, n: rt.usize): rt.u8 | undefined { + return rt.iterNth(it, n); +} + +export function last$Copied_Iter_u8(it: rt.Iter): rt.u8 | undefined { + return rt.iterLast(it); +} + +/** Through a `&mut` to the iterator. */ +export function byMut$Copied_Iter_u8(it: rt.Iter): rt.u8 | undefined { + return rt.iterToOption(it.next()); +} + +/** Through a `&mut` to the iterator. */ +export function byMut$Gaps(it: Gaps.Gaps): rt.u8 | undefined | rt.None { + return rt.iterToOption(Gaps.next$Iterator(it), rt.None); +} + +/** Through a borrow of a std iterator the function is not generic over. */ +export function borrowed(it: rt.Iter): rt.u8 | undefined { + return rt.iterToOption(it.next()); +} + +/** Of a slice's iterator the function makes. */ +export function secondOf(data: rt.ByteSlice): rt.u8 | undefined { + const it: rt.Iter = rt.iterSlice(rt.byteSliceView(data)); + it.next(); + return rt.iterToOption(it.next()); +} + +/** Of a small range the function makes. */ +export function fromOne(n: rt.u8): rt.u8 | undefined { + const range: rt.Range = new rt.Range(1, n); + return range.start < range.end ? range.start++ : undefined; +} + +export function peeked$Copied_Iter_u8(it: rt.Peekable): rt.u8 | undefined { + return rt.peekablePeek(it); +} + +export function at$Option_u8(items: Array, i: rt.usize): rt.u8 | undefined | rt.None { + return rt.sliceGet(items, i, rt.None); +} + +export function at$u8(items: rt.ByteSlice, i: rt.usize): rt.u8 | undefined { + return rt.byteSliceGet(items, i); +} + //# sourceMappingURL=iters.ts.map diff --git a/ts/fixtures/lang/src/harness.rs b/ts/fixtures/lang/src/harness.rs index 39427fe4f..010b78511 100644 --- a/ts/fixtures/lang/src/harness.rs +++ b/ts/fixtures/lang/src/harness.rs @@ -123,6 +123,7 @@ fn cases() -> Vec<(&'static str, Case)> { ("counts::cloned_rcs", |_, data, out| counts::cloned_rcs(data, out)), ("counts::copies", |_, data, out| counts::copies(data, out)), ("statics::cells", |_, data, out| statics::cells(data, out)), + ("iters::returned", |_, data, out| iters::returned(data, out)), ] } diff --git a/ts/fixtures/lang/src/iters.rs b/ts/fixtures/lang/src/iters.rs index b405de074..b9f89605f 100644 --- a/ts/fixtures/lang/src/iters.rs +++ b/ts/fixtures/lang/src/iters.rs @@ -791,3 +791,88 @@ impl fmt::Debug for Doubled<'_> { f.debug_list().entries(self.0.iter().map(|&b| b as u16 * 2)).finish() } } + +/// What std's `Option`-returning calls give, returned as is: an `Option`, whose `None` +/// stays apart from an item's own. +pub fn returned(data: &[u8], out: &mut Vec) { + let maybe = |b: &u8| if b % 3 == 0 { None } else { Some(*b) }; + let push = |b: Option, out: &mut Vec| out.push(b.map_or(0xaa, |b| b)); + let nested = |b: Option>, out: &mut Vec| match b { + None => out.push(0xbb), + Some(None) => out.push(0xcc), + Some(Some(b)) => out.push(b), + }; + let n = data.first().map_or(0, |&b| usize::from(b % 4)); + push(first(data.iter().copied()), out); + push(back(data.iter().copied()), out); + push(nth(data.iter().copied(), n), out); + push(last(data.iter().copied()), out); + nested(first(data.iter().map(maybe)), out); + nested(back(data.iter().map(maybe)), out); + nested(first(Gaps { data, at: n }), out); + push(first(Countdown { left: n as u8, step: 1 }), out); + let text = std::str::from_utf8(data).unwrap_or("é"); + out.extend(first(text.chars()).map_or(0, u32::from).to_le_bytes()); + let mut copied = data.iter().copied(); + push(by_mut(&mut copied), out); + let mut gaps = Gaps { data, at: 0 }; + nested(by_mut(&mut gaps), out); + nested(by_mut(&mut gaps), out); + let mut it = data.iter(); + push(borrowed(&mut it).copied(), out); + push(borrowed(&mut it).copied(), out); + push(second_of(data).copied(), out); + push(from_one(n as u8), out); + let mut peekable = data.iter().copied().peekable(); + push(peeked(&mut peekable).copied(), out); + push(at(data, n).copied(), out); + let maybes: Vec> = data.iter().map(maybe).collect(); + nested(at(&maybes, n).copied(), out); +} + +fn first(mut it: I) -> Option { + it.next() +} + +fn back(mut it: I) -> Option { + it.next_back() +} + +fn nth(mut it: I, n: usize) -> Option { + it.nth(n) +} + +fn last(it: I) -> Option { + it.last() +} + +/// Through a `&mut` to the iterator. +fn by_mut(it: &mut I) -> Option { + it.next() +} + +/// Through a borrow of a std iterator the function is not generic over. +fn borrowed<'a>(it: &mut std::slice::Iter<'a, u8>) -> Option<&'a u8> { + it.next() +} + +/// Of a slice's iterator the function makes. +fn second_of(data: &[u8]) -> Option<&u8> { + let mut it = data.iter(); + it.next(); + it.next() +} + +/// Of a small range the function makes. +fn from_one(n: u8) -> Option { + let mut range = 1..n; + range.next() +} + +fn peeked(it: &mut std::iter::Peekable) -> Option<&I::Item> { + it.peek() +} + +fn at(items: &[T], i: usize) -> Option<&T> { + items.get(i) +} diff --git a/ts/fixtures/reject/census.md b/ts/fixtures/reject/census.md index e5df61f78..06ea2c92c 100644 --- a/ts/fixtures/reject/census.md +++ b/ts/fixtures/reject/census.md @@ -1,6 +1,6 @@ # Census of `reject-fixture` -- Refusals: 101 +- Refusals: 102 - Function instances: 116 - Generic functions no instance reached, lowered over their type parameters: 7 @@ -17,6 +17,7 @@ | 3 | unsupported type `_` | fixtures/reject/src/lib.rs:7:14 | | 2 | `_` is not supported: its `None` and `Some` would both be `rt.None` | fixtures/reject/src/lib.rs:16:15 | | 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:250:16 | +| 2 | `_`, a trait object of another crate's trait, which is not supported yet | fixtures/reject/src/lib.rs:11:16 | | 2 | `_`, a trait object of the generic trait `_`, which is not supported yet | fixtures/reject/src/lib.rs:518:23 | | 2 | a coercion to `_`, which is not supported yet | fixtures/reject/src/lib.rs:509:40 | | 2 | an iterator of the crate implementing `_`, which is not supported yet | fixtures/reject/src/lib.rs:169:1 | @@ -36,7 +37,6 @@ | 1 | `_` of `_`, which is not supported yet | fixtures/reject/src/lib.rs:599:4 | | 1 | `_` through a held type's own, which is not supported yet | fixtures/reject/src/lib.rs:321:2 | | 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | fixtures/reject/src/lib.rs:575:12 | -| 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:297:9 | | 1 | `_`, which reads a capacity that depends on whether the other handles of its storage dropped, which is not supported | fixtures/reject/src/lib.rs:437:6 | | 1 | `f64::mul_add`, which rounds once, where JS would round twice | fixtures/reject/src/lib.rs:488:4 | @@ -94,6 +94,7 @@ The type or module each refused type or path belongs to. | 2 | `Scaled` | fixtures/reject/src/lib.rs:518:23 | | 2 | `dyn Scaled` | fixtures/reject/src/lib.rs:518:23 | | 2 | `dyn std::any::Any` | fixtures/reject/src/lib.rs:593:32 | +| 2 | `dyn std::iter::Iterator` | fixtures/reject/src/lib.rs:11:16 | | 2 | `std::any::TypeId` | fixtures/reject/src/lib.rs:599:2 | | 2 | `std::collections::HashMap` | fixtures/reject/src/lib.rs:53:13 | | 2 | `std::iter::Iterator` | fixtures/reject/src/lib.rs:250:16 | @@ -124,7 +125,6 @@ The type or module each refused type or path belongs to. | 1 | `Waiting` | fixtures/reject/src/lib.rs:556:2 | | 1 | `[u8; 4]` | fixtures/reject/src/lib.rs:535:26 | | 1 | `dyn Keyed` | fixtures/reject/src/lib.rs:593:32 | -| 1 | `dyn std::iter::Iterator` | fixtures/reject/src/lib.rs:11:16 | | 1 | `f64` | fixtures/reject/src/lib.rs:493:2 | | 1 | `into_keys` | fixtures/reject/src/lib.rs:53:13 | | 1 | `poll` | fixtures/reject/src/lib.rs:556:2 | @@ -152,6 +152,7 @@ The type or module each refused type or path belongs to. | 4 | a variant of `_`, which is not supported: either is the same JS string | `std::borrow::Cow` | fixtures/reject/src/lib.rs:385:2 | | 3 | unsupported type `_` | `f32` | fixtures/reject/src/lib.rs:7:14 | | 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 another crate's trait, which is not supported yet | `dyn std::iter::Iterator` | fixtures/reject/src/lib.rs:11:16 | | 2 | `_`, a trait object of the generic trait `_`, which is not supported yet | `dyn Scaled`, `Scaled` | fixtures/reject/src/lib.rs:518:23 | | 2 | an assignment through a reference to `_` | `std::pin::Pin` | fixtures/reject/src/lib.rs:126:2 | | 2 | replacing the value behind a reference to `_` | `std::pin::Pin` | fixtures/reject/src/lib.rs:110:2 | @@ -173,7 +174,6 @@ The type or module each refused type or path belongs to. | 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:250:16 | | 1 | `_` through a held type's own, which is not supported yet | `::ne` | fixtures/reject/src/lib.rs:321:2 | | 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::sync::Mutex::get_mut` | fixtures/reject/src/lib.rs:575:12 | -| 1 | `_`, a trait object of another crate's trait, which is not supported yet | `dyn std::iter::Iterator` | fixtures/reject/src/lib.rs:11:16 | | 1 | `_`, which is not supported yet | `Hasher::write` | fixtures/reject/src/lib.rs:297:9 | | 1 | `_`, which reads a capacity that depends on whether the other handles of its storage dropped, which is not supported | `BytesMut::capacity` | fixtures/reject/src/lib.rs:437:6 | | 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:231:30 | @@ -318,6 +318,13 @@ The type or module each refused type or path belongs to. +
`_`, a trait object of another crate's trait, which is not supported yet (2) + +- fixtures/reject/src/lib.rs:11:16: `dyn std::iter::Iterator`, a trait object of another crate's trait, which is not supported yet +- fixtures/reject/src/lib.rs:12:4: `dyn std::iter::Iterator`, a trait object of another crate's trait, which is not supported yet + +
+
`_`, a trait object of the generic trait `_`, which is not supported yet (2) - fixtures/reject/src/lib.rs:518:23: `dyn Scaled`, a trait object of the generic trait `Scaled`, which is not supported yet @@ -438,12 +445,6 @@ The type or module each refused type or path belongs to.
-
`_`, a trait object of another crate's trait, which is not supported yet (1) - -- fixtures/reject/src/lib.rs:11:16: `dyn std::iter::Iterator`, a trait object of another crate's trait, which is not supported yet - -
-
`_`, which is not supported yet (1) - fixtures/reject/src/lib.rs:297:9: `Hasher::write`, which is not supported yet diff --git a/ts/fixtures/reject/expected.txt b/ts/fixtures/reject/expected.txt index 4d72f199b..4936362a7 100644 --- a/ts/fixtures/reject/expected.txt +++ b/ts/fixtures/reject/expected.txt @@ -7,6 +7,7 @@ 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 unsupported type `f32` at fixtures/reject/src/lib.rs:7:25 `dyn std::iter::Iterator`, a trait object of another crate's trait, which is not supported yet at fixtures/reject/src/lib.rs:11:16 +`dyn std::iter::Iterator`, a trait object of another crate's trait, which is not supported yet at fixtures/reject/src/lib.rs:12:4 `Option>>` is not supported: its `None` and `Some` would both be `rt.None` at fixtures/reject/src/lib.rs:17:2 `Option>>` is not supported: its `None` and `Some` would both be `rt.None` at fixtures/reject/src/lib.rs:16:15 unsupported call to `core::slice::::rotate_left` at fixtures/reject/src/lib.rs:21:4 diff --git a/ts/src/lower/mir/mod.rs b/ts/src/lower/mir/mod.rs index 540497087..2b7581d1e 100644 --- a/ts/src/lower/mir/mod.rs +++ b/ts/src/lower/mir/mod.rs @@ -1088,7 +1088,9 @@ impl<'m, 'b, 'a, 'tcx> Fx<'m, 'b, 'a, 'tcx> { let Some(local) = destination.as_local() else { continue; }; - if crate::lower::iter::is_next(tcx, def_id) && self.defs[local] == 1 { + // The return place leaves as the `Option` the signature declares, unless this is a + // `next` itself, which returns the protocol's item or `rt.DONE` below. + if crate::lower::iter::is_next(tcx, def_id) && self.defs[local] == 1 && local != mir::RETURN_PLACE { nexts.push((local, gargs.skip_binder().type_at(0))); } if crate::lower::library::key(tcx, def_id).is_some_and(|(o, n)| o == "Try" && n == "branch") @@ -1130,7 +1132,7 @@ impl<'m, 'b, 'a, 'tcx> Fx<'m, 'b, 'a, 'tcx> { continue; } self.next_results.insert(to); - } else if local != mir::RETURN_PLACE && small_range(tcx, iter_ty) { + } else if small_range(tcx, iter_ty) { self.range_nexts.insert(local); } self.next_results.insert(local);