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 @@ -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) - `<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
- [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
Expand Down
27 changes: 27 additions & 0 deletions quest/m3/ts-operator-paths.md
Original file line number Diff line number Diff line change
@@ -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 `<u8 as AddAssign>::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):
`<u8 as AddAssign>::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