Skip to content

check MIR assignment type validity check during codegen#155512

Open
RalfJung wants to merge 2 commits intorust-lang:mainfrom
RalfJung:interpret-assignment-validity
Open

check MIR assignment type validity check during codegen#155512
RalfJung wants to merge 2 commits intorust-lang:mainfrom
RalfJung:interpret-assignment-validity

Conversation

@RalfJung
Copy link
Copy Markdown
Member

@RalfJung RalfJung commented Apr 19, 2026

I looked at this while debugging #155477, but this makes no progress on that issue.

The first commit improves the check (subtyping should no longer be occurring here) makes the error message a bit more clear. The 2nd commit moves things around so that we can run the same check during codegen as well.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 19, 2026

Some changes occurred to the CTFE machinery

cc @oli-obk, @lcnr

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

@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 19, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 19, 2026

r? @davidtwco

rustbot has assigned @davidtwco.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler, mir
  • compiler, mir expanded to 72 candidates
  • Random selection from 17 candidates

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 19, 2026

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@RalfJung RalfJung changed the title interpret: improve assignment type validity check and error messages check MIR assignment type validity check during codegen Apr 19, 2026
Copy link
Copy Markdown
Member Author

@RalfJung RalfJung Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know what would be a good place for this check as it needs both rustc_middle and rustc_trait_selection (so apparently we cannot put it in rustc_middle). rustc_ty_utils already has those dependencies and otherwise seems fairly lightweight so adding it as dependency in rustc_const_eval and rustc_codegen_ssa is hopefully fine?

View changes since the review

@RalfJung RalfJung force-pushed the interpret-assignment-validity branch from 4f96108 to 3e7a6e4 Compare April 19, 2026 11:28
@RalfJung
Copy link
Copy Markdown
Member Author

RalfJung commented Apr 19, 2026

Strangely, codegen does not seem to see the same types as the interpreter / Miri. I can't reproduce the ICE there.

@RalfJung
Copy link
Copy Markdown
Member Author

Ah, transmute is implemented differently in codegen so we're not asking the mir_assign_valid_types question as part of the transmute. So there's not really a place outside the interpreter that could hit #155477.

It could still be worth checking mir_assign_valid_types during codegen, as a sanity check? I can also remove the 2nd commit again if you prefer. (But note that this does resolve an existing FIXME saying we need to find a better place for these utility functions.)

@RalfJung RalfJung force-pushed the interpret-assignment-validity branch from 3e7a6e4 to 5239e33 Compare April 19, 2026 11:52
@RalfJung RalfJung force-pushed the interpret-assignment-validity branch from 5239e33 to ec0f805 Compare April 19, 2026 12:02
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 19, 2026

☔ The latest upstream changes (presumably #155083) made this pull request unmergeable. Please resolve the merge conflicts.

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

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants