Repository navigation
feat(ts): translate the rest of a trait object in a struct's last field - #519
Merged
Merged
Conversation
Quest-Claim: dec2c49a9925b67c
…ject, a dyn Future in a struct's last field, and raw pointers unsized to either Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…it, in the place a raw pointer to a cell is Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…unsizes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…once Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
marked this pull request as ready for review
November 3, 2026 14:13
|
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 18 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
|
…rest # Conflicts: # ts/README.md
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
#493 translates
Rc<RefCell<dyn Trait>>,Arc<Mutex<dyn Trait>>, and the crate's own&Tail<dyn Trait>as anrt.tailDynview, but still refused the rest of quest/m3/ts-dyn-tail-rest.md: aCell,UnsafeCell, orManuallyDropof a trait object, adyn Futurein a struct's last field, and raw pointers unsized to a trait object or a struct of one. No consumer reaches these yet; they are std gaps.Approach
CellandUnsafeCellviews namert.Cell'sv; the cell is the place of what it holds.ManuallyDrop<T>isTin JS, so a pointer to one unsizes as a pointer to what it holds; a box of it still drops nothing.dyn Futurein the last field is anrt.DynFutureover the field, made where it is read, so each poll advances the one future in place; it drops the future, as a struct's glue drops its last field, so the struct's drop drops it once.Box::from_rawof it drops the concrete value once, or as a&mutto its place where JS copies the value, throughrt.rawUnsize, which keeps a null or dangling pointer as itself sois_nullholds. This covers crate traits,dyn Future,dyn Debug, and structs of one. A raw pointer that is thert.Placeof a library value, such as a cell, unsizes throughrt.rawUnsizePlace, which makes the view as each read finds the value, so uninitialized or replaced storage is never read early; where the result would be an object made eagerly (*mut Rangeto*mut dyn Iterator), it is refused with a span.Pointee::Object(a&mutto one is the object), so*mut dyn Traitis typed as the object; comparing pointers to trait objects stays refused, now with its own reason.Cell::get_mutandCell::as_ptrtranslate as theirUnsafeCell'sget_mutandget(samert.Cell), in every table that judges those; without them nothing reads aCell<dyn Trait>. This also fills the gap for sized cells.&mutto an unsized type reaching std marked the type as replaced, which made a raw pointer intoUnsafeCell<dyn Trait>look out of step. Nothing writes a whole unsized value, and what a trait object's methods replace already counts where it unsized, soreplaceskips unsized types.Tests: a new
dyns::restsdifferential case covers dispatch through each view, writes landing in the original, a future advancing across polls and dropping once (in aMutexand anasyncblock in aRefCell), drop order withManuallyDrop, raw pointers to crate traits, a struct of one, cells,dyn Debug, a null pointer, uninitialized storage, and ownership rebuilt byBox::from_raw, plus an iterator in a boxedCelland anArc<Mutex<..>>dropping once. The reject fixture'scell_unsizednow translates;raw_dyn_iterkeeps its refusal with the new reason, anddyn_comparedcovers comparing pointers to trait objects.Impact
rt.rawUnsizeandrt.rawUnsizePlace. No breaking change.Alternatives
Cell::as_ptr/get_muttoUnsafeCell's inlibrary::key: rejected, sincemade_out_of_stepmust project throughCell's innerUnsafeCell.object_of: the same gap reacheddyn Iteratoranddyn Future, so the raw case is handled once at the coercion.Follow-ups
std::future::readyandDebugofPollare unsupported calls (avoided in the fixture), and a raw pointer to a library value unsized to an object made eagerly (*mut Rangeto*mut dyn Iterator) stays refused.Review
Codex (
quest review, gpt-6.1-sol, medium), 5 rounds; round 5 on head b83fde6 reported no findings. That head merges origin/main (#516, #521, #524), with ats/README.mdprose conflict against #521 resolved by keeping both texts;just cipasses on it.rt.Place: fixed. Raw pointer objects made as borrowed, soBox::from_rawskipped the destructor: fixed.rt.rawUnsizePlace, eager-object case refused).dyns.ts), and the added differential case matches native.🤖 Generated with Claude Code