From 72d8b0db421f607b4cbef63201df736478ae2745 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Tue, 3 Nov 2026 06:54:18 -0800 Subject: [PATCH] chore(quest): plan a name or an operator argument at its own Rust span Co-Authored-By: Claude Opus 5.5 --- quest/m3/README.md | 1 + quest/m3/ts-argument-spans.md | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 quest/m3/ts-argument-spans.md diff --git a/quest/m3/README.md b/quest/m3/README.md index bbb2ba69b..20a81399e 100644 --- a/quest/m3/README.md +++ b/quest/m3/README.md @@ -37,3 +37,4 @@ generic std gap is planned here even when moq never calls it. - [Python's wake on the loop's own thread](/quest/m3/ffi-python-wake.md) - a wake on the event loop's thread resumes the future with no socket pair - [Python's call cost](/quest/m3/ffi-python-calls.md) - a call on an object costs what BoltFFI's does, or the gap is explained - [A std map with a crate's own BuildHasher](/quest/m3/ts-map-own-hasher.md) - std's and hashbrown's maps built with a crate's own hasher translate for keys that are JS objects +- [A name or an operator argument at its own Rust span](/quest/m3/ts-argument-spans.md) - a `tsc` error on a plain-name or operator argument names that argument's Rust, not the method it is passed to diff --git a/quest/m3/ts-argument-spans.md b/quest/m3/ts-argument-spans.md new file mode 100644 index 000000000..d70afcd73 --- /dev/null +++ b/quest/m3/ts-argument-spans.md @@ -0,0 +1,22 @@ +# [S] A name or an operator argument at its own Rust span + +## Goal + +When `tsc` rejects an argument of a translated call that is a plain name or an operator, +[rust2-ts](/ts/README.md) reports the error at that argument's Rust, not at the method name of +the call it is passed to, proven by the `spans` fixture's snapshot. + +## Plan + +Left out of [#520](https://github.com/moq-dev/rust2/pull/520), which maps an argument made by +a call to its own Rust. In `Meter.scaled(m, rt.u32WrappingAdd(a, 1), ...)`, the receiver `m` +still maps to `scaled`, as does an argument such as `(a ^ b) >>> 0`. + +MIR gives each argument its own span (`Spanned`). Locating names and operators the +way calls are located needs the lowering passes that match on expression shapes, such as +`Expr::Ident`, `Expr::Member`, or `Expr::Binary`, to look through the location wrapper first. +Wrapping members and binaries naively changed what the formatting code spills into a variable +before its closure reads it, so the generated code changed. Prove the output text unchanged by +the snapshots, as #520 did, and measure the source map's growth on moq's translation. + +Public API: the translator's error spans.