Repository navigation
feat(ts): translate bytes' BufMut for a &mut [u8] and a &mut [MaybeUninit<u8>] - #642
Conversation
Quest-Claim: 7ed00e0424c1a603
…init<u8>] A `&mut [u8]` counted as a mapped buffer, though no mapping writes one, so every call into its impl refused. It now translates from the MIR, as the `MaybeUninit` impl already did, and `ptr::write_bytes` of bytes maps, which the provided `put_bytes` reaches through the forwarding impls. Its other pointees are refused, and a write the body shows past an array JS keeps apart is too. A differential case writes an array through each slice, directly, through a `&mut`, and through a `Box`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed head 0de9208600994217a125a9ca574882d7624a8b49 against base efa6300cc2a9be621b52d683179bcd8e49f9a672.
No actionable introduced findings identified.
The mutable-slice implementations now reach MIR without changing shared-slice mappings. I checked the generated slice cursor/backing-storage behavior against bytes' implementations, the byte-only pointer fill and origin checks, and the registered differential and rejection cases.
Direction: no changes requested from this review; retain the normal validation gates.
Verification limits: GitHub-only static review. I did not execute the translator, differential tests, or CI, and did not independently reproduce the reported results or pre-existing snapshot failures. This COMMENT is not an approval.
(Written by review (OpenAI))
|
quest land watch: the merge queue removed this pull request at 0de9208 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 3516907, 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) |

Problem
bytes'impl BufMut for &mut [u8]refused at every call:mapped_self(ts/src/lower/stock.rs) counted any&[u8]or&mut [u8]as a mapped buffer, but noBuffermapping writes a mutable slice. Reproduced first with a new differential case: 45 refusals, all<&mut [u8] as bytes::BufMut>::*. The&mut [MaybeUninit<u8>]impl already translated from its MIR but forptr::write_bytes, which the providedput_bytesreaches through the forwarding&mut TandBox<T>impls (they don't forwardput_bytes) and theMaybeUninitimpl's ownput_bytescalls.Approach
mapped_selfcounts only a shared&[u8], so the&mut [u8]impl translates from MIR like the deque's in moq-dev/rust2#611:chunk_mutis the slice'srs.ByteSlice,advance_mutitsmem::take(self).split_at_mut(cnt).ptr::write_bytesand the*mut T/NonNullwrite_bytesmethods map to a newrs.ptrWriteBytesfor byte pointees (u8,MaybeUninit<u8>). Any other pointee is refused with a span, as JS keeps it as a value, not bytes. The origin check refuses a write the body shows reaching past an array JS keeps apart, as it doesptr::copy.buf::slices: writes a 255-byte array through a&mut [u8]and a&mut [MaybeUninit<u8>]of the room its input picks, bywrite_allandchunk_all(every provided and overridden method,chunk_mutwrites,advance_mutpast the room), directly, through a&mut, and through aBox, ending with the room left and both arrays whole. Of 320 inputs per kind, each of the 8 kinds reaches both completed writes (21 to 127) and panics.write_bytes::<u32>and awrite_bytespast a lone byte.Impact
BufMutfor&mut [u8]and&mut [MaybeUninit<u8>], andptr::write_bytesof bytes, now translate instead of refusing.rs.ptrWriteBytes.Caused by
No single PR:
mapped_selfhas counted every byte-slice reference sincebytes'Buf/BufMutmapping began, before any&mut [u8]consumer.Choices made without asking
write_bytescovers byte pointees only and refuses others (u32,i8, structs). Integers of every byte set alike (such as zeroing) could be supported, but no consumer reaches them; see Follow-ups.rs.ptrWriteBytessets byte by byte through the sameelemSetpath asptrCopy's fallback rather than aUint8Array.fillfast path: simpler, and nothing here is hot.Alternatives
&mut [u8]as a newBuffervariant in the bytes mapping. Rejected: the impl's MIR translates exactly with what exists, and a mapping would duplicatebytes' panics by hand.Follow-ups
ptr::write_bytesof non-byte pointees (integers and floats from a repeated byte, e.g. zeroing a[u32]): plan as an m3 quest, since rust2 aims for all of std and this refusal is a std gap with no consumer yet.Validation
just ci: lint passes; tests pass but for the two known TypeId-hash snapshots (ts/fixtures/lang/dyns/expected/ids.ts,ts/fixtures/lang/panics/hook/expected/lib.ts), which differ only in hash strings, reproduce on bareorigin/mainper the coordinator, and moq-dev/rust2#633 fixes.stockdifferential: 0 differences.Models
Size: S
Implementer: Claude Code, claude-opus-5-5, high effort
(Written by Claude Opus 5.5 with high effort)
🤖 Generated with Claude Code
Review
mechanical fix by codex, gpt-6.1-sol, medium effort:
Merged base and re·solved ts/README.md conflict by preserving the PR pointer row and base MaybeUninit row; ran just check base and just test base successfully.(head 3516907)Rewritten by
quest reviewafter each round.01a1b538-0a34-7080-ac34-8e28ac2dc77c, round 1No actionable defects were found in the specified diff; 400 focused differential cases passed using existing build artifacts, although the full suite was blocked by the read-only environment.