Repository navigation
feat(ts): translate Debug of std's iterator sources, Option's, Result's, and an array's iterators, and a slice's parts - #542
Merged
Conversation
Quest-Claim: 981fd4774504703f
…'s, and an array's iterators, and a slice's parts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ce-debug # Conflicts: # ts/README.md # ts/runtime/rt/str.ts # ts/src/lower/fmt.rs
kixelated
marked this pull request as ready for review
November 3, 2026 19:37
|
This run was cancelled before it finished. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 12 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. CodeRabbit Verify
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
Debugof std's iterator sources and several collection iterators was refused, so an adaptor over one (for examplechar::decode_utf16([..]), which wraps an array'sIntoIter) failed to translate. #515 covered the adaptors; this covers what they wrap.Approach
Extends
iter_debugints/src/lower/fmt.rs, which #515'speel_iter-based adaptorDebugalready reaches throughwrapped. Each new arm writes std's private fields as std's impl does, from the runtime iterator's own state:Once,option::{Iter, IterMut, IntoIter}, andresult::{Iter, IterMut, IntoIter}:rt.fmtIterOption, the item left as anOptioninside std's wrapper structs (Once { inner: IntoIter { inner: Item { opt } } }). Its item is written as the iterator's item type, so a&mutto a value JS copies is read through its place.FromFnandRepeatWith: their names, without closures, as std writes them.Successors: the item it yields next.IntoIter: the list it has left, as aVec's.CharIndices: its front offset andChars. AString'sDrain: what it has left.Windows,Chunks,ChunksExact,RChunks,RChunksExact:rt.fmtParts, what the parts left cover, the remainder, and the size.PartsIternow tracks whether a read past the end emptied it, as std'sWindows::nth,nth_back, andnext_backsetvto[].Splitand its nine forms:rt.fmtSplit, what is left to split andfinished, a&mutone emptying its slice as it finishes, and asplitn'sGenericSplitNwith its count.HashSet's set operations: the list a clone yields, as std'sdebug_list().entries(self.clone()).ChunksMutand its forms are refused at their span: std writes their*mut [T]as an address.Tested differentially in
fmt::sourcesof theshapesfixture, plain,{:#?}, and{:x?}, fresh, read from either end, and past the end. A reject fixture coversChunksMut.Impact
fmtIterOption,fmtIterClone,fmtSuccessors,fmtParts,fmtSplit,fmtCharIndices,fmtStringDrain. No breaking changes.Debugderives over its types; any field or adaptor holding one of these iterators now translates instead of refusing.Alternatives
Nones) is computed differently anyway.Follow-ups
The quest is rewritten to what remains:
str's searcher iterators (Split,Lines,SplitWhitespace,Matches) writeCharSearcherandTwoWaySearcherstate the runtime does not keep; aBTreeSet's set operations write std's strategy;ExtractIfs write a peeked item; anditer::repeat,repeat_n, andonce_withare not translated at all yet.Review
quest review, Codexgpt-6.1-sol, medium effort.ts/src/lower/library.rs:2995(nestedVeccapacity inclone_from) is not in this branch's diff. It is main's fix(ts): keep a nested Vec's capacity where clone_from writes over it #533, which the old merge base lacked.origin/main(feat(ts): translate a slice's as_chunks_mut and as_rchunks_mut #529, fix(ts): translate the crate's own iterator held as a value, taken by value or by std's &mut self methods #540), ending at head 7a1260b.just cipassed on that head.🤖 Generated with Claude Code