diff --git a/quest/m3/README.md b/quest/m3/README.md index a0a44aa8d..ced9594b0 100644 --- a/quest/m3/README.md +++ b/quest/m3/README.md @@ -37,6 +37,7 @@ generic std gap is planned here even when moq never calls it. - [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 - [Rc and Arc of a slice](/quest/m3/ts-shared-slices.md) - `Rc<[T]>` and `Arc<[T]>` from a `Vec`, a slice, or an iterator translate - [Popping a String that is reassigned elsewhere](/quest/m3/ts-reassigned-pop.md) - `pop`, `remove`, and `split_off` of a local some other path assigns whole translate +- [Whether a type needs drop](/quest/m3/ts-needs-drop.md) - `mem::needs_drop::()` translates as rustc's constant for each instance - [Operator trait methods called by path](/quest/m3/ts-operator-paths.md) - `::add_assign` and every other `std::ops` operator method translate called by path or as a value - [The rest of a vector's methods](/quest/m3/ts-vec-rest.md) - `append`, `resize`, `split_off`, `try_reserve`, and `Vec::from(VecDeque)` 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-needs-drop.md b/quest/m3/ts-needs-drop.md new file mode 100644 index 000000000..3cbfba6d7 --- /dev/null +++ b/quest/m3/ts-needs-drop.md @@ -0,0 +1,18 @@ +# [XS] Whether a type needs drop + +## Goal + +[rust2-ts](/ts/README.md) translates `std::mem::needs_drop::()` as the constant rustc +gives each instance. That includes a `T` whose JS value drops nothing, such as a `String`, +since a caller may branch on it as std's collections do. A differential test against +native Rust proves it for a `T` of each outcome. + +## Plan + +Found on 2026-11-02 while reproducing a comparison of two constants +([moq-dev/rust2#480](https://github.com/moq-dev/rust2/pull/480)): `needs_drop::()` is an +"unsupported call to `std::mem::needs_drop::`", while `size_of::()` already +translates as its value. The value is rustc's, not whether translation emits a drop. +Fold in any other per-instance constant of a type that is refused the same way. + +Public API: the translator's output.