Skip to content
Merged
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: 1 addition & 0 deletions quest/m3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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::<T>()` translates as rustc's constant for each instance
- [Operator trait methods called by path](/quest/m3/ts-operator-paths.md) - `<u8 as AddAssign>::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
Expand Down
18 changes: 18 additions & 0 deletions quest/m3/ts-needs-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# [XS] Whether a type needs drop

## Goal

[rust2-ts](/ts/README.md) translates `std::mem::needs_drop::<T>()` 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::<T>()` is an
"unsupported call to `std::mem::needs_drop::<u8>`", while `size_of::<T>()` 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.