Repository navigation
feat(ts): translate Arc<dyn Trait> and Arc<dyn Future> - #177
Conversation
Quest-Claim: 1bfa29973ffdf445
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 19e08a8
No actionable bugs found. The ArcDyn view is a focused extension: reusing the existing trait/future wrappers while forwarding the original Arc's count avoids changing all Arc allocations or replacing the concrete value. I checked clone/drop and Weak upgrade paths, final-owner drop glue, upcasts, pointer equality, and the added differential fixtures (including panic cleanup and both kinds of final owner). The explicit Weak-unsizing refusal keeps the unsupported boundary clear.
Verification: static GitHub source/diff review only; I did not run the compiler, TypeScript checks, or differential tests.
# Conflicts: # ts/fixtures/lang/caller.ts # ts/fixtures/lang/expected/harness.ts # ts/fixtures/lang/src/harness.rs # ts/fixtures/task/expected/drops.ts # ts/tests/task.ts
# Conflicts: # ts/fixtures/reject/census.md # ts/fixtures/reject/expected.txt
|
Landing at
(written by Claude Opus 5.5) |
Advances quest/m3/ts-dyn.md:
Arc<dyn Trait>andArc<dyn Future>.Problem
rust2-ts refused every
Arc<T>toArc<dyn Trait>coercion. moq-net holds its group expiry policy asArc<dyn Expiry>. AnArcunsized from anArc<T>shares the original's allocation and count, so the trait object can't replace thert.Arc's value, and a separatert.Arcaround a wrapper would have its own count.Approach
Arc<T>unsized toArc<dyn Trait>is anrt.ArcDyn, a view of thert.Arcit was made from. Itsvalueis the trait object aBox<T>of the same value unsizes to, reusing feat(ts): translate trait objects of the crate's own traits #171's wrapper classes, andstrongreads and writes the original's count. Clones,strong_count,downgrade/upgrade, and drops on either side see one count, and whicheverArcis last drops the value:rt.Arcthrough its own drop,rt.ArcDynthrough the object's[Symbol.dispose]. Deref is.value, as for anyArc.Arc<dyn Future>takes the same path. Its value is thert.FutureaBox<dyn Future>would be (feat(ts): translate Box::pin and dyn Future #170'srt.DynFuture, or the coroutine itself), dropped with the lastArc.Arc<dyn Named>toArc<dyn Shape>) is the same view.Arc::ptr_eqandWeak::ptr_eqof trait objects compare theArcs the views were made from (rt.arcPtrEq). Two coercions of clones of oneArcare equal, as Rust's data-pointer comparison is. Otherptr_eqs are unchanged.Weak<T>toWeak<dyn Trait>stays refused with its span. It has no consumer.lang's newdyns::sharedcase runs differentially. It covers two objects and their upcasts from oneArc, counts after each side's clones and drops,Weakupgrades before and after the last drop,ptr_eqof the same and of differentArcs, an atomic counter everyArcsees, andArcs of numbers, enums, and structs in aVec. Inputs are incaller.tsviaop("dyns::shared").task'sdynsstep now runs scenarioarg % 12, where 6 to 11 are shared. They log whatArc<dyn Part>s drop: the lastArcbeing the original or a trait object, aDropthat panics through a trait object inside aVecwhile the rest still drop, aWeak, and anArc<dyn Future>whose async block's capture drops with the last clone. Each runs under a panic at each point, in aDrop, and with none.langwith 776 differences andtaskwith 133.taskwith 133.ptr_eqas===failslangwith 776.Census
moq-net at the pinned revision (
just ts census):a coercion to _, which is not supported yetare gone.Arc<dyn Expiry>translate.Arc<dyn Any + Send + Sync>now report asa trait object of another crate's trait(51 to 55), which the quest's remainingAnywork covers.Expirywrapper classes now reachis_expired(&kio::Waiter), adding 2kio::Waitertype refusals.Expiryimpls behind the objects) refuse kio calls and types: 5 calls, 6 + 1 types.Impact
Arc<dyn Trait>andArc<dyn Future>translate, typedrt.Arc<Trait>, with values ofrt.ArcDyn. Nothing that translated before changes.rt.ArcDynandrt.arcPtrEq.Arc<dyn OtherCrateTrait>now says why (a trait object of another crate's trait) instead ofa coercion to _.Alternatives
rt.Arc, so a secondrt.Arccould share it: one more allocation perArcfor a case only trait objects need.rt.Arc's value with the wrapper at coercion: otherArc<T>clones would see the wrapper.Choices made without asking
Arc<dyn>drop scenarios extend the existingdynstask step (arg % 12) rather than adding a step. No other scenario's arguments move.Weak<T>toWeak<dyn Trait>unsizing stays refused (newweak_objectreject case). It would be a few lines on the same view, but nothing needs it.Arc<T>'s ownDebugis not mapped for anyT, so the test formats&*arc. Left alone as out of scope.quest/m2/ts-model/README.mdno longer listsdyn Expiryas an enum among moq's own changes.Follow-ups
quest/m3/ts-dyn.mdkeeps what remains: other crates' traits (Fn*,Iterator,Error,Any, includingArc<dyn Any>, andbytes::Buf), and generic traits and associated types.Arc<T>'sDebug/DisplayontoT's (refused today for everyT).Checks
just ts test(all fixtures, differential included),just ts check(clippy, fmt, shear, sort, tsc),quest check,taplo format --check. ffi, driver, and uniffi are untouched and were not run.(written by Claude Opus 5.5)
🤖 Generated with Claude Code