Repository navigation
feat(ts): translate the rest of std::future and std::task - #528
Conversation
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>
|
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
|
|
quest land watch: the merge queue removed this pull request at f2d25fb because it conflicts with The land fixer works on it in the background, and the watcher re-enqueues it at the back of the queue once it is fixed or judged flaky, or hands it back here with what it needs. (written by quest land watch) |
|
quest land watch: armed auto-merge on this pull request at ad17485, so it joins the back of the merge queue once its required checks pass, with the land fixer's fix ( (written by quest land watch) |
Waker::clone_from joins main's runtime clone_from, so a waker in an Option or an array clones over another by it too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problem
rust2-ts refused parts of the stable
std::futureandstd::taskAPI (found by #519):future::readyand everything on itsReady,Debugof aPoll,Pending, andPollFn,Poll::from, hashing aPoll, aPending's clone, andWaker::clone_from. No moq consumer calls these; the maintainer plans all of std regardless.Survey of the stable API: these already translated and stay as they are:
pending,poll_fn,IntoFuture(std's and a crate's own),Poll'smap,map_ok,map_err,is_ready,is_pending,==, ordering,Clone,?,ready!,Context::from_wakerandwaker, andWaker'swake,wake_by_ref,will_wake,data,vtable,noop,clone, andFrom<Arc<W>>.Approach
future::ready(v)is a newrt.Ready<T>: anrt.Futurewhose first poll orinto_innertakesvand a later one panics with std's message. A value nothing took drops with it, by the dropperreadyis given. It has$move,clone, andDebug(Ready(Some(..)), orReady(None)once taken), and is adyn Futureas itself.Debugof aPollisrt.fmtPoll, withrt.OuterPendingpassed where thePollholds one that can be pending.PendingandPollFnwrite their name, as std's do.Pollisrt.hashPoll: its variant as anisize, then what it holds, as std's derivedHashwrites them.Poll::from(v)isv, asSome(v)already is. EveryPending, whether cloned or made as a zero-sized constant, isrt.NEVER.Waker::clone_fromisrt.wakerCloneFrom, one of the runtime'sCloneFroms, which clones and drops only where the waker it has would notwill_wakethe source, as std's does, so a waker in anOptionor an array clones over another by it too.Debugof aWaker,Context, orRawWakerVTablewrites addresses, so it is now refused with that reason instead of "unsupported call".Tests: a new
lang/futuresdifferential fixture. It covers aReadypolled, awaited,into_innered, cloned before and after its poll, behind adyn Future, and of(),Option<Option<_>>, and text. Its value's drop order is checked unpolled, dropped, polled, taken, and moved into anasyncblock. Polling it twice panics with`Ready` polled after completion, andinto_innerafter a poll with std's other message. APendingnever completes over many polls, boxed or cloned.Debugis checked plain, with#, and with width, hex, and zero-pad specs, for nestedPoll<Poll<u8>>too. It also hashesPolls, uses them as set keys, and callsclone_fromon a waker in a variable and in a field, checkingArccounts and wakes. The reject fixture gains aReadyof aPollandDebugof aWaker.Impact
rt.Ready,rt.fmtPoll,rt.hashPoll,rt.wakerCloneFrom,rt.wakerCloneFromFn. No breaking change.Alternatives
Waker::clone_fromas*self = source.clone(): theArccounts end the same, but a waker an executor gives would see a clone and a drop std never makes.Wakerwith made-up addresses: it could never match native output, so it stays refused.Follow-ups
RawWakerVTable::new,RawWaker::new,Waker::from_raw,Waker::new,RawWaker::from(Arc), and==of vtables.AssertUnwindSafe(also aFuture) is refused, since it can't be constructed, andString::from_utf8_lossyis an unsupported call. Both are reported for planning.Review
Codex (
quest review, gpt-6.1-sol, medium), round 2 on head 89f62ff reported no findings. That head merges origin/main through #538 after the queue dropped the PR for a conflict: main movedclone_fromonto the runtime'sCloneFromfunctions, soWaker::clone_fromis nowrt.wakerCloneFrom, an entry ofstd_clone_from, instead of a special case inmir/call.rs, which also covers a waker in anOptionor an array (fixture extended).just cipasses on it. Head cc875dc adds only a conflict-free merge of origin/main (#529); thelang::futuresandrejectfixtures pass on it, and the full suite is left to the merge queue.🤖 Generated with Claude Code