diff --git a/quest/m3/README.md b/quest/m3/README.md index 6f0e147df..ccb9886f1 100644 --- a/quest/m3/README.md +++ b/quest/m3/README.md @@ -38,6 +38,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 - [Adding to a String](/quest/m3/ts-string-add.md) - `String + &str` translates as `+=` does +- [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 - [Whole writes into a lazy cell or thread-local key](/quest/m3/ts-lazy-writes.md) - a whole write through a `&mut` to a `LazyCell`, `LazyLock`, or `LocalKey` keeps its state diff --git a/quest/m3/ts-operator-paths.md b/quest/m3/ts-operator-paths.md new file mode 100644 index 000000000..e7b07b1e9 --- /dev/null +++ b/quest/m3/ts-operator-paths.md @@ -0,0 +1,27 @@ +# [S] Operator trait methods called by path + +## Goal + +[rust2-ts](/ts/README.md) translates each `std::ops` operator trait's method called by its +path, such as `::add_assign(&mut n, 1)` or `Add::add(a, b)`, wherever its +operator form translates, as a written call and as a function value +(`apply(AddAssign::add_assign, &mut n, 1)`). That covers every operator trait: the +arithmetic, bitwise, and shift ones, their `*Assign` forms, `Neg`, and `Not`. A differential +test against native Rust proves each call means what its operator does, overflow checks +and integer widths included. + +## Plan + +Found on 2026-11-02 completing [moq-dev/rust2#470](https://github.com/moq-dev/rust2/pull/470): +`::add_assign` called by path is an "unsupported call", written or as a value, +while `n += 1` translates. rustc lowers the operator on a primitive to a MIR binary op, but +a call by path stays a call to the trait method, which no mapping covers. + +Lowering std's primitive impls from their MIR may cover most of these, since their bodies are +the operator itself. Measure that against a mapping per trait. + +Public API: the translator's output. + +## Related + +- [Adding to a String](/quest/m3/ts-string-add.md) - `String + &str`, an operator impl of a std type rather than a primitive's