Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion quest/m3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ memory model for values whose address is reinterpreted, without a consumer.
- [A Pin of a crate's own Deref type](/quest/m3/ts-pin-own-deref.md) - `Pin<P>` over a crate's own `Deref` derefs through its impl and type-checks
- [Waiting: drop the lang fixture's mul_add allowance](/quest/m3/ts-fma-allowance.md) - the differential fails on any `mul_add` difference again once wasm32's `fma` rounds exactly
- [Waiting: type-check in process with tsrs](/quest/m3/ts-tsrs.md) - rust2-ts checks bindings through tsrs instead of `tsc` once it is a stable library
- [Throw only where Rust panics](/quest/m3/ts-runtime-throws.md) - no runtime `rust2-ts:` error where native Rust goes on: exact, or refused at translation
- [rust2-ts with no ts.toml](/quest/m3/ts-configless.md) - a crate's whole `pub` API translates with no config and no bound items
- [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
- [`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
Expand Down
4 changes: 0 additions & 4 deletions quest/m3/ts-array-ref-conversions.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,3 @@ and lends parts of arrays where they are: its tests use `first_chunk_mut` in pla
Decided with the maintainer on 2026-11-07: ✅ plan it, in m3 (from #662's follow-ups).

Public API: the translator's output.

## Related

- [Throw only where Rust panics](/quest/m3/ts-runtime-throws.md) - its exact `ptr::eq` for `as_chunks` copies changes how an array taken from a flat slice is represented, on the same `rs.ArraySlice`
71 changes: 0 additions & 71 deletions quest/m3/ts-runtime-throws.md

This file was deleted.

15 changes: 8 additions & 7 deletions ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ crate translation reaches is refused, and so are two versions of one crate it re
| `Ordering`, `DefaultHasher`, `RandomState`, `BuildHasherDefault<H>` | `rs.Ordering`, which is `-1`, `0`, or `1`; `rs.Hasher`; `rs.RandomState`, the keys of the `DefaultHasher` it builds, never changed once made; `undefined`, as `PhantomData` is, whose `build_hasher` is `H::default()` |
| `Duration` | `rs.Duration`: `{ secs, nanos }`, std's whole seconds as an `rs.u64` and the nanoseconds past them, never changed once made |
| `TypeId` | `rs.TypeId`: rustc's 128-bit hash of the type, which std's holds at run time, as 32 hex digits, equal by `===`; ordered as std's derive orders the hash's pointer-sized words, lowest first, hashed as its high 64 bits, and written as `TypeId(0x…)`, as std's are |
| `Layout`, `alloc::alloc` | `rs.Layout`: `{ size, align }`, never changed once made, checked as std's constructors check it; `alloc` gives an `rs.Block` of its bytes, which a cast of its pointer to `*mut T` the body shows came from `alloc` or `realloc` makes a JS array of `T`s, values JS copies, as an `rs.AtIndex` of its first; a cast back to `*mut u8` only as what `dealloc` or `realloc` takes, which free the array or copy it into a new one, and abort on memory `alloc` didn't give, as Rust leaves that undefined; its bytes, read, written, or cast to any other type, are refused, and fail at run time through a pointer from elsewhere |
| `Layout`, `alloc::alloc` | `rs.Layout`: `{ size, align }`, never changed once made, checked as std's constructors check it; `alloc` gives an `rs.Block` of its bytes, which a cast of its pointer to `*mut T` the body shows came from `alloc` or `realloc` makes a JS array of `T`s, values JS copies, as an `rs.AtIndex` of its first; a cast back to `*mut u8` only as what `dealloc` or `realloc` takes, which free the array or copy it into a new one, and abort on memory `alloc` didn't give, as Rust leaves that undefined; its bytes, read, written, or cast to any other type, are refused, as are a call of `alloc` or `realloc` whose pointer the body passes on as bytes elsewhere, such as out of the body, and a `realloc` whose result it casts to a type other than the one the memory it grows was cast from, so no pointer to its bytes leaves the body that made it |
| closure | an arrow function, with `[Symbol.dispose]` if it owns a value that drops, and what makes its clone if a clone can't be itself |
| `fn` pointer, function item as a value | the function, or std's an arrow that calls it as a written call does, as a closure is typed: a `()` result is `undefined`, where a declared function returns `void` |
| `&dyn Trait`, `&mut dyn Trait`, `Box<dyn Trait>`, `Arc<dyn Trait>`, `Rc<dyn Trait>`, `Weak<dyn Trait>`, `Pin<P>` of one | an object with the trait's methods, its supertraits' included: `shape.area$Shape()`; behind an `Arc` or an `Rc`, an `rs.ArcDyn` sharing the count of the `Arc` it was made from |
Expand Down Expand Up @@ -193,7 +193,8 @@ where the arrays are, whether each is a JS array of its own, as a `Vec<[T; N]>`
split it. A caller passes one as `rs.arraySliceFrom(arrays, rs.sliceFrom)`, `rs.byteSliceFrom`
for bytes and `rs.arraySliceOf(rs.sliceFrom)` for arrays of arrays, and reads one as
`rs.arraySliceItems(slice)`: the arrays themselves, or copies of the ones a split of one
slice holds, which have no array of their own. std's methods that lend arrays or parts of
slice holds, which have no array of their own, each remembered as its run, so `ptr::eq`
compares a pointer to one where the run is. std's methods that lend arrays or parts of
the slice, such as `iter_mut`, `split_at_mut`, `chunks_mut`, and `swap`, take them where
they are; any other reads them as `rs.arraySliceItems` does, or for a `&mut` one, such as
`sort` or `rotate_left`, reads copies of the arrays, which it writes back once it returns,
Expand All @@ -213,9 +214,8 @@ with its payload if that is text, or `Box<dyn Any>` as std's hook writes any oth
A program that reaches `set_hook` has each panic carry the `Location` native code gives
it, std's own at the `/rustc/<commit>/library/...` path its build names, read from the
toolchain's source, and runs its hook with a `PanicHookInfo` before throwing; a panic in
the hook throws `rs.Abort`, as std aborts. A panic of `bytes`' own code is where the
program's `bytes` has it, and one of tokio's where its compiled code has it, named as the
session names that file: by the host's cargo registry, unless the build remaps it, as
the hook throws `rs.Abort`, as std aborts. A panic of `bytes`' or tokio's own code is
where its compiled code has it, named as the session names that file: by the host's cargo registry, unless the build remaps it, as
`--remap-path-prefix` does natively. The default
hook writes nothing, as wasm32 has no stderr. A program without one passes no locations,
and a bundler drops the hook's runtime, `rs/hook.ts`, from it; what stays is the location
Expand Down Expand Up @@ -765,8 +765,9 @@ of them:
`rs/bytes.ts`, panicking as `bytes` does, and so do `split_to`, `split_off`,
`truncate`, `clear`, and `slice_ref`, whose panic names no addresses. A `Bytes` of a
`String` takes storage of its capacity, as `bytes` does. `slice_ref` of
bytes from other storage throws, since Rust may share what JS copied, as a `&'static
str`'s bytes that `as_bytes` encodes anew. `Bytes::from_owner`
bytes the body doesn't show borrowed, through `Deref`, `as_ref`, or a slice of one, from
that `Bytes` or one sharing its storage through `slice` or `clone`, is refused, since Rust
may share what JS copied, as a `&'static str`'s bytes that `as_bytes` encodes anew. `Bytes::from_owner`
reads its owner's bytes once, as `bytes` does, and an owner that drops is kept in the
`rs.Shared` they count, which drops it with the last `Bytes` sharing them; one of an owner
is never unique, so taking it back copies.
Expand Down
2 changes: 1 addition & 1 deletion ts/fixtures/lang/panics/hook/expected/bytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function panicAdvance(errorInfo: TryGetError.TryGetError): never {
const _8: rs.Fmt = (f: rs.Formatter) => rs.usizeDisplay(arg, f);
const arg2 = errorInfo.requested;
const args3 = [_8, (f: rs.Formatter) => rs.usizeDisplay(arg2, f)];
rs.panicFmt(["advance out of bounds: the len is ", args3[0], " but advancing by ", args3[1]], { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/lib.rs", line: 207, col: 5 });
rs.panicFmt(["advance out of bounds: the len is ", args3[0], " but advancing by ", args3[1]], { file: "bytes/source/lib.rs", line: 207, col: 5 });
}

//# sourceMappingURL=bytes.ts.map
14 changes: 7 additions & 7 deletions ts/fixtures/lang/panics/hook/expected/bytes/buf/take.Take.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export function tryCopyToSlice$bytes_Buf_bytes_Bytes(self: Take<rs.ByteSlice>, d
while (!(dst.length === 0)) {
const src: rs.ByteSlice = chunk$bytes_Buf_bytes_Bytes_mut(self);
const cnt: rs.usize = rs.min(src.length, dst.length);
rs.byteSliceCopyFromSlice(rs.byteSliceRange(dst, 0, cnt, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_impl.rs", line: 1178, col: 16 }), rs.byteSliceRange(src, 0, cnt, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_impl.rs", line: 1178, col: 44 }), { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_impl.rs", line: 1178, col: 24 });
dst = rs.byteSliceRange(dst, cnt, undefined, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_impl.rs", line: 1179, col: 27 });
rs.byteSliceCopyFromSlice(rs.byteSliceRange(dst, 0, cnt, { file: "bytes/source/buf/buf_impl.rs", line: 1178, col: 16 }), rs.byteSliceRange(src, 0, cnt, { file: "bytes/source/buf/buf_impl.rs", line: 1178, col: 44 }), { file: "bytes/source/buf/buf_impl.rs", line: 1178, col: 24 });
dst = rs.byteSliceRange(dst, cnt, undefined, { file: "bytes/source/buf/buf_impl.rs", line: 1179, col: 27 });
advance$bytes_Buf_bytes_Bytes(self, cnt);
}
return rs.OK;
Expand Down Expand Up @@ -225,7 +225,7 @@ export function remaining$bytes_Buf_bytes_Bytes(self: Take<rs.ByteSlice>): rs.us
*/
export function chunk$bytes_Buf_bytes_Bytes(self: Take<rs.ByteSlice>): rs.ByteSlice {
const bytes: rs.ByteSlice = self.inner;
return rs.byteSliceRange(bytes, 0, min$00xoube(bytes.length, self.limit), { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/take.rs", line: 142, col: 15 });
return rs.byteSliceRange(bytes, 0, min$00xoube(bytes.length, self.limit), { file: "bytes/source/buf/take.rs", line: 142, col: 15 });
}

/**
Expand Down Expand Up @@ -262,10 +262,10 @@ export function chunk$bytes_Buf_bytes_Bytes(self: Take<rs.ByteSlice>): rs.ByteSl
*/
export function advance$bytes_Buf_bytes_Bytes(self: Take<rs.ByteSlice>, cnt: rs.usize): void {
if (!(cnt <= self.limit)) {
rs.panic("assertion failed: cnt <= self.limit", { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/take.rs", line: 146, col: 9 });
rs.panic("assertion failed: cnt <= self.limit", { file: "bytes/source/buf/take.rs", line: 146, col: 9 });
} else {
rs.bytesAdvance(rs.place(() => self.inner, (value) => self.inner = value), cnt);
self.limit = rs.usizeSub(self.limit, cnt, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/take.rs", line: 148, col: 9 });
self.limit = rs.usizeSub(self.limit, cnt, { file: "bytes/source/buf/take.rs", line: 148, col: 9 });
}
}

Expand All @@ -292,10 +292,10 @@ export function advance$bytes_Buf_bytes_Bytes(self: Take<rs.ByteSlice>, cnt: rs.
*/
export function copyToBytes$bytes_Buf_bytes_Bytes(self: Take<rs.ByteSlice>, len: rs.usize): rs.ByteSlice {
if (!(len <= remaining$bytes_Buf_bytes_Bytes_mut(self))) {
rs.panicFmt(["`len` greater than remaining"], { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/take.rs", line: 152, col: 9 });
rs.panicFmt(["`len` greater than remaining"], { file: "bytes/source/buf/take.rs", line: 152, col: 9 });
} else {
const r: rs.ByteSlice = rs.bytesSplitTo(rs.place(() => self.inner, (value) => self.inner = value), len);
self.limit = rs.usizeSub(self.limit, len, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/take.rs", line: 155, col: 9 });
self.limit = rs.usizeSub(self.limit, len, { file: "bytes/source/buf/take.rs", line: 155, col: 9 });
return r;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ export function uninit(slice: rs.ByteSlice): rs.ByteSlice {
*/
export function writeByte(self: rs.ByteSlice, index: rs.usize, byte: rs.u8): void {
if (!(index < len(self))) {
rs.panic("assertion failed: index < self.len()", { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/uninit_slice.rs", line: 108, col: 9 });
rs.panic("assertion failed: index < self.len()", { file: "bytes/source/buf/uninit_slice.rs", line: 108, col: 9 });
} else {
asMutPtr(indexMut$ops_IndexMut_ops_RangeFrom_usize(self, new rs.RangeFrom(index, rs.usizeStep), { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/uninit_slice.rs", line: 110, col: 22 })).v = byte;
asMutPtr(indexMut$ops_IndexMut_ops_RangeFrom_usize(self, new rs.RangeFrom(index, rs.usizeStep), { file: "bytes/source/buf/uninit_slice.rs", line: 110, col: 22 })).v = byte;
}
}

Expand Down Expand Up @@ -96,7 +96,7 @@ export function copyFromSlice(self: rs.ByteSlice, src: rs.ByteSlice): void {
const _5: rs.usize = len(self);
const _8: rs.usize = src.length;
if (!(_5 === _8)) {
rs.assertFailed("==", (f: rs.Formatter) => rs.usizeDebug(_5, f), (f: rs.Formatter) => rs.usizeDebug(_8, f), undefined as rs.Arguments | undefined, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/uninit_slice.rs", line: 137, col: 9 });
rs.assertFailed("==", (f: rs.Formatter) => rs.usizeDebug(_5, f), (f: rs.Formatter) => rs.usizeDebug(_8, f), undefined as rs.Arguments | undefined, { file: "bytes/source/buf/uninit_slice.rs", line: 137, col: 9 });
} else {
rs.ptrCopy(rs.byteSliceAsPtr(src), asMutPtr(self), len(self));
}
Expand Down
Loading