Skip to content

interpreter: improve comments and error message in mir_assign_valid_types#155512

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
RalfJung:interpret-assignment-validity
Jun 3, 2026
Merged

interpreter: improve comments and error message in mir_assign_valid_types#155512
rust-bors[bot] merged 1 commit into
rust-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.

@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
Comment thread compiler/rustc_ty_utils/src/compare_types.rs
@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 2 times, most recently from 5239e33 to ec0f805 Compare April 19, 2026 12:02
@rust-bors

This comment has been minimized.

@RalfJung RalfJung force-pushed the interpret-assignment-validity branch from ec0f805 to 20d66f0 Compare April 20, 2026 06:55
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 20, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@RalfJung RalfJung force-pushed the interpret-assignment-validity branch from 20d66f0 to ab617ae Compare April 20, 2026 13:34
@RalfJung
Copy link
Copy Markdown
Member Author

Given that relate_types is apparently buggy I think maybe we shouldn't make it more widely available then. ;) So I removed the 2nd commit.

@RalfJung RalfJung changed the title check MIR assignment type validity check during codegen interpreter: improve comments and error message in mir_assign_valid_types Apr 20, 2026
@lcnr
Copy link
Copy Markdown
Contributor

lcnr commented Apr 27, 2026

as stated in #155477 (comment), fixing relate_types should be straightforward

@RalfJung
Copy link
Copy Markdown
Member Author

I think it might still make sense to first land this as a trivial comments-only PR. And the fact that codegen wouldn't see the case that caused the problem also made me less enthusiastic about running this check in codegen.
r? @lcnr

@rustbot rustbot assigned lcnr and unassigned davidtwco Apr 27, 2026
@RalfJung
Copy link
Copy Markdown
Member Author

RalfJung commented May 6, 2026

@lcnr any thoughts on these comments? :)
Or @oli-obk maybe?

@RalfJung
Copy link
Copy Markdown
Member Author

RalfJung commented Jun 2, 2026

Friendly ping @lcnr @oli-obk -- this should be a fairly trivial PR, not sure why it's been sitting here for 6 weeks.

@oli-obk
Copy link
Copy Markdown
Contributor

oli-obk commented Jun 3, 2026

Because I was very much not on top of my notifications and declared bankruptcy 1st of may to start over

Copy link
Copy Markdown
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

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

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Jun 3, 2026

📌 Commit ab617ae has been approved by oli-obk

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 5. This pull request will be tested once the tree is reopened.

@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 Jun 3, 2026
// Make sure the layout is equal, too -- just to be safe. Miri really needs layout equality.
// For performance reason we skip this check when the types are equal. Equal types *can*
// have different layouts when enum downcast is involved (as enum variants carry the type of
// the enum), but those should never occur in assignments.
Copy link
Copy Markdown
Contributor

@oli-obk oli-obk Jun 3, 2026

Choose a reason for hiding this comment

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

This one was a bit confusing as the text didn't change, only line breaks in comments

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

IIRC the old text went beyond the 100 column mark so I reflowed it. Sorry for the confusion. I wish we had better diff views for such comment changes.

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 3, 2026
…dity, r=oli-obk

interpreter: improve comments and error message in mir_assign_valid_types

I looked at this while debugging rust-lang#155477, but this makes no progress on that issue.
rust-bors Bot pushed a commit that referenced this pull request Jun 3, 2026
Rollup of 12 pull requests

Successful merges:

 - #157085 (powerpc: warn against incorrect values for ABI-relevant target features)
 - #157170 (Use `impl` restrictions in `std`, `core`)
 - #157217 ([tiny] remove unecessary `.into()` calls)
 - #157262 (rustdoc: IXCRE: Preserve sizedness bounds on type params belonging to the parent item)
 - #157379 (Some more simple per-owner resolver changes)
 - #157381 (librustdoc: fix CSS border issue to support Firefox high contrast mode)
 - #155512 (interpreter: improve comments and error message in mir_assign_valid_types)
 - #157254 (Correct description of panic.rs)
 - #157290 (interpret: fix mir::UnOp layout computation)
 - #157332 (Rewrite target checking for `#[sanitize]`)
 - #157351 (Avoid leaking the query-job collection warning into the panic query stack)
 - #157389 (Add @clarfonthey to libs review rotation)
@rust-bors rust-bors Bot merged commit 1b77f84 into rust-lang:main Jun 3, 2026
11 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 3, 2026
rust-timer added a commit that referenced this pull request Jun 3, 2026
Rollup merge of #155512 - RalfJung:interpret-assignment-validity, r=oli-obk

interpreter: improve comments and error message in mir_assign_valid_types

I looked at this while debugging #155477, but this makes no progress on that issue.
@RalfJung RalfJung deleted the interpret-assignment-validity branch June 4, 2026 07:41
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Jun 4, 2026
Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#157085 (powerpc: warn against incorrect values for ABI-relevant target features)
 - rust-lang/rust#157170 (Use `impl` restrictions in `std`, `core`)
 - rust-lang/rust#157217 ([tiny] remove unecessary `.into()` calls)
 - rust-lang/rust#157262 (rustdoc: IXCRE: Preserve sizedness bounds on type params belonging to the parent item)
 - rust-lang/rust#157379 (Some more simple per-owner resolver changes)
 - rust-lang/rust#157381 (librustdoc: fix CSS border issue to support Firefox high contrast mode)
 - rust-lang/rust#155512 (interpreter: improve comments and error message in mir_assign_valid_types)
 - rust-lang/rust#157254 (Correct description of panic.rs)
 - rust-lang/rust#157290 (interpret: fix mir::UnOp layout computation)
 - rust-lang/rust#157332 (Rewrite target checking for `#[sanitize]`)
 - rust-lang/rust#157351 (Avoid leaking the query-job collection warning into the panic query stack)
 - rust-lang/rust#157389 (Add @clarfonthey to libs review rotation)
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.

5 participants