Repository navigation
Lower bodies from MIR - #67
Conversation
Quest-Claim: 13f5cafd4d89a95e
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
…ch arms Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
The reject fixture held constructs THIR refused that MIR lowers: temporaries, scrutinees, skipped pattern parts, empty repeats, closures consumed by their call, iterators that drop after their loop, and values held across an await. They move into the task fixture, whose guards log each drop against native Rust, and the lang fixture, which gains or-bindings, a move closure's copy, and an empty repeat. Two bugs they found: an empty array MIR never assigns read as an undeclared name, and a dropped closure that owns a value that drops failed inside std's drop glue span. It now refuses at its drop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Ports the collections' lowering to MIR only: their calls take the operands MIR already lowered, and the THIR pattern and expression paths go with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
A range or an array iterator stepped in place was an object of its bounds or its array and index, whose fields V8 stepped up to 1.25x slower over the bench's BTreeMap, which THIR's counters had run as fast as. Each is now two variables, which an iterator moved into another and read nowhere else shares. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
The README drops `--lower` and the THIR lowering's generators, scopes, and refusals, and records what MIR measured against THIR. The quest is done; what it leaves is two quests: the census refusals MIR has that THIR didn't, and the output size the coroutine classes and temporaries add. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5f930c9273
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 5f930c9273c51d66e7e2986a275867db9f23b0b8 (against base d7bff791fb7f9111ec7fe850df98a9c35b90ac3c).
Existing actionable finding: I agree with the independently posted P1 operand-use finding at ts/src/lower/mir/mod.rs:461–463. drop_unread treats binary/unary evaluations as pure, whereas rvalue::effect and set_local preserve potentially panicking arithmetic; pruning its inputs can leave the retained expression reading an unassigned value. Share the actual effect classification when pruning uses and add chained, discarded checked-arithmetic differential coverage. Referencing that thread rather than duplicating it. No additional actionable bugs found in the areas inspected.
Direction: One MIR lowering is simpler than retaining THIR's separate drop/async machinery. The scalarized-iterator escape guards and expanded temporary-drop/cancellation tests fit that direction. The PR now explicitly accepts the size gap and 16 census regressions with dedicated follow-ups, and records the pre-release migration decision; these are disclosed tradeoffs, not new findings.
Verification limits: Static GitHub inspection of base/head source changes and relevant fixtures, including an independent optimization pass. I did not run builds, differential tests, benchmarks, or reproduce the reported measurements.
drop_unread uncounted the operands of a checked operation nothing reads, though set_local still lowers it for its panic, leaving it reading a local never assigned or declared. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 24b608b30b05760e7319ff820b127d36f0cd98ce, compared with my previous review of 5f930c9273c51d66e7e2986a275867db9f23b0b8; base remains d7bff791fb7f9111ec7fe850df98a9c35b90ac3c.
Previous P1 addressed: The operand-use finding is fixed in ts/src/lower/mir/mod.rs:462–468: pruning now uses the same rvalue::effect classification as lowering, retaining dependencies of arithmetic evaluated for its possible panic. The new integer-fixture case covers discarded chained results, the snapshots retain the initialization before those operations, and the wide differential loop includes the new case. The original thread remains unresolved administratively; this is a code-fix assessment, not a new finding.
No new actionable bugs found in this delta. Reusing the existing effect predicate is the simpler, consistent fix rather than maintaining another purity rule. Static GitHub inspection only; I did not run builds or tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Finishes quest/m2/ts-mir.md.
Problem
rust2-ts had two lowerings. THIR was the default, and MIR was the prototype from the spike (#36), behind
--lower mir. The spike decided that MIR should be the only one. THIR could not see drops, unwinding, or coroutines the way MIR's elaboration does.Approach
optimized_mir. The THIR expression and pattern lowering (body.rs's,pat.rs), the drop scopes,rt.future's generators,--lower, andRUST2_TS_ABORTare gone. Panics unwind under-C panic=unwind. The diff is -4,707 / +1,318 lines ints/srcandts/runtime.rt.idx.Vec, or range step in place, as two variables rather than anrt.Iter. An object of both made V8 1.25x slower on the BTreeMap workload.?on aResultin a function returningPoll<Result<..>>.rt.u64FromHalveswas MIR-only, so it now applies to every body, including the codec'svarint::from_halves.Tests
temporaries. Its guards log each drop against native Rust: temporaries, scrutinees, a pattern's skipped parts, empty repeats, a closure consumed by its call, and an iterator dropped after its loop. It also logs guards held across an.awaitthat a cancel drops.moveclosure's copy, an empty repeat, and checked arithmetic nothing reads, which must still panic on overflow.node --enable-source-maps. A panic, assert, unwrap, bounds check, or overflow points at the Rust line and column of the call, and through each caller.just checkandjust testpass.Impact
Measured with
just ts benchat 24b608b, after #68, against origin/main's THIR output at d7bff79 (--route thir). Host load was 15-40. The three runs below agree, and the bench's A/A route stays within 1.5% at the geomean.The census of moq-net at the pinned revision has 13,744 refusals, against 14,891 from THIR before collections landed. 16 function instances that THIR translated are refused; ts-mir-census tracks them.
Consumer: moq. moq-net's codec and model translate through this lowering, and the census tracks the rest.
Public API
--loweris removed. With it goes the driver's only option, sorust2-driver'scargo::Args::parsedrops itsoptionsparameter andArgsdrops itsoptionsfield. rust2-ffi is the other caller.rt.Future<T>. The value is now an exported class of its own,fooFuture. The exportedfooBodygenerator andfooDrophelpers are gone, and so isrt.futurefrom the runtime.Alternatives
{ start, end }. Measured up to 1.25x slower in V8 on BTreeMap workloads (A/A within 1-3%).Follow-ups
ControlFlowvalues, switches and fields on unmapped external types,charswitches, and type refusals at the function span instead of the local's.Decisions
The maintainer decided:
(written by Opus 5.5)
🤖 Generated with Claude Code
https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn