From ddd0d32044a9170b449ceea77c84724039f407f2 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Sat, 31 Oct 2026 16:42:21 -0700 Subject: [PATCH 1/4] chore(quest): claim quest/m3/ts-str-places.md Quest-Claim: 1397ae1d553c85e9 From 7ddc45ec5c564fe329464a5193a49ce49afa0c6d Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Sat, 31 Oct 2026 17:17:51 -0700 Subject: [PATCH 2/4] feat(ts): translate a &mut str to a String wherever it is, and to a part of one Co-Authored-By: Claude Opus 5.5 --- quest/m3/README.md | 3 +- quest/m3/ts-box-places.md | 16 ++++ quest/m3/ts-str-get.md | 17 ++++ quest/m3/ts-str-places.md | 18 ---- ts/README.md | 9 +- ts/fixtures/lang/caller.ts | 4 + ts/fixtures/lang/expected/ascii.ts | 137 ++++++++++++++++++++++++++- ts/fixtures/lang/expected/harness.ts | 4 +- ts/fixtures/lang/src/ascii.rs | 124 +++++++++++++++++++++++- ts/fixtures/lang/src/harness.rs | 1 + ts/fixtures/reject/expected.txt | 5 +- ts/fixtures/reject/src/lib.rs | 18 ++-- ts/fixtures/reject/ts.toml | 4 +- ts/runtime/rt/str.ts | 69 ++++++++++++-- ts/src/lower/library.rs | 8 +- ts/src/lower/mir/call.rs | 90 +++++++++++++----- 16 files changed, 457 insertions(+), 70 deletions(-) create mode 100644 quest/m3/ts-box-places.md create mode 100644 quest/m3/ts-str-get.md delete mode 100644 quest/m3/ts-str-places.md diff --git a/quest/m3/README.md b/quest/m3/README.md index 00acc0b53..c6882b824 100644 --- a/quest/m3/README.md +++ b/quest/m3/README.md @@ -32,7 +32,8 @@ generic std gap is planned here even when moq never calls it. - [LinkedList](/quest/m3/ts-linked-list.md) - `LinkedList` and its methods translate - [std's sorts call their tests in std's order](/quest/m3/ts-sort-order.md) - `slice::sort` and a B-tree's `collect` call `lt` or `cmp` as std's driftsort does past 16 elements - [A B-tree's searches call Ord as std's do](/quest/m3/ts-btree-search-order.md) - a B-tree's lookups and inserts call a key's own `Ord` in std's order and number -- [A &mut str to any String](/quest/m3/ts-str-places.md) - `make_ascii_*` of a `String` a tuple, an array, or a `Vec` holds, and of a part of one, translate +- [A &mut into a Box of a value JS copies](/quest/m3/ts-box-places.md) - a write through `&mut *b` of a `Box`, a `Box`, or a `Box` reaches the box's place +- [A str's checked and inclusive parts](/quest/m3/ts-str-get.md) - `str::get` and indexing a `str` by `a..=b` or `..=b` translate - [The rest of a boxed slice's impls](/quest/m3/ts-boxed-slice-rest.md) - `clone_from`, `AsRef`, `AsMut`, `TryFrom` into a boxed array, and `Box` into bytes translate for boxed slices - [A crate's own Extend in a tuple](/quest/m3/ts-tuple-own-extend.md) - `collect` and `extend` into a tuple holding a crate's `Extend` type translate - [A reversed zip's per-pair cost](/quest/m3/ts-zip-rev-overhead.md) - a reversed by-index zip costs per pair what a forward one does, or the gap is explained diff --git a/quest/m3/ts-box-places.md b/quest/m3/ts-box-places.md new file mode 100644 index 000000000..68b2d7dba --- /dev/null +++ b/quest/m3/ts-box-places.md @@ -0,0 +1,16 @@ +# [S] A &mut into a Box of a value JS copies + +## Goal + +[rust2-ts](/ts/README.md) translates a `&mut` to what a `Box` holds, where JS copies it (a +number, a `String`, or a `str`), as a write to the local or field holding the box. Today +`*(&mut *b) += 1` of a `Box`, `push` on a `Box`, and `make_ascii_uppercase` +on a `Box` translate to `b.v` of a value with no `v`, which `tsc` rejects. Proven by +differential tests against native Rust. + +## Plan + +Found translating `&mut str`'s places. A `Box` is its `T`, so a `&mut` through it is +the box's own place, as `String::as_mut_str` borrows the `String`'s. + +Public API: the translator's output. diff --git a/quest/m3/ts-str-get.md b/quest/m3/ts-str-get.md new file mode 100644 index 000000000..fd5f4b5f9 --- /dev/null +++ b/quest/m3/ts-str-get.md @@ -0,0 +1,17 @@ +# [S] A str's checked and inclusive parts + +## Goal + +[rust2-ts](/ts/README.md) translates `str::get`, and indexing a `str` or a `String` by an +inclusive range (`&s[a..=b]`, `&s[..=b]`, and their `&mut` and `get_mut` forms), with +std's `None` and panics. Today each refuses: `get` as an unsupported call, and the +inclusive ranges at `Index::index` or `IndexMut::index_mut`. Proven by differential tests +against native Rust. + +## Plan + +Found translating `&mut str`'s places, whose `get_mut` and `&mut s[a..b]` take the other +ranges. The runtime's `strSlice` and `strGetMut` check offsets already; an inclusive end +past `usize::MAX` panics as std's does. No consumer calls them yet; planned as part of std. + +Public API: the translator's output. diff --git a/quest/m3/ts-str-places.md b/quest/m3/ts-str-places.md deleted file mode 100644 index b4c064fc8..000000000 --- a/quest/m3/ts-str-places.md +++ /dev/null @@ -1,18 +0,0 @@ -# [S] A &mut str to any String - -## Goal - -[rust2-ts](/ts/README.md) translates a `&mut str` to a `String` wherever the `String` is, -and to a part of one, so `make_ascii_uppercase` and `make_ascii_lowercase` reach every place -std's do. Today they write a local's, a field's, or one behind a `&mut String`; a `String` -a tuple, an array, or a `Vec` holds refuses at `DerefMut` as "no path", and `&mut s[a..b]` -and `String::as_mut_str` refuse as a `&mut` their mapping would copy. Proven by -differential tests against native Rust. - -## Plan - -Found translating the ASCII methods. A JS string can't change in place, so a `&mut str` is -an `rt.Place` of the whole `String`; a part of one needs the place and its UTF-8 -byte range, written back as a new string. No consumer calls them yet; planned as part of std. - -Public API: the translator's output. diff --git a/ts/README.md b/ts/README.md index 780b98d82..7ddab2a95 100644 --- a/ts/README.md +++ b/ts/README.md @@ -171,8 +171,7 @@ the width and sign, which computes on the value's `bigint`. The stable ASCII methods of `u8` and `char`, and of `[u8]` and `str`, so of a `Vec` and a `String`, are std's. A `u8` and a `char` share each runtime function, `rt.isAsciiDigit(c)`. `make_ascii_uppercase` and `make_ascii_lowercase` of a byte, a char, or a string write -the other case where the `&mut` borrows it; of a part of a `String`, or of a `String` -that a tuple, an array, or a `Vec` holds, they are refused. `escape_ascii`'s iterators read from either +the other case where the `&mut` borrows it, a part of a `String` included. `escape_ascii`'s iterators read from either end, size themselves as std's do, and write what they have left by `Display`, unpadded. An `f64` is a JS number, so its operators are JS's, which round as Rust's do. Where @@ -284,7 +283,11 @@ returns, from `rfind` or `match_indices`, counts UTF-8 bytes, as Rust's does, an one `&s[a..b]` takes, which reads the string up to it and panics as std does inside a char. A JS string can't change in place, so `String`'s edits, `push_str`, `truncate`, `insert`, `retain`, `replace_range`, and the rest, assign the edited one to the local or -field the `&mut` borrows, taking and checking byte offsets as std does. `extend` and +field the `&mut` borrows, taking and checking byte offsets as std does. A `&mut str` is +the `rt.Place` of its `String` wherever that is, and a part of one, from `&mut s[a..b]`, +`get_mut`, or `split_at_mut`, is `rt.strPart(p, a, b)`, a place of its own that writes the +whole string anew, checking its offsets as `&s[a..b]` does. `as_bytes_mut`, +`get_unchecked_mut`, and `str::from_utf8_mut` are refused. `extend` and `collect` read their iterator by `for_each`, as std's do, and of chars first reserve its size hint's lower bound, which panics past `isize::MAX`. A `drain` holds the `&mut`'s place and writes the string without the drained text as it drops, so one that diff --git a/ts/fixtures/lang/caller.ts b/ts/fixtures/lang/caller.ts index c04f92d48..b4485c5cc 100644 --- a/ts/fixtures/lang/caller.ts +++ b/ts/fixtures/lang/caller.ts @@ -721,6 +721,10 @@ const asciiCases = [ // Text of every char `ascii.rs` tries, each once. ...[0, 1, 2, 3].map((kind) => Uint8Array.of(op("ascii::slices"), kind, ...Array.from({ length: 41 }, (_, i) => i))), Uint8Array.of(op("ascii::chars"), 0, ...[0xd7ff, 0xd800, 0xdfff, 0xe000, 0x1f600, 0x10ffff, 0x110000].flatMap((n) => [n >>> 24, (n >>> 16) & 0xff, (n >>> 8) & 0xff, n & 0xff])), + // `parts` of each kind at every pair of byte offsets up to two past the end of its + // 14 bytes of text, and of no text. + ...Array.from({ length: 8 * 17 * 17 }, (_, i) => Uint8Array.of(op("ascii::parts"), i % 8, Math.floor(i / 8) % 17, Math.floor(i / 8 / 17))), + ...Array.from({ length: 8 * 3 * 3 }, (_, i) => Uint8Array.of(op("ascii::parts"), 0x10 | (i % 8), Math.floor(i / 8) % 3, Math.floor(i / 24))), ]; export const cases: Uint8Array[] = [...loops, ...durations, ...ints(), ...utf8, ...floats, ...formats, ...parsed, ...singlesCases, ...singlesFormats, ...singlesParsed, ...dyns, ...cells, ...shared, ...locks, ...onces, ...bounds, ...unsafeCells, ...edits, ...subslices, ...consumers, ...closures, ...elements, ...ranges, ...reducers, ...sliceEdits, ...drains, ...iters, ...hinted, ...peekedOthers, ...hints, ...reserves, ...setOps, ...zeros, ...writes, ...floatsMulAdds, ...singlesMulAdds, ...unlikeEqs, ...ownNes, ...rangeFroms, ...compares, ...unlikeCompares, ...rangeMethods, ...wraps(), ...refOrders, ...saturates(), ...methods(), ...separated, ...asciiCases]; diff --git a/ts/fixtures/lang/expected/ascii.ts b/ts/fixtures/lang/expected/ascii.ts index dbfa7d13f..b45562229 100644 --- a/ts/fixtures/lang/expected/ascii.ts +++ b/ts/fixtures/lang/expected/ascii.ts @@ -2,7 +2,7 @@ import * as rt from "./rt.ts"; import type * as ascii_Held from "./ascii.Held.ts"; -import { isSomeAnd$09tpccf, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, unwrapOr$0l7j3f6 as option_unwrapOr$0l7j3f6, mapOr$02k4ito as option_mapOr$02k4ito, mapOr$0jad0p1 as option_mapOr$0jad0p1 } from "./core/option.ts"; +import { isSomeAnd$09tpccf, unwrapOr$1iemzn8 as option_unwrapOr$1iemzn8, unwrapOr$0r2bmpr as option_unwrapOr$0r2bmpr, unwrapOr$0l7j3f6 as option_unwrapOr$0l7j3f6, mapOr$1t0muvr as option_mapOr$1t0muvr, mapOr$02k4ito as option_mapOr$02k4ito, mapOr$0jad0p1 as option_mapOr$0jad0p1, asDeref$0w8at8i as option_asDeref$0w8at8i } from "./core/option.ts"; import { put as fmt_put } from "./fmt.ts"; /** Each test of `b`, a bit apiece. */ @@ -327,4 +327,139 @@ export function slices(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { } } +/** `s[a..b]`'s case changed through the `&mut str` it is given. */ +export function upperPart(s: rt.Place, a: rt.usize, b: rt.usize): void { + const _5: rt.Place = rt.strPart(s, a, b); + _5.v = rt.strToAsciiUppercase(_5.v); +} + +/** + * A part `get_mut` or `split_at_mut_checked` may give, upper-cased and put, or 0xfe if + * it gave none. + */ +export function putUpper(out: rt.ByteVec, part: rt.Place | undefined): void { + if (part === undefined) { + rt.byteVecPush(out, 254); + } else { + part.v = rt.strToAsciiUppercase(part.v); + fmt_put(out, part.v); + } +} + +/** + * Case changed through a `&mut str` to a `String` where a local, a tuple, an array, a + * `Vec`, or an `Option` holds it, and to parts of one at byte offsets `data` picks up to + * two past the end, the `String` put after each change. A part off a char boundary, + * backwards, or out of bounds panics as std's does; a checked one gives `None`. + */ +export function parts(kind: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void { + let text!: string; + if ((kind & 16) === 0) { + text = "aÉbࠀc😀dZ"; + } else { + text = ""; + } + const _7: string = text; + const at: (a0: rt.usize) => rt.usize = (i: rt.usize): rt.usize => { + return option_mapOr$1t0muvr(rt.byteSliceGet(data, i), 0, (_2: rt.u8): rt.usize => { + return rt.usizeRem(_2 as rt.usize, rt.usizeAdd(rt.stringLen(_7), 3)); + }); + }; + const _10: [rt.usize, rt.usize] = [at(0), at(1)]; + const a: rt.usize = _10[0]; + const b: rt.usize = _10[1]; + let s: string = text; + const pair: [rt.u8, string] = [7, text]; + const array: string[] = ["q", text]; + const v: string[] = [text, text]; + const _32: rt.u8 = rt.u8Rem(kind, 8); + if (_32 === 0) { + s = rt.strToAsciiUppercase(s); + fmt_put(out, s); + const _41: rt.Place = rt.strPart(rt.place(() => s, (value15) => s = value15), a, b); + _41.v = rt.strToAsciiLowercase(_41.v); + fmt_put(out, s); + } else if (_32 === 1) { + pair[1] = rt.strToAsciiUppercase(pair[1]); + fmt_put(out, pair[1]); + const _54: rt.Place = rt.strPart(rt.place(() => pair[1], (value14) => pair[1] = value14), a); + _54.v = rt.strToAsciiLowercase(_54.v); + fmt_put(out, pair[1]); + rt.byteVecPush(out, pair[0]); + } else if (_32 === 2) { + array[1] = rt.strToAsciiUppercase(array[1]); + fmt_put(out, array[1]); + const _73: rt.Place = rt.strPart(rt.place(() => array[1], (value13) => array[1] = value13), 0, b); + _73.v = rt.strToAsciiLowercase(_73.v); + fmt_put(out, array[1]); + fmt_put(out, array[0]); + } else if (_32 === 3) { + const iter: rt.Iter> = rt.iterSliceMut(v); + while (true) { + const _93: rt.Place | rt.Done = iter.next(); + if (_93 === rt.DONE) { + break; + } + _93.v = rt.strToAsciiUppercase(_93.v); + } + const at6 = rt.idx(v, 0); + const _100: rt.Place = rt.strPart(rt.place(() => v[at6], (value11) => v[at6] = value11), 0); + _100.v = rt.strToAsciiLowercase(_100.v); + const at7 = rt.idx(v, 1); + const _105: rt.Place = rt.strPart(rt.place(() => v[at7], (value12) => v[at7] = value12), a, b); + _105.v = rt.strToAsciiLowercase(_105.v); + fmt_put(out, v[rt.idx(v, 0)]); + fmt_put(out, v[rt.idx(v, 1)]); + } else if (_32 === 4) { + const _119: [rt.Place, rt.Place] = rt.strSplitAtMut(rt.place(() => s, (value10) => s = value10), a); + _119[0].v = rt.strToAsciiUppercase(_119[0].v); + _119[1].v = rt.strToAsciiUppercase(_119[1].v); + _119[0].v = rt.strToAsciiLowercase(_119[0].v); + fmt_put(out, _119[0].v); + fmt_put(out, _119[1].v); + const _131: [rt.Place, rt.Place] = rt.strSplitAtMut(_119[1], rt.usizeSaturatingSub(b, a)); + _131[1].v = rt.strToAsciiLowercase(_131[1].v); + fmt_put(out, _131[0].v); + fmt_put(out, _131[1].v); + fmt_put(out, s); + } else if (_32 === 5) { + putUpper(out, rt.strGetMut(rt.place(() => s, (value7) => s = value7), a, b)); + putUpper(out, rt.strGetMut(rt.place(() => pair[1], (value8) => pair[1] = value8), a)); + const at4 = rt.idx(v, 1); + putUpper(out, rt.strGetMut(rt.place(() => v[at4], (value9) => v[at4] = value9), 0, b)); + fmt_put(out, s); + fmt_put(out, pair[1]); + fmt_put(out, v[rt.idx(v, 1)]); + } else if (_32 === 6) { + const _168: [rt.Place, rt.Place] | undefined = rt.strSplitAtMutChecked(rt.place(() => array[1], (value5) => array[1] = value5), a); + if (_168 === undefined) { + rt.byteVecPush(out, 253); + } else { + _168[1].v = rt.strToAsciiUppercase(_168[1].v); + putUpper(out, rt.strGetMut(_168[0], rt.min(b, rt.stringLen(_168[0].v)))); + } + fmt_put(out, array[1]); + let held: string | undefined = text; + const _191: rt.Place | undefined = held === undefined ? undefined : rt.place(() => held as string, (value6) => held = value6); + if (_191 !== undefined) { + _191.v = rt.strToAsciiUppercase(_191.v); + } + fmt_put(out, option_unwrapOr$1iemzn8(option_asDeref$0w8at8i(held), "-")); + } else { + const at2 = rt.idx(v, 1); + upperPart(rt.strPart(rt.place(() => v[at2], (value) => v[at2] = value), a), 0, rt.usizeSaturatingSub(b, a)); + fmt_put(out, v[rt.idx(v, 1)]); + upperPart(rt.place(() => s, (value2) => s = value2), a, b); + fmt_put(out, rt.strPart(rt.place(() => s, (value3) => s = value3), 0, a).v); + fmt_put(out, rt.strPart(rt.place(() => s, (value4) => s = value4), a).v); + const leaked: rt.Place = { v: pair[1] }; + const _234: rt.Place = rt.strPart(leaked, rt.min(b, a)); + _234.v = rt.strToAsciiUppercase(_234.v); + fmt_put(out, leaked.v); + const empty: rt.Place = { v: "" }; + empty.v = rt.strToAsciiUppercase(empty.v); + fmt_put(out, empty.v); + } +} + //# sourceMappingURL=ascii.ts.map diff --git a/ts/fixtures/lang/expected/harness.ts b/ts/fixtures/lang/expected/harness.ts index f4eed50f1..2107a2261 100644 --- a/ts/fixtures/lang/expected/harness.ts +++ b/ts/fixtures/lang/expected/harness.ts @@ -2,7 +2,7 @@ import * as rt from "./rt.ts"; import { fromFns, maps, lent as arrays_lent, asSlices, given } from "./arrays.ts"; -import { bytes as ascii_bytes, chars as ascii_chars, slices as ascii_slices } from "./ascii.ts"; +import { bytes as ascii_bytes, chars as ascii_chars, slices as ascii_slices, parts as ascii_parts } from "./ascii.ts"; import { atomics } from "./atomics.ts"; import { borrows as borrows_borrows } from "./borrows.ts"; import { bounds as bounds_bounds } from "./bounds.ts"; @@ -233,7 +233,7 @@ export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) loaded(data84, out85); }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["orders::btrees", btrees as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["lengths::lengths", lengths as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["iters::option_items", (_2185: rt.u8, data85: rt.ByteSlice, out86: rt.ByteVec): undefined => { optionItems(data85, out86); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["ascii::parts", ascii_parts as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]]; } /** Run one case. */ diff --git a/ts/fixtures/lang/src/ascii.rs b/ts/fixtures/lang/src/ascii.rs index 476b888c4..63de112b8 100644 --- a/ts/fixtures/lang/src/ascii.rs +++ b/ts/fixtures/lang/src/ascii.rs @@ -1,9 +1,11 @@ //! The ASCII methods of `u8`, `char`, byte slices, and `str`: their tests, case maps, and //! case-insensitive equality, each case changed in place through a `&mut` to where the //! value is, slices trimmed, and what `escape_ascii` yields from either end and writes. -//! Every byte is tried, and the chars at each edge of ASCII and past it. +//! Every byte is tried, and the chars at each edge of ASCII and past it. A `String`'s case +//! also changes through a `&mut str` to it wherever it is, and to parts of it. use std::ascii; +use std::borrow::BorrowMut; use std::fmt::Write; use crate::fmt::put; @@ -318,3 +320,123 @@ pub fn slices(kind: u8, data: &[u8], out: &mut Vec) { } } } + +/// ASCII letters between chars of each wider UTF-8 length, so a case change shows at +/// each side of every part. +const MIXED: &str = "a\u{c9}b\u{800}c\u{1f600}dZ"; + +/// `s[a..b]`'s case changed through the `&mut str` it is given. +fn upper_part(s: &mut str, a: usize, b: usize) { + s[a..b].make_ascii_uppercase(); +} + +/// A part `get_mut` or `split_at_mut_checked` may give, upper-cased and put, or 0xfe if +/// it gave none. +fn put_upper(out: &mut Vec, part: Option<&mut str>) { + match part { + Some(part) => { + part.make_ascii_uppercase(); + put(out, part); + } + None => out.push(0xfe), + } +} + +/// Case changed through a `&mut str` to a `String` where a local, a tuple, an array, a +/// `Vec`, or an `Option` holds it, and to parts of one at byte offsets `data` picks up to +/// two past the end, the `String` put after each change. A part off a char boundary, +/// backwards, or out of bounds panics as std's does; a checked one gives `None`. +pub fn parts(kind: u8, data: &[u8], out: &mut Vec) { + let text = match kind & 0x10 { + 0 => MIXED, + _ => "", + }; + let at = |i: usize| data.get(i).map_or(0, |&b| usize::from(b) % (text.len() + 3)); + let (a, b) = (at(0), at(1)); + let mut s = text.to_string(); + let mut pair = (7u8, text.to_string()); + let mut array = [String::from("q"), text.to_string()]; + let mut v = vec![text.to_string(), text.to_string()]; + match kind % 8 { + 0 => { + s.as_mut_str().make_ascii_uppercase(); + put(out, &s); + s[a..b].make_ascii_lowercase(); + put(out, &s); + } + 1 => { + pair.1.make_ascii_uppercase(); + put(out, &pair.1); + pair.1[a..].make_ascii_lowercase(); + put(out, &pair.1); + out.push(pair.0); + } + 2 => { + array[1].make_ascii_uppercase(); + put(out, &array[1]); + array[1][..b].make_ascii_lowercase(); + put(out, &array[1]); + put(out, &array[0]); + } + 3 => { + for t in v.iter_mut() { + t.make_ascii_uppercase(); + } + AsMut::::as_mut(&mut v[0])[..].make_ascii_lowercase(); + v[1][a..b].make_ascii_lowercase(); + put(out, &v[0]); + put(out, &v[1]); + } + 4 => { + // Two parts at once, each written after the other's write. + let (x, y) = s.split_at_mut(a); + x.make_ascii_uppercase(); + y.make_ascii_uppercase(); + x.make_ascii_lowercase(); + put(out, x); + put(out, y); + let (y0, y1) = y.split_at_mut(b.saturating_sub(a)); + y1.make_ascii_lowercase(); + put(out, y0); + put(out, y1); + put(out, &s); + } + 5 => { + put_upper(out, s.get_mut(a..b)); + put_upper(out, pair.1.get_mut(a..)); + put_upper(out, v[1].get_mut(..b)); + put(out, &s); + put(out, &pair.1); + put(out, &v[1]); + } + 6 => { + match BorrowMut::::borrow_mut(&mut array[1]).split_at_mut_checked(a) { + Some((x, y)) => { + y.make_ascii_uppercase(); + put_upper(out, x.get_mut(b.min(x.len())..)); + } + None => out.push(0xfd), + } + put(out, &array[1]); + let mut held = Some(text.to_string()); + if let Some(t) = held.as_mut() { + t.make_ascii_uppercase(); + } + put(out, held.as_deref().unwrap_or("-")); + } + _ => { + // A part of a part, through a `&mut str` given. + upper_part(&mut v[1][a..], 0, b.saturating_sub(a)); + put(out, &v[1]); + upper_part(&mut s, a, b); + put(out, &String::from(&mut s[..a])); + put(out, &(&mut s[a..]).to_string()); + let leaked = pair.1.leak(); + leaked[b.min(a)..].make_ascii_uppercase(); + put(out, leaked); + let empty: &mut str = Default::default(); + empty.make_ascii_uppercase(); + put(out, empty); + } + } +} diff --git a/ts/fixtures/lang/src/harness.rs b/ts/fixtures/lang/src/harness.rs index 5294a25a4..6407edec6 100644 --- a/ts/fixtures/lang/src/harness.rs +++ b/ts/fixtures/lang/src/harness.rs @@ -256,6 +256,7 @@ fn cases() -> Vec<(&'static str, Case)> { ("orders::btrees", orders::btrees), ("lengths::lengths", lengths::lengths), ("iters::option_items", |_, data, out| iters::option_items(data, out)), + ("ascii::parts", ascii::parts), ] } diff --git a/ts/fixtures/reject/expected.txt b/ts/fixtures/reject/expected.txt index 3b8f475ca..614b37a53 100644 --- a/ts/fixtures/reject/expected.txt +++ b/ts/fixtures/reject/expected.txt @@ -160,8 +160,9 @@ a raw pointer to `ByRefTake` in `(u16, ByRefTake)`, which the crate may put anot a raw pointer to `ByKeySet` in `(u16, ByKeySet)`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1622:51 a raw pointer to `ByKeyReplace` in `(u16, ByKeyReplace)`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1630:55 a raw pointer to `ByKeyTake` in `(u16, ByKeyTake)`, which the crate may put another object in place of at fixtures/reject/src/lib.rs:1637:52 -`std::ops::DerefMut::deref_mut` of a value JS copies, which is no path at fixtures/reject/src/lib.rs:1646:2 -`std::ops::IndexMut::index_mut` with a mutable reference to a value JS copies, which its mapping would copy at fixtures/reject/src/lib.rs:1652:3 +unsupported call to `core::str::::as_bytes_mut` at fixtures/reject/src/lib.rs:1645:13 +`core::str::::get_unchecked_mut` with a mutable reference to a value JS copies, which its mapping would copy at fixtures/reject/src/lib.rs:1646:13 +`std::str::from_utf8_mut` with a mutable reference to a value JS copies, which its mapping would copy at fixtures/reject/src/lib.rs:1651:20 unsupported call to `std::ptr::copy::<[u8; 4]>` at fixtures/reject/src/lib.rs:1826:3 unsupported call to `std::ptr::copy_nonoverlapping::<[u8; 4]>` at fixtures/reject/src/lib.rs:1827:3 unsupported call to `std::ptr::addr_eq::<[u8; 4], [u8; 4]>` at fixtures/reject/src/lib.rs:1828:14 diff --git a/ts/fixtures/reject/src/lib.rs b/ts/fixtures/reject/src/lib.rs index 6b2c9db5f..1de7cb55a 100644 --- a/ts/fixtures/reject/src/lib.rs +++ b/ts/fixtures/reject/src/lib.rs @@ -1640,17 +1640,17 @@ pub fn key_taken(n: u16) -> u16 { unsafe { *part } } -/// A `String`'s case changed where a tuple holds it, through a `&mut str` to an element -/// JS copies, which is no path to write it back to. -pub fn ascii_in_tuple(mut pair: (u8, String)) -> String { - pair.1.make_ascii_uppercase(); - pair.1 +/// A `str`'s UTF-8 written as bytes, or a part of it unchecked. +pub fn str_bytes_mut(s: &mut str) { + unsafe { s.as_bytes_mut()[0] = b'a' }; + unsafe { s.get_unchecked_mut(..1) }.make_ascii_uppercase(); } -/// Part of a `String` changed in place, which a JS string can't be. -pub fn ascii_part(mut s: String) -> String { - s[1..].make_ascii_uppercase(); - s +/// Bytes written through a `&mut str` to them, which no JS string is. +pub fn str_from_bytes_mut(bytes: &mut [u8]) { + if let Ok(text) = std::str::from_utf8_mut(bytes) { + text.make_ascii_uppercase(); + } } pub struct Owned(pub u32, pub u32); diff --git a/ts/fixtures/reject/ts.toml b/ts/fixtures/reject/ts.toml index bffbafa0e..9b207cff6 100644 --- a/ts/fixtures/reject/ts.toml +++ b/ts/fixtures/reject/ts.toml @@ -147,8 +147,8 @@ roots = [ "key_set", "key_replaced", "key_taken", - "ascii_in_tuple", - "ascii_part", + "str_bytes_mut", + "str_from_bytes_mut", "byte_pointer_ops", "byte_pointer_parts", "byte_pointer_rebound", diff --git a/ts/runtime/rt/str.ts b/ts/runtime/rt/str.ts index 709dc1a53..5d4b8b87e 100644 --- a/ts/runtime/rt/str.ts +++ b/ts/runtime/rt/str.ts @@ -60,14 +60,71 @@ function unitAt(s: string, i: number, from: number, to: number): number { /** `&s[start..end]` by UTF-8 byte offsets, with `end` defaulting to the length. */ export function strSlice(s: string, start: number, end?: number): string { + return s.slice(...units(s, start, end)); +} + +/** + * The code units of `s` from byte `start` to byte `end`, or to the end, or `undefined` if + * either is out of bounds or inside a char, or they are backwards. + */ +function unitsChecked(s: string, start: number, end?: number): [number, number] | undefined { const from = unitAt(s, 0, 0, start); - if (end === undefined) { - if (from < 0) sliceFailed(s, start, stringLen(s)); - return s.slice(from); + if (from < 0) return undefined; + const to = end === undefined ? s.length : unitAt(s, from, start, end); + return to < 0 ? undefined : [from, to]; +} + +/** `unitsChecked`, panicking as std's indexing does where it gives `undefined`. */ +function units(s: string, start: number, end?: number): [number, number] { + return unitsChecked(s, start, end) ?? sliceFailed(s, start, end ?? stringLen(s)); +} + +/** + * `&mut p[from..to]` by code units: a part of the string at `p`, whose writes splice the + * string anew. A write through a `&mut str` keeps each char's length, so the units hold. + */ +class StrPart implements Place { + readonly #whole: Place; + readonly #from: number; + readonly #to: number; + + constructor(whole: Place, [from, to]: [number, number]) { + this.#whole = whole; + this.#from = from; + this.#to = to; + } + + get v(): string { + return this.#whole.v.slice(this.#from, this.#to); } - const to = from < 0 ? -1 : unitAt(s, from, start, end); - if (to < 0) sliceFailed(s, start, end); - return s.slice(from, to); + + set v(value: string) { + const s = this.#whole.v; + this.#whole.v = s.slice(0, this.#from) + value + s.slice(this.#to); + } +} + +/** `&mut p[start..end]` by UTF-8 byte offsets, with `end` defaulting to the length. */ +export function strPart(p: Place, start: number, end?: number): Place { + return new StrPart(p, units(p.v, start, end)); +} + +/** `str::get_mut` by a range's UTF-8 byte offsets, with `end` defaulting to the length. */ +export function strGetMut(p: Place, start: number, end?: number): Place | undefined { + const at = unitsChecked(p.v, start, end); + return at && new StrPart(p, at); +} + +/** `str::split_at_mut`. */ +export function strSplitAtMut(p: Place, mid: number): [Place, Place] { + const [, at] = units(p.v, 0, mid); + return [new StrPart(p, [0, at]), new StrPart(p, [at, p.v.length])]; +} + +/** `str::split_at_mut_checked`. */ +export function strSplitAtMutChecked(p: Place, mid: number): [Place, Place] | undefined { + const at = unitsChecked(p.v, 0, mid); + return at && [new StrPart(p, at), new StrPart(p, [at[1], p.v.length])]; } /** std's panic for a slice of `s` that is out of bounds, backwards, or inside a char. */ diff --git a/ts/src/lower/library.rs b/ts/src/lower/library.rs index 101b84c37..396e4d79f 100644 --- a/ts/src/lower/library.rs +++ b/ts/src/lower/library.rs @@ -1290,9 +1290,13 @@ fn mapping<'tcx>( // `Some` of a value is the value. let some = matches!(to.kind(), ty::Adt(adt, args) if Std::of(tcx, adt.did()) == Some(Std::Option) && args.type_at(0) == targ(gargs, 1)); - if to == from || some || (string(tcx, to) && string(tcx, from.peel_refs())) { + if to == from || some { return Some(value); } + // A `&mut str` is the `rt.Place` of its text. + if string(tcx, to) && string(tcx, from.peel_refs()) { + return Some(b.t.pointee_value(targ(gargs, 1), value)); + } // A `Vec` is owned, and a reference to a slice, an array, or a `Vec` borrows its slice. if let Some(elem) = cow_slice(tcx, to) { let owned = b.t.std_of(targ(gargs, 1)) == Some(Std::Vec); @@ -2154,7 +2158,7 @@ fn mapping<'tcx>( return Some(b.err(span, cow_variant(cow))); } ("ToString", "to_string") | ("ToOwned", "to_owned") if matches!(self_ty()?.peel_refs().kind(), ty::Str) => { - args.pop()? + b.t.pointee_value(self_ty()?, args.pop()?) } // Panics, which format their message as std does. diff --git a/ts/src/lower/mir/call.rs b/ts/src/lower/mir/call.rs index 524522eda..0e128098b 100644 --- a/ts/src/lower/mir/call.rs +++ b/ts/src/lower/mir/call.rs @@ -639,24 +639,39 @@ impl<'m, 'b, 'a, 'tcx> Fx<'m, 'b, 'a, 'tcx> { self.set_borrowed(&place, value, span, out); done(Expr::undefined(), false) } - // A `Cow` is the `String` it would hold, so the `&mut` borrows the same place. - ("Cow", "to_mut") if targ(0).is_some_and(|t| t.is_str()) => { - let (place, borrowed) = self.borrowed_place(&args[0].node, span, out)?; - if let Some(local) = dest.as_local() - && self.defs[local] == 1 - && matches!(self.slots[local], Slot::Var(_)) - { - self.slots[local] = Slot::Alias(Some(place)); - self.reborrows.extend(borrowed.map(|b| (local, b))); - return Some(None); - } - match borrowed { - Some(borrowed) => { - let target = self.stable_target(borrowed, place, span, out); - done(self.place_of(target, None), true) - } - None => done(place, true), - } + // A `Cow` is the `String` it would hold, and a `String` is its `str`, so the + // `&mut` borrows the same place. + ("Cow", "to_mut") if targ(0).is_some_and(|t| t.is_str()) => self.same_place(args, dest, span, out), + ("String", "as_mut_str") => self.same_place(args, dest, span, out), + ("DerefMut", "deref_mut") | ("AsMut", "as_mut") | ("BorrowMut", "borrow_mut") + if targ(0).is_some_and(|t| t.is_str() || self.b.t.std_of(t) == Some(Std::String)) + && dest.ty(&self.mir.local_decls, tcx).ty.builtin_deref(true).is_some_and(|t| t.is_str()) => + { + self.same_place(args, dest, span, out) + } + // A place nothing else holds: the `String` leaked, or `Default`'s empty `str`. + ("String", "leak") => { + let leaked = self.operand(&args[0].node, span, out); + done(Expr::Object(vec![(crate::ts::Key::Name("v".into()), leaked)]), true) + } + ("Default", "default") + if targ(0).is_some_and(|t| t.ref_mutability() == Some(ty::Mutability::Mut) && t.peel_refs().is_str()) => + { + done(Expr::Object(vec![(crate::ts::Key::Name("v".into()), Expr::Str(String::new()))]), false) + } + // A part of a `str` is a place of its own, which splices the whole anew. + ("str", "get_mut") => { + let whole = self.operand(&args[0].node, span, out); + let (start, end) = self.range_bounds(&args[1].node, targ(0)?, span, out)?; + done(Expr::rt("strGetMut", [whole, start].into_iter().chain(end).collect()), true) + } + ("str", "split_at_mut" | "split_at_mut_checked") => { + let values = self.operands(false, &[], args, dest.ty(&self.mir.local_decls, tcx).ty, span, out); + let f = match name.as_str() { + "split_at_mut" => "strSplitAtMut", + _ => "strSplitAtMutChecked", + }; + done(Expr::rt(f, values), true) } // A `Wrapping` or a `Saturating` is its integer, so what the `&mut` borrows gets the // wrapped or saturated result. @@ -1065,6 +1080,33 @@ impl<'m, 'b, 'a, 'tcx> Fx<'m, 'b, 'a, 'tcx> { } } + /// The place the `&mut` receiver borrows, as the `&mut` the call returns: an alias of it + /// where the destination is read only as one. + fn same_place( + &mut self, + args: &[Spanned>], + dest: Place<'tcx>, + span: Span, + out: &mut Vec, + ) -> Option> { + let (place, borrowed) = self.borrowed_place(&args[0].node, span, out)?; + if let Some(local) = dest.as_local() + && self.defs[local] == 1 + && matches!(self.slots[local], Slot::Var(_)) + { + self.slots[local] = Slot::Alias(Some(place)); + self.reborrows.extend(borrowed.map(|b| (local, b))); + return Some(None); + } + match borrowed { + Some(borrowed) => { + let target = self.stable_target(borrowed, place, span, out); + Some(Some((self.place_of(target, None), true))) + } + None => Some(Some((place, true))), + } + } + /// A `fmt::Write` method of a `String`, a `Formatter`, or the crate's own writer, or of /// std's impl for a `&mut W`, which calls `W`'s. A provided method of the crate's impl /// writes through its `write_str`. `None` for any other writer. @@ -1396,16 +1438,18 @@ impl<'m, 'b, 'a, 'tcx> Fx<'m, 'b, 'a, 'tcx> { ) -> Option> { let container = gargs.type_at(0); let index_ty = gargs.type_at(1); - // A string slices by UTF-8 byte offsets, which a JS string doesn't index by. + // A string slices by UTF-8 byte offsets, which a JS string doesn't index by, and a + // part a `&mut` borrows is a place of its own, which splices the whole anew. if container.is_str() || self.b.t.std_of(container) == Some(Std::String) { - if name == "index_mut" { - return None; - } let base = self.operand(&args[0].node, span, out); let (start, end) = self.range_bounds(&args[1].node, index_ty, span, out)?; + let f = match name { + "index_mut" => "strPart", + _ => "strSlice", + }; let mut values = vec![self.path(base, "s", out), start]; values.extend(end); - return Some(Some((Expr::rt("strSlice", values), true))); + return Some(Some((Expr::rt(f, values), true))); } let elem_ty = elem(self.tcx, container)?; let bytes = matches!(elem_ty.kind(), ty::Uint(ty::UintTy::U8)); From 406260c5a3631d9bfb5c3595000a04dbe1c41788 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Sat, 31 Oct 2026 17:24:10 -0700 Subject: [PATCH 3/4] style(ts): format the &mut str intercepts Co-Authored-By: Claude Opus 5.5 --- ts/src/lower/mir/call.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ts/src/lower/mir/call.rs b/ts/src/lower/mir/call.rs index 0e128098b..b464de068 100644 --- a/ts/src/lower/mir/call.rs +++ b/ts/src/lower/mir/call.rs @@ -645,7 +645,7 @@ impl<'m, 'b, 'a, 'tcx> Fx<'m, 'b, 'a, 'tcx> { ("String", "as_mut_str") => self.same_place(args, dest, span, out), ("DerefMut", "deref_mut") | ("AsMut", "as_mut") | ("BorrowMut", "borrow_mut") if targ(0).is_some_and(|t| t.is_str() || self.b.t.std_of(t) == Some(Std::String)) - && dest.ty(&self.mir.local_decls, tcx).ty.builtin_deref(true).is_some_and(|t| t.is_str()) => + && dest.ty(&self.mir.local_decls, tcx).ty.peel_refs().is_str() => { self.same_place(args, dest, span, out) } @@ -655,15 +655,23 @@ impl<'m, 'b, 'a, 'tcx> Fx<'m, 'b, 'a, 'tcx> { done(Expr::Object(vec![(crate::ts::Key::Name("v".into()), leaked)]), true) } ("Default", "default") - if targ(0).is_some_and(|t| t.ref_mutability() == Some(ty::Mutability::Mut) && t.peel_refs().is_str()) => + if targ(0) + .and_then(|t| self.b.t.place_pointee(t)) + .is_some_and(|t| t.is_str()) => { - done(Expr::Object(vec![(crate::ts::Key::Name("v".into()), Expr::Str(String::new()))]), false) + done( + Expr::Object(vec![(crate::ts::Key::Name("v".into()), Expr::Str(String::new()))]), + false, + ) } // A part of a `str` is a place of its own, which splices the whole anew. ("str", "get_mut") => { let whole = self.operand(&args[0].node, span, out); let (start, end) = self.range_bounds(&args[1].node, targ(0)?, span, out)?; - done(Expr::rt("strGetMut", [whole, start].into_iter().chain(end).collect()), true) + done( + Expr::rt("strGetMut", [whole, start].into_iter().chain(end).collect()), + true, + ) } ("str", "split_at_mut" | "split_at_mut_checked") => { let values = self.operands(false, &[], args, dest.ty(&self.mir.local_decls, tcx).ty, span, out); From 75938725f4bcc7f6a7753bf1f5506623677129bc Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Sat, 31 Oct 2026 17:37:13 -0700 Subject: [PATCH 4/4] test(ts): update the reject census for the str refusals Co-Authored-By: Claude Opus 5.5 --- ts/fixtures/reject/census.md | 42 ++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/ts/fixtures/reject/census.md b/ts/fixtures/reject/census.md index 53ad641a2..d0ebdc0e6 100644 --- a/ts/fixtures/reject/census.md +++ b/ts/fixtures/reject/census.md @@ -1,6 +1,6 @@ # Census of `reject-fixture` -- Refusals: 198 +- Refusals: 199 - Function instances: 240 - Generic functions no instance reached, lowered over their type parameters: 11 @@ -9,12 +9,12 @@ | Count | Construct | First | | ---: | --- | --- | | 45 | a raw pointer to `_` in `_`, which the crate may put another object in place of | fixtures/reject/src/lib.rs:617:10 | -| 25 | unsupported call to `_` | fixtures/reject/src/lib.rs:167:8 | +| 26 | unsupported call to `_` | fixtures/reject/src/lib.rs:167:8 | | 19 | a raw pointer to `_` in a variable assigned again while it may point there | fixtures/reject/src/lib.rs:625:10 | | 14 | a reference to `_`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there | fixtures/reject/src/lib.rs:1346:33 | | 5 | a raw pointer to `_` in an element, a payload, or a union field, which is not supported yet | fixtures/reject/src/lib.rs:688:10 | +| 4 | `_` with a mutable reference to a value JS copies, which its mapping would copy | fixtures/reject/src/lib.rs:523:12 | | 4 | a variant of `_`, which is not supported: either is the same JS string | fixtures/reject/src/lib.rs:338:2 | -| 3 | `_` with a mutable reference to a value JS copies, which its mapping would copy | fixtures/reject/src/lib.rs:523:12 | | 3 | a copy of a closure that changes what it captured | fixtures/reject/src/lib.rs:231:14 | | 3 | an assignment through a reference to `_` | fixtures/reject/src/lib.rs:90:2 | | 3 | replacing the value behind a reference to `_` | fixtures/reject/src/lib.rs:98:2 | @@ -41,7 +41,6 @@ | 1 | `_` is not supported: its field `_` is `_`, typed `_`, whose `Pending` would be `rt.OuterPending` as `_` | fixtures/reject/src/lib.rs:504:2 | | 1 | `_` of `_` by `_`, which is not supported yet | fixtures/reject/src/lib.rs:260:6 | | 1 | `_` of `_`, which is not supported yet | fixtures/reject/src/lib.rs:547:4 | -| 1 | `_` of a value JS copies, which is no path | fixtures/reject/src/lib.rs:1646:2 | | 1 | `_`, which is not supported yet | fixtures/reject/src/lib.rs:268:9 | | 1 | `_`, which reads a capacity that depends on whether the other handles of its storage dropped, which is not supported | fixtures/reject/src/lib.rs:390:6 | | 1 | `collect` of `_`, which sorts by `_`'s own `Ord`, of entries that drop, which is not supported yet | fixtures/reject/src/lib.rs:964:22 | @@ -95,6 +94,7 @@ The type or module each refused type or path belongs to. | 4 | `Iterator` | fixtures/reject/src/lib.rs:37:4 | | 4 | `[u8; 4]` | fixtures/reject/src/lib.rs:483:26 | | 4 | `std::pin::Pin` | fixtures/reject/src/lib.rs:98:2 | +| 4 | `std::str` | fixtures/reject/src/lib.rs:441:4 | | 3 | `*const [u8; 4]` | fixtures/reject/src/lib.rs:1829:33 | | 3 | `std::ptr` | fixtures/reject/src/lib.rs:1826:3 | | 3 | `std::vec::Vec` | fixtures/reject/src/lib.rs:317:16 | @@ -212,14 +212,11 @@ The type or module each refused type or path belongs to. | 1 | `std::net::AddrParseError` | fixtures/reject/src/lib.rs:440:32 | | 1 | `std::net::Ipv4Addr` | fixtures/reject/src/lib.rs:440:32 | | 1 | `std::num` | fixtures/reject/src/lib.rs:1286:4 | -| 1 | `std::ops::DerefMut` | fixtures/reject/src/lib.rs:1646:2 | -| 1 | `std::ops::IndexMut` | fixtures/reject/src/lib.rs:1652:3 | | 1 | `std::ops::RangeFrom` | fixtures/reject/src/lib.rs:993:32 | | 1 | `std::ops::RangeTo` | fixtures/reject/src/lib.rs:993:11 | | 1 | `std::ptr::mut_ptr` | fixtures/reject/src/lib.rs:1829:56 | | 1 | `std::slice::IterMut` | fixtures/reject/src/lib.rs:775:15 | | 1 | `std::std::Layout` | fixtures/reject/src/lib.rs:574:15 | -| 1 | `std::str` | fixtures/reject/src/lib.rs:441:4 | | 1 | `std::sync::Mutex` | fixtures/reject/src/lib.rs:523:12 | | 1 | `std::sync::Weak` | fixtures/reject/src/lib.rs:457:40 | | 1 | `std::task::Poll` | fixtures/reject/src/lib.rs:84:34 | @@ -261,9 +258,9 @@ The type or module each refused type or path belongs to. | 1 | `_` of `_`, which is not supported yet | `std::any::Any::type_id`, `dyn std::any::Any` | fixtures/reject/src/lib.rs:547:4 | | 1 | `_` of `_`, whose `clone_from` is its own, which is not supported yet | `slice::clone_from_slice`, `Reused` | fixtures/reject/src/lib.rs:293:4 | | 1 | `_` of `_`, whose `clone_from` is its own, which is not supported yet | `slice::fill`, `Reused` | fixtures/reject/src/lib.rs:21:4 | -| 1 | `_` of a value JS copies, which is no path | `std::ops::DerefMut::deref_mut` | fixtures/reject/src/lib.rs:1646:2 | | 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::iter::once` | fixtures/reject/src/lib.rs:1244:22 | -| 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::ops::IndexMut::index_mut` | fixtures/reject/src/lib.rs:1652:3 | +| 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::str::from_utf8_mut` | fixtures/reject/src/lib.rs:1651:20 | +| 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::str::get_unchecked_mut` | fixtures/reject/src/lib.rs:1646:13 | | 1 | `_` with a mutable reference to a value JS copies, which its mapping would copy | `std::sync::Mutex::get_mut` | fixtures/reject/src/lib.rs:523:12 | | 1 | `_`, which is not supported yet | `Hasher::write` | fixtures/reject/src/lib.rs:268:9 | | 1 | `_`, which reads a capacity that depends on whether the other handles of its storage dropped, which is not supported | `BytesMut::capacity` | fixtures/reject/src/lib.rs:390:6 | @@ -384,6 +381,7 @@ The type or module each refused type or path belongs to. | 1 | unsupported call to `_` | `std::std::Layout::new` | fixtures/reject/src/lib.rs:574:15 | | 1 | unsupported call to `_` | `std::std::alloc` | fixtures/reject/src/lib.rs:576:11 | | 1 | unsupported call to `_` | `std::std::dealloc` | fixtures/reject/src/lib.rs:579:3 | +| 1 | unsupported call to `_` | `std::str::as_bytes_mut` | fixtures/reject/src/lib.rs:1645:13 | | 1 | unsupported call to `_` | `std::str::parse` | fixtures/reject/src/lib.rs:441:4 | | 1 | unsupported type `_` from another crate | `std::net::AddrParseError` | fixtures/reject/src/lib.rs:440:32 | | 1 | unsupported type `_` from another crate | `std::net::Ipv4Addr` | fixtures/reject/src/lib.rs:440:32 | @@ -440,7 +438,7 @@ The type or module each refused type or path belongs to. -
unsupported call to `_` (25) +
unsupported call to `_` (26) - fixtures/reject/src/lib.rs:167:8: unsupported call to `std::ops::Range::::contains::` - fixtures/reject/src/lib.rs:308:10: unsupported call to `::hash::` @@ -460,6 +458,7 @@ The type or module each refused type or path belongs to. - fixtures/reject/src/lib.rs:993:32: unsupported call to ` as std::ops::RangeBounds>::contains::` - fixtures/reject/src/lib.rs:998:9: unsupported call to `std::ops::Range::<&mut u8>::is_empty` - fixtures/reject/src/lib.rs:1286:4: unsupported call to `core::num::::is_ascii_octdigit` +- fixtures/reject/src/lib.rs:1645:13: unsupported call to `core::str::::as_bytes_mut` - fixtures/reject/src/lib.rs:1826:3: unsupported call to `std::ptr::copy::<[u8; 4]>` - fixtures/reject/src/lib.rs:1827:3: unsupported call to `std::ptr::copy_nonoverlapping::<[u8; 4]>` - fixtures/reject/src/lib.rs:1828:14: unsupported call to `std::ptr::addr_eq::<[u8; 4], [u8; 4]>` @@ -523,6 +522,15 @@ The type or module each refused type or path belongs to.
+
`_` with a mutable reference to a value JS copies, which its mapping would copy (4) + +- fixtures/reject/src/lib.rs:523:12: `std::sync::Mutex::::get_mut` with a mutable reference to a value JS copies, which its mapping would copy +- fixtures/reject/src/lib.rs:1244:22: `std::iter::once` with a mutable reference to a value JS copies, which its mapping would copy +- fixtures/reject/src/lib.rs:1646:13: `core::str::::get_unchecked_mut` with a mutable reference to a value JS copies, which its mapping would copy +- fixtures/reject/src/lib.rs:1651:20: `std::str::from_utf8_mut` with a mutable reference to a value JS copies, which its mapping would copy + +
+
a variant of `_`, which is not supported: either is the same JS string (4) - fixtures/reject/src/lib.rs:338:2: a variant of `std::borrow::Cow<'_, str>`, which is not supported: either is the same JS string @@ -532,14 +540,6 @@ The type or module each refused type or path belongs to.
-
`_` with a mutable reference to a value JS copies, which its mapping would copy (3) - -- fixtures/reject/src/lib.rs:523:12: `std::sync::Mutex::::get_mut` with a mutable reference to a value JS copies, which its mapping would copy -- fixtures/reject/src/lib.rs:1244:22: `std::iter::once` with a mutable reference to a value JS copies, which its mapping would copy -- fixtures/reject/src/lib.rs:1652:3: `std::ops::IndexMut::index_mut` with a mutable reference to a value JS copies, which its mapping would copy - -
-
a copy of a closure that changes what it captured (3) - fixtures/reject/src/lib.rs:231:14: a copy of a closure that changes what it captured @@ -717,12 +717,6 @@ The type or module each refused type or path belongs to.
-
`_` of a value JS copies, which is no path (1) - -- fixtures/reject/src/lib.rs:1646:2: `std::ops::DerefMut::deref_mut` of a value JS copies, which is no path - -
-
`_`, which is not supported yet (1) - fixtures/reject/src/lib.rs:268:9: `Hasher::write`, which is not supported yet