Repository navigation
feat(ts): translate Debug of std's iterator adaptors and a str's escapes - #515
Merged
Merged
Conversation
Quest-Claim: afbc67f337eeed14
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nts at Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Debug of a str's escapes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h the place of a value Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…to it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fused flag Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Debug lowering kept its own copy of how references and boxes peel to the iterator, which dropped the place of a `&mut Box` to the crate's own iterator. It now reads the type `peel_iter` gives, and the fixture covers the boxed and borrowed orders std forwards through. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
marked this pull request as ready for review
November 3, 2026 14:52
|
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 39 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
|
…tor-debug # Conflicts: # ts/fixtures/lang/lengths/expected/lengths.ts
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 adaptors (Map,Filter,Enumerate,Zip,Chain,Peekable,Skip,Take,StepBy,Flatten,FlatMap,DecodeUtf16, and the rest) failed as "unsupported call", and so didDebugof astr's escapes, which #514 added to this quest. Closes the questquest/m3/ts-iter-adaptor-debug.md.Approach
adaptor_debugints/src/lower/fmt.rs): each adaptor maps to one runtime function, given theDebugof each iterator it wraps, built by the samefmt_fnpath for the typeiter::peel_iterholds it as, so an adaptor over an unmapped iterator is refused at its span.Zipwrites bareZipwhere both sides areTrustedRandomAccessNoCoerce, as std's specialization does.Flatten/FlatMapread theirFlattenCompat's types from rustc's field types. Astr's escapes writeName { inner: FlatMap { .. } }, matching nightly's std.rt/iter.ts,rt/char.ts): tree-shakablefmtAdaptor,fmtEnumerate,fmtCounted,fmtFlagged,fmtScan,fmtPeekable,fmtStepBy,fmtChain,fmtZip,fmtCycle,fmtFuse,fmtFlatten,fmtAround, andfmtDecodeUtf16read the state each class already keeps (Skip's and Take'sn, Peekable's peeked item, Chain's dropped halves, and so on).rt.iterHeldreads an adaptor's field as Rust holds it, through theBox/&mutforwarding wrappers and an own iterator'siterFromsource.Debugexposes them:fusedis now exactlyFusedIterator, as std'sFusekeeps such an iterator (Some(..)) rather than dropping it. This is most of the snapshot churn (falsebecomestrueiniterFlatten/iterFlatMap/iterFusecalls).StepBy<Range<u8 | u16 | u32 | usize>>on wasm32 to count down the range's end. The newRangeStepByclass mirrors that, soStepBy { iter: 6..47, .. }matches.fmt::adaptorscase in theshapesfixture covers each adaptor plain and{:#?}, after partial reads from either end. It also covers nested adaptors,{:x?}, bothZipforms, bothFuseforms, the specialized range steps with wraparound, adaptors overby_ref(),Box, and crate-own iterators (a fieldless enum through&mut,&mut &mut,&mut Box,Box<&mut>, andBox<&mut Box>, and a struct throughBox<Box>and&mut &mut Box<Box>), and the threestrescapes. All run differentially against native wasm32.Impact
Debugof the adaptors above and of astr's escapes now translates.iterFlatten,iterFlatMap, anditerFusegetfused = truefor everyFusedIterator.step_byof a small unsignedRangepasses the integer's greatest tort.iterStepBy.fmt*functions above,rt.iterHeld, andrt.iterStepBy's optionalmax. The no-intooverloads ofrt.iterFlatMapandrt.iterFlattenalso acceptfused,size, andoneShot. Nothing breaking, so noMIGRATE.mdentry.Alternatives
Peekable's orChain'sOptions in the runtime's representation.debugmethods on each iterator class, likeclone. Dropped for tree-shaking: free functions cost nothing in bundles that never format an adaptor.Follow-ups
quest/m3/ts-iter-source-debug.md:DebugofOnce,Repeat,FromFn, an array'sIntoIter,Option's iterators, and std's other iterators (an adaptor over one is refused at its span today).quest/m3/ts-own-iter-value.md:toggle.map(f), a fieldless enum iterator of the crate's own taken by value, fails to type-check whether or not anything formats it.Decision
The maintainer approved taking the
Debugtype of each wrapped iterator fromiter::peel_iter, the function that decides how the adaptor holds it. Review rounds 2 to 4 had each found a case where a separate hand-written walk in theDebuglowering disagreed with it (an own value-typed iterator under&mut,&mut &mut, and&mut Box). That walk is deleted, so the two cannot drift.PinandRcare not iterators in std, so no adaptor can wrap them. The rejected alternatives were to merge with the boxed case recorded as a follow-up quest, or to refuse adaptors over the crate's own iterator behind a reference.Review
gpt-6.1-sol, medium effort, viaquest review. Round 5 reviewed headb504eb170278cf8a66bcdb84db15bd87952a5c57.rt.iterHeld. The identityCopiedoverby_ref()now goes throughrt.fmtAround.&mutwas read as its value instead of itsPlace. Fixed.&mut &mut. Fixed.&mut Box<_>. Fixed at its source: see Decision.lengths.ts), regenerated; it and main's newclonessnapshot differ from main only by the exact fused flag. No further round was needed.Checks
just cipassed ona0a2d515. The pushed heade230f3f9adds only main's quest-plan commits (#530, #531), and its quest tree lints clean.🤖 Generated with Claude Code