Repository navigation
feat(ts): translate the rest of a guard's maps - #384
Merged
Merged
Conversation
Quest-Claim: 1d3f1f04f27d5fe2
RefMut::map, Ref and RefMut's filter_map and map_split, and the map and filter_map of an RwLock's guards, mapped or not. A mapped guard is an rt.RefMap of where its part is: a write through a mapped RefMut reaches the cell, through the part's rt.Place where JS copies it, or into the object in place. Split guards share the cell's borrow until the last drops. A mapped guard of a sized part JS can't write in place is refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lowering for both guards Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # ts/fixtures/lang/caller.ts # ts/fixtures/lang/expected/harness.ts # ts/fixtures/lang/src/harness.rs
…fferential Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # ts/fixtures/lang/expected/harness.ts # ts/fixtures/lang/expected/lib.ts # ts/src/lower/mir/call.rs
kixelated
marked this pull request as ready for review
November 1, 2026 12:07
|
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 16 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. |
kixelated
enabled auto-merge (squash)
November 1, 2026 12:07
kixelated
added a commit
that referenced
this pull request
Nov 1, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
moq-bot Bot
pushed a commit
that referenced
this pull request
Nov 1, 2026
* chore(quest): claim quest/m2/ts-byte-views/README.md Quest-Claim: 00e3717952d0d17a * perf(ts): return a Result of numbers alone in a slot A function only translated code calls that returns a Result of numbers alone, such as Decoder::varint's Result<u64, E> or a Result<(i64, u64), E>, now hands back through #160's slot: it returns the first number, or undefined with the error in the slot, and writes any other numbers there. A local with no slice is held as its parts only where it meets a slot, and a tuple made where its parts are taken apart is never made. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(ts): update results' snapshot for #381's merge Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(ts): regenerate core/result.ts's snapshot for #384's merge Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Luke Curley <432854+kixelated@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: quest fixer <quest-fixer@localhost>
This was referenced Nov 1, 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
rust2-ts refused
RefMut::map,Ref::filter_map,Ref::map_split,RefMut::filter_map,RefMut::map_split, and themap/filter_mapof anRwLock's guards (and of theMappedRwLock*Guards they make). #374 landed onlyRef::map. Completes quest/m3/ts-guard-maps.md.Approach
guard_mapints/src/lower/task.rs, for both shared and exclusive guards. It calls the map's function on what the guard lends (an exclusive guard of a value JS copies lendsrt.valuePlace(guard)), then hands each part to the runtime as the guard should hold it.rt.RefMapis now the single mapped-guard class. It holds the part'srt.Placeand its cell, and reads and writes the part throughvalue, as a cell does its own value. So every existing write path through a guard (guard.value = ...fromDerefMut) reaches the cell, never a copy:String,Option) is thert.Placethe closure already returns;Vec, a struct) isrt.partPlace(obj), which writes a whole value into the object in place, as a write through a&mutto it does (vecAssignorptrWrite);[u8; N]part is thebyteSliceViewof thert.ByteSliceits reference is. This also fixesRef::mapto a[u8; N], which feat(ts): translate the rest of the cells' and locks' methods #374 left emitting outputtscrejected.map_splitadds a shared borrow, or one more exclusive one (std'sBorrowRefMut::clone).refMutReleasenow decrements the exclusive count instead of zeroing it, so the cell frees only as the last part drops.MappedRwLockReadGuard/MappedRwLockWriteGuardmap toStd::Ref/Std::RefMut, so they deref, write through, and drop like the guards they come from.write_inanderasedmoved fromFxtoTranslatorso the guard lowering shares the store's rule for what writes in place.Tests
borrows::maps(new, lang differential against native wasm32): writes through mapped guards to au32,String,Vec,[u8; 4],Option<u16>, and aDropvalue. Whole writes drop the old value at the write, and are read back after the guard drops. Also covers maps of maps,filter_mapOk/Err, shared and exclusivemap_splitwith parts dropped in either order, guards of a[u8; 4], and borrow state after each drop. It checks wasm32's panics:RefCell already mutably borrowedandRefCell already borrowedwhile a mapped, filtered, or split guard holds the cell.locks::mapped(new):RwLockReadGuard/RwLockWriteGuardmap/filter_map, and the mapped guards' ownmap/filter_map, with lock state throughtry_read/try_write.mapped_closure, the new refusal.just cipasses locally.Impact
Ref::map's output changes shape (rt.refMap(guard, part)), and a mappedRefis anrt.RefMapholding a place.refMapnow takes the part rather than the function; newrefFilterMap,refMapSplit,refMutMap,refMutFilterMap,refMutMapSplit,partPlace;RefMapno longer extendsRefCellbut implements it. The runtime ships with the output, so there is noMIGRATE.mdentry.Alternatives
RefMutof an object holding the object, and lower whole writes through everyRefMutin place. Rejected: a whole write through an unmapped guard of a binding's class works today and would regress.Follow-ups
DebugofRefCell/RwLockguards (refused today),MutexGuard::map, and the guards' unstabletry_map.RwLocklocked again while held is anrtabort!with no panic message, which the differential can't compare with the runtime'srt.Panic("rwlock locked for ..."). Solocks::mappedchecks lock state throughtry_read/try_writeinstead. The gap predates this PR.Review
quest review), gpt-6.1-sol, medium effort.origin/main: no findings.(written by Claude Opus 5.5)
🤖 Generated with Claude Code