Skip to content

Avoid ICE in known_panics_lint for mismatched type const literals#156463

Open
reddevilmidzy wants to merge 1 commit into
rust-lang:mainfrom
reddevilmidzy:mgca-mir
Open

Avoid ICE in known_panics_lint for mismatched type const literals#156463
reddevilmidzy wants to merge 1 commit into
rust-lang:mainfrom
reddevilmidzy:mgca-mir

Conversation

@reddevilmidzy
Copy link
Copy Markdown
Member

close: #154748
close: #154750

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 11, 2026
@reddevilmidzy
Copy link
Copy Markdown
Member Author

I first tried fixing this during literal-to-const lowering, but that either changed the existing diagnostics or introduced additional delayed-bug ICEs.

The type mismatch is already diagnosed earlier, so this instead makes known_panics_lint bail out on incompatible layouts during const propagation to avoid the ICE while preserving the current errors.

@reddevilmidzy reddevilmidzy changed the title Avoid ICE in known_panics_lint for mismatched type const literals Avoid ICE in known_panics_lint for mismatched type const literals May 11, 2026
@reddevilmidzy
Copy link
Copy Markdown
Member Author

r? @BoxyUwU

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 12, 2026

BoxyUwU is currently at their maximum review capacity.
They may take a while to respond.

@reddevilmidzy reddevilmidzy marked this pull request as ready for review May 12, 2026 02:38
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 12, 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. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 12, 2026
_ => return None,
}

if value.layout.size != to.size {
Copy link
Copy Markdown
Contributor

@oli-obk oli-obk May 12, 2026

Choose a reason for hiding this comment

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

This fixes the symptom, not the issue itself. Why do we even get here after the error is reported?

Oh I think I may have found it: https://github.com/rust-lang/rust/pull/152001/changes#r3224335944

View changes since the review

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.

[ICE]: attempting to project to field at offset 0 with size 8 into immediate with layout TyAndLayout [ICE]: invalid field access on immediate

4 participants