From 9276ad5b3ef94318df7287d41084e0dd375bce97 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Sat, 7 Nov 2026 17:31:05 -0800 Subject: [PATCH] quest: plan array references from slices and cells Co-Authored-By: Claude Opus 5.5 --- quest/m3/README.md | 1 + quest/m3/ts-array-ref-conversions.md | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 quest/m3/ts-array-ref-conversions.md diff --git a/quest/m3/README.md b/quest/m3/README.md index 72d1a95dd..db14860a9 100644 --- a/quest/m3/README.md +++ b/quest/m3/README.md @@ -51,3 +51,4 @@ memory model for values whose address is reinterpreted, without a consumer. - [Browser APIs through wasm-bindgen](/quest/m3/ts-wasm-bindgen/README.md) - web-sys and js-sys imports become direct JS calls, so idiomatic crates such as web-rs's web-codecs translate as stock crates - [`if let` of a temporary whose rest drops](/quest/m3/ts-if-let-drop.md) - `if let Some(E::A(x)) = temp()` with a destructor in the rest of `temp` emits TypeScript that type-checks - [`u64` wrapping arithmetic in V8](/quest/m3/ts-u64-wrapping.md) - `rs.u64WrappingAdd` and its kin cost near a plain `+` while the value is a safe integer +- [Array references from slices and cells](/quest/m3/ts-array-ref-conversions.md) - `try_into` of a slice into an array reference, `Cell::as_array_of_cells`, and `identity` of a `&mut [T; N]` lend the array where it is diff --git a/quest/m3/ts-array-ref-conversions.md b/quest/m3/ts-array-ref-conversions.md new file mode 100644 index 000000000..75fdee6b0 --- /dev/null +++ b/quest/m3/ts-array-ref-conversions.md @@ -0,0 +1,20 @@ +# [S] Array references from slices and cells + +## Goal + +[rust2-ts](/ts/README.md) translates `TryFrom<&mut [T]> for &mut [T; N]` (and its `&[T]` +twin, as `slice.try_into()` reaches them), `Cell::as_array_of_cells`, and +`convert::identity` of a `&mut [T; N]`, each lending the array where it is, proven by +differential tests against native Rust. Today each is an unsupported call. + +## Plan + +Suggested on [#662](https://github.com/moq-dev/rust2/pull/662), which removed `arrayView` +and lends parts of arrays where they are: its tests use `first_chunk_mut` in place of these. +`try_into` of a slice into an array reference is common in parsers. Build on #662's +`rs.ArraySlice` and slice helpers, adding no new pointer form, per m3's +[unsafe policy](/quest/m3/README.md). + +Decided with the maintainer on 2026-11-07: ✅ plan it, in m3 (from #662's follow-ups). + +Public API: the translator's output.