From 28219a61951ffdaea8215b539e4a5528661b9cd1 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Fri, 6 Nov 2026 20:22:30 -0800 Subject: [PATCH] quest: plan NonZero's unchecked arithmetic in m3 Co-Authored-By: Claude Opus 5.5 --- quest/m3/ts-unsafe/README.md | 1 + quest/m3/ts-unsafe/nonzero-unchecked-ops.md | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 quest/m3/ts-unsafe/nonzero-unchecked-ops.md diff --git a/quest/m3/ts-unsafe/README.md b/quest/m3/ts-unsafe/README.md index 0d7820e12..9945bbadd 100644 --- a/quest/m3/ts-unsafe/README.md +++ b/quest/m3/ts-unsafe/README.md @@ -78,5 +78,6 @@ Public API: the translator's output. - [BinaryHeap from std's MIR](/quest/m3/ts-unsafe/binary-heap-mir.md) - std's `BinaryHeap` and `PeekMut` translate, replacing the runtime's port - [A slice's pointer cast to an array's](/quest/m3/ts-unsafe/array-casts.md) - `*(s as *const [u8] as *const [u8; N])` in a crate's own code, and `IoSlice` - [Unchecked integer operations](/quest/m3/ts-unsafe/unchecked-ops.md) - `unchecked_*` and `NonZero::new_unchecked` translate, aborting on a violated precondition +- [NonZero's unchecked arithmetic](/quest/m3/ts-unsafe/nonzero-unchecked-ops.md) - `NonZero::unchecked_add` and `unchecked_mul` translate, aborting at std's site - [UnsafeCell's raw accessors](/quest/m3/ts-unsafe/unsafecell.md) - `UnsafeCell::raw_get`, `from_mut`, and `replace` translate - [A Box of one uninitialized value](/quest/m3/ts-unsafe/box-new-uninit.md) - `Box::new_uninit` and `new_zeroed` for one value translate, through `write` and `assume_init` diff --git a/quest/m3/ts-unsafe/nonzero-unchecked-ops.md b/quest/m3/ts-unsafe/nonzero-unchecked-ops.md new file mode 100644 index 000000000..4b59c4f1e --- /dev/null +++ b/quest/m3/ts-unsafe/nonzero-unchecked-ops.md @@ -0,0 +1,19 @@ +# [XS] NonZero's unchecked arithmetic + +## Goal + +[rust2-ts](/ts/README.md) translates `NonZero::unchecked_add` and `NonZero::unchecked_mul`, +proven by differential tests against native Rust. Today each is refused by name. + +## Plan + +Left by [#622](https://github.com/moq-dev/rust2/pull/622), which translated the integers' +`unchecked_*` and `NonZero::new_unchecked` through `rs.precondition`. Both are unstable +(`nonzero_ops`) and not `#[track_caller]`, so a violated precondition aborts with std's +`unsafe precondition(s) violated` text located inside std's source, through `caller.rs`'s +`SITES`, rather than at the call. + +Decided with the maintainer on 2026-11-07: ✅ m3, in this epic (rejected: skip). No +consumer at the moq pin. + +Public API: the translator's output.