Skip to content

Fix ICE in offset_of! error recovery#153495

Merged
rust-bors[bot] merged 3 commits intorust-lang:mainfrom
TaKO8Ki:fix-153236-offset-of-recovery
Mar 6, 2026
Merged

Fix ICE in offset_of! error recovery#153495
rust-bors[bot] merged 3 commits intorust-lang:mainfrom
TaKO8Ki:fix-153236-offset-of-recovery

Conversation

@TaKO8Ki
Copy link
Member

@TaKO8Ki TaKO8Ki commented Mar 6, 2026

Fixes #153236.

offset_of! was changed in #148151 to lower through THIR as a sum of calls to the offset_of intrinsic. In the error-recovery case, when no valid field indices are recorded, that lowering synthesized 0 as a u32 even though the overall offset_of! expression has type usize.

On 64-bit targets, const-eval then tried to write a 4-byte immediate into an 8-byte destination, which caused the ICE.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 6, 2026
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 6, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 6, 2026

r? @petrochenkov

rustbot has assigned @petrochenkov.
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
  • compiler expanded to 69 candidates
  • Random selection from 15 candidates

@petrochenkov
Copy link
Contributor

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 6, 2026

📌 Commit e62f17c has been approved by petrochenkov

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 Mar 6, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 6, 2026
…ery, r=petrochenkov

Fix ICE in `offset_of!` error recovery

Fixes rust-lang#153236.

`offset_of!` was changed in rust-lang#148151 to lower through THIR as a sum of calls to the `offset_of` intrinsic. In the error-recovery case, when no valid field indices are recorded, that lowering synthesized `0` as a `u32` even though the overall `offset_of!` expression has type `usize`.

On 64-bit targets, const-eval then tried to write a 4-byte immediate into an 8-byte destination, which caused the ICE.
rust-bors bot pushed a commit that referenced this pull request Mar 6, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #153466 (`rust-analyzer` subtree update)
 - #151280 (Fix incorrect trailing comma suggested in no_accessible_fields)
 - #152593 (Box in `ValTreeKind::Branch(Box<[I::Const]>)` changed to `List`)
 - #153174 (std: add wasm64 to sync::Once and thread_parking atomics cfg guards)
 - #153485 (libcore float tests: replace macro shadowing by const-compatible macro)
 - #153495 (Fix ICE in `offset_of!` error recovery)
 - #152040 (Do not emit ConstEvaluatable goals if type-const)
 - #152741 (Suppress invalid suggestions in destructuring assignment)
 - #153189 (refactor: move `check_align` to `parse_alignment`)
 - #153230 (Roll rustfmt reviewers for in-tree rustfmt)
 - #153445 (Consider try blocks as block-like for overflowed expr)
 - #153452 (Cleanup unused diagnostic emission methods)
 - #153476 (bootstrap.py: fix typo "parallle")
 - #153483 (Preserve parentheses around `Fn` trait bounds in pretty printer)
@rust-bors rust-bors bot merged commit ac9bd09 into rust-lang:main Mar 6, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 6, 2026
rust-timer added a commit that referenced this pull request Mar 6, 2026
Rollup merge of #153495 - TaKO8Ki:fix-153236-offset-of-recovery, r=petrochenkov

Fix ICE in `offset_of!` error recovery

Fixes #153236.

`offset_of!` was changed in #148151 to lower through THIR as a sum of calls to the `offset_of` intrinsic. In the error-recovery case, when no valid field indices are recorded, that lowering synthesized `0` as a `u32` even though the overall `offset_of!` expression has type `usize`.

On 64-bit targets, const-eval then tried to write a 4-byte immediate into an 8-byte destination, which caused the ICE.
github-actions bot pushed a commit to rust-lang/rust-analyzer that referenced this pull request Mar 9, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#153466 (`rust-analyzer` subtree update)
 - rust-lang/rust#151280 (Fix incorrect trailing comma suggested in no_accessible_fields)
 - rust-lang/rust#152593 (Box in `ValTreeKind::Branch(Box<[I::Const]>)` changed to `List`)
 - rust-lang/rust#153174 (std: add wasm64 to sync::Once and thread_parking atomics cfg guards)
 - rust-lang/rust#153485 (libcore float tests: replace macro shadowing by const-compatible macro)
 - rust-lang/rust#153495 (Fix ICE in `offset_of!` error recovery)
 - rust-lang/rust#152040 (Do not emit ConstEvaluatable goals if type-const)
 - rust-lang/rust#152741 (Suppress invalid suggestions in destructuring assignment)
 - rust-lang/rust#153189 (refactor: move `check_align` to `parse_alignment`)
 - rust-lang/rust#153230 (Roll rustfmt reviewers for in-tree rustfmt)
 - rust-lang/rust#153445 (Consider try blocks as block-like for overflowed expr)
 - rust-lang/rust#153452 (Cleanup unused diagnostic emission methods)
 - rust-lang/rust#153476 (bootstrap.py: fix typo "parallle")
 - rust-lang/rust#153483 (Preserve parentheses around `Fn` trait bounds in pretty printer)
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.

[ICE]: invalid immediate for given destination place: scalar value has wrong size

3 participants