Repository navigation
fix(ts): keep a Vec's room in a raw slice cast to an array - #632
Conversation
RawSlice.array viewed the items alone, so a cast of a raw slice into a Vec's spare capacity read undefined past its length. 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 11 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
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed head 97c4b0a against base d0c268d.
No actionable findings. RawSlice.array now uses the same room-aware storage selection as ptrSlice while retaining the original offset and requested array length. It does not introduce ptrSlice's reach check, and the existing no-memory-pointer guard remains before projection. RoomView reads and writes the spare slots through the original Room, so the new swap/read fixture observes those writes when the Vec subsequently takes the slots into its length. The generated cases exercise u32, String and Option.
Direction: retain this cross-feature regression coverage for raw-array casts into spare capacity. The separately reported environment-dependent TypeId snapshot failures are not resolved or validated by this change.
Verification limits: GitHub-only static review of the full diff and the surrounding RawSlice, sliceArray, Room/RoomView and Vec storage helpers. No compilation, differential tests, mutation checks or CI were run, and the author's reported pass/failure counts were not independently reproduced. This COMMENT is not a passing-build or merge-readiness claim.
(Written by review (OpenAI))

Problem
RawSlice.array(n), the runtime half of a*const [T]cast to*const [T; N]from moq-dev/rust2#624, viewed theVec'sitemsalone. A raw slice into aVec's spare capacity, asv.as_mut_ptr().add(v.len())makes since moq-dev/rust2#623, lost theRoomholding those slots, so a read through the array gaveundefined(TypeError: Cannot read properties of undefined). CodeRabbit flagged it on #624's queued head (review).Fix
array(n)builds its slice oversliceArray(at, n), the room-aware viewptrSlicealready uses, withoutptrSlice'sreachcheck, so the cast still checks nothing, as in Rust.lang/elements'spare::pointersnow casts the room's raw slice to*mut [T; 2], swaps, and reads through it, foru32,String, andOption<u16>. Without the fix, 31 of 1345 differential cases differ from native wasm32.Impact
Translator output unchanged. Runtime:
RawSlice.arrayof a slice into aVec's room reads and writes the room.Caused by
RawSlice.arraytookat.arrayinstead of the room-aware view, which moq-dev/rust2#623 added while feat(ts): translate a slice's pointer cast to an array's, and std::io::IoSlice #624 was openValidation
just ts test --test fixtures lang::elements: passes; fails with 31 differences on the runtime without the fixjust ci: everything passes exceptlang/dyns(ids.ts) andlang/panics/hook(lib.ts), whoseTypeIdhash snapshots differ. That reproduces unchanged on origin/main (33fa28d4/d0c268d5) in this checkout, while the merge queue's build ofd0c268d5passed, so the hashes look environment-dependent.Follow-ups
TypeIdsnapshots from moq-dev/rust2#605 that differ by checkout: plan it, since every localjust cioutside CI fails until they're stable.Models
Size: XS
Implementer: Claude Code, Claude Opus 5.5, high effort
(Written by Claude Opus 5.5 with high effort)
🤖 Generated with Claude Code
Review
Rewritten by
quest reviewafter each round.01a1b4c7-86ba-71d0-b1b9-d584e7fdf509, round 1The change reuses the existing storage adapter correctly and adds differential fixture coverage for reads and writes through raw-slice array views; no actionable defects were found, though tests were not run in the read-only environment.