Repository navigation
feat(ts): translate a Box, Arc, or Rc of dyn Debug or dyn Display - #445
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
marked this pull request as ready for review
November 2, 2026 15:45
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
kixelated
enabled auto-merge (squash)
November 2, 2026 16:22
This was referenced Nov 2, 2026
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
A
&dyn Debugor&dyn Displaytranslates as a function writing its value, but aBox,Arc, orRcof one is refused where it is built, as "a trait object of another crate's trait". #247 foundArc<dyn Debug>refused, and the trait objects quest's goal names it. moq builds none today; this is std coverage the quest's plan calls for.Approach
A
Box<dyn Debug>orBox<dyn Display>is the samert.Fmta&dynof its value is:rt.fmtOwned(value, write, drop), a function writing the value, whose[Symbol.dispose]drops it when it drops. AnArcorRcof one goes through the existingrt.ArcDynover what a box of its value makes, so the last pointer drops the value. An upcast that drops auto traits (Box<dyn Debug + Send>toBox<dyn Debug>) is the same function. An upcast from another trait object, and a&mut dyn Debug, stay refused.Tests:
fmt::objectsin the lang fixture's differential test against native wasm32 covers boxes ofdyn Debuganddyn Displayover the crate's type, a tuple, aString, and ausize, written with{:?},{:#?}, width, fill, and alignment. It drops them in order through aVec's drop andtruncate, and covers an upcast droppingSend. It shares one value as anArc<dyn Debug + Send + Sync>and as anRc<dyn Display>and anRc<dyn Debug>of oneRc, checking counts and that the value drops with the last pointer, whichever it is.Census at the moq pin: unchanged (976 / 232 / 141 for moq-net / model / kio), since moq builds none.
Impact
rt.fmtOwned.Alternatives
fmt$Debug, as the crate's own traits with aDebugsupertrait get: a&dyn Debugis already anrt.Fmt, andDebug for Box<T>/Arc<T>forwards to it, so one representation serves all pointers.Follow-ups
&mut dyn Debug, and an upcast from another trait object todyn Debug(such as fromdyn Error), stay refused.Debugof aRefCellis an existing refusal, met while writing the fixture.Review
mechanical fix by codex / Codex:
Merged base preserving both sides of the harness conflict and regenerated its TypeScript snapshot; passed in ts/: UPDATE_EXPECT=1 cargo test --locked -p rust2-ts --test fixtures lang -- --exact; cargo test --locked -p rust2-ts --bin rust2-ts; cargo fmt --all --check; tsc -p runtime.(head a016fe3)Codex
gpt-6.1-solat medium effort, viaquest review, round 1 on head519bc63038289e755df9f68d06b41e92837fc390: no findings.🤖 Generated with Claude Code