Skip to content

Handle index projections in call destinations in DSE#155680

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Amanieu:call-arg-move-index
Apr 25, 2026
Merged

Handle index projections in call destinations in DSE#155680
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Amanieu:call-arg-move-index

Conversation

@Amanieu
Copy link
Copy Markdown
Member

@Amanieu Amanieu commented Apr 23, 2026

Since call destinations are evaluated after call arguments, we can't turn copy arguments into moves if the same local is later used as an index projection in the call destination.

DSE call arg optimization: #113758

r? @cjgillot
cc @RalfJung

Since call destinations are evaluated after call arguments, we can't
turn copy arguments into moves if the same local is later used as an
index projection in the call destination.
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 23, 2026

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 23, 2026
@cjgillot
Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 25, 2026

📌 Commit b15544d has been approved by cjgillot

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 25, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Apr 25, 2026
…illot

Handle index projections in call destinations in DSE

Since call destinations are evaluated after call arguments, we can't turn copy arguments into moves if the same local is later used as an index projection in the call destination.

DSE call arg optimization: rust-lang#113758

r? @cjgillot
cc @RalfJung
rust-bors Bot pushed a commit that referenced this pull request Apr 25, 2026
Rollup of 7 pull requests

Successful merges:

 - #155643 (Improve suggestion for $-prefixed fragment specifiers)
 - #154197 (Avoid redundant clone suggestions in borrowck diagnostics)
 - #154372 (Exposing Float Masks)
 - #155680 (Handle index projections in call destinations in DSE)
 - #155732 (bootstrap: Don't clone submodules unconditionally in dry-run)
 - #155737 (Account for `GetSyntheticValue` failures)
 - #155738 (Pass fields to `is_tuple_fields` instead of `SBValue` object)
@rust-bors rust-bors Bot merged commit fa82155 into rust-lang:main Apr 25, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 25, 2026
@RalfJung
Copy link
Copy Markdown
Member

call destinations are evaluated after call arguments

Are they? Hm I guess in Miri they really are. That seems like a mistake to me. For assignments we evaluate the destination first, and we generally use left-to-right evaluation order.

Do you know what codegen does / whether it even matters there?

@RalfJung
Copy link
Copy Markdown
Member

we can't turn copy arguments into moves if the same local is later used as an index projection in the call destination.

This is a Miri-only problem, right? Is there an example/issue somewhere that this is fixing, or how did you even notice this problem?

@Amanieu
Copy link
Copy Markdown
Member Author

Amanieu commented Apr 29, 2026

I don't think we ever generate MIR that triggers this, I only noticed this as a possibility while reviewing existing MIR optimization in preparation for implementing the MIR move optimization.

@RalfJung
Copy link
Copy Markdown
Member

I don't see any reason why a[b] = passthrough_usize(Move(b)) would or should be problematic under our current MIR semantics. So adjusting the optimization here seems a bit premature to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants