Fix ICE when transmute Assume field is invalid#150707
Merged
bors merged 1 commit intorust-lang:mainfrom Jan 6, 2026
Merged
Conversation
Collaborator
Member
|
r? BoxyUwU |
BoxyUwU
reviewed
Jan 5, 2026
9d8c47b to
c474d8d
Compare
BoxyUwU
reviewed
Jan 5, 2026
compiler/rustc_transmute/src/lib.rs
Outdated
| .find(|(_, field_def)| name == field_def.name) | ||
| .unwrap_or_else(|| panic!("There were no fields named `{name}`.")); | ||
| fields[field_idx].to_leaf() == ScalarInt::TRUE | ||
| match fields[field_idx].try_to_scalar() { |
Member
There was a problem hiding this comment.
I think .try_to_leaf() == Some(ScalarInt::TRUE) ought to work
Member
There was a problem hiding this comment.
or ah, you care about seaprating "non value" from false i guess
Member
There was a problem hiding this comment.
i guess try_to_leaf should still work though and remove the Scalar::Int
Contributor
Author
There was a problem hiding this comment.
Updated to use try_to_leaf() as requested. Thanks for the tip!
c474d8d to
e603055
Compare
Member
|
@bors r+ rollup |
Collaborator
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Jan 6, 2026
…ce, r=BoxyUwU Fix ICE when transmute Assume field is invalid This PR fixes an internal compiler error in `rustc_transmute` where initializing an `Assume` field (like `alignment`) with a non-scalar constant (like a struct) caused a panic. The fix updates `from_const` to use `try_to_scalar()` instead of assuming the value is always a leaf. It now gracefully returns `None` for invalid types, allowing the compiler to report standard "missing field initialiser" errors instead of crashing. Fixes rust-lang#150506
bors
added a commit
that referenced
this pull request
Jan 6, 2026
…uwer Rollup of 11 pull requests Successful merges: - #144113 (Impls and impl items inherit `dead_code` lint level of the corresponding traits and trait items) - #148339 (naked functions: emit `.private_extern` on macos) - #149880 (rustc_codegen_llvm: update alignment for double on AIX) - #150122 (Refactor function names of `rustc_ast_lowering`) - #150412 (use PIDFD_GET_INFO ioctl when available) - #150670 (THIR pattern building: Move all `thir::Pat` creation into `rustc_mir_build::thir::pattern`) - #150695 (MGCA: pretty printing for struct expressions and tuple calls ) - #150698 (Improve comment clarity in candidate_may_shadow) - #150706 (Update wasm-component-ld) - #150707 (Fix ICE when transmute Assume field is invalid) - #150708 (Enable merge queue in new bors) r? `@ghost` `@rustbot` modify labels: rollup
bors
added a commit
that referenced
this pull request
Jan 6, 2026
Rollup of 11 pull requests Successful merges: - #144113 (Impls and impl items inherit `dead_code` lint level of the corresponding traits and trait items) - #148339 (naked functions: emit `.private_extern` on macos) - #149880 (rustc_codegen_llvm: update alignment for double on AIX) - #150122 (Refactor function names of `rustc_ast_lowering`) - #150412 (use PIDFD_GET_INFO ioctl when available) - #150670 (THIR pattern building: Move all `thir::Pat` creation into `rustc_mir_build::thir::pattern`) - #150695 (MGCA: pretty printing for struct expressions and tuple calls ) - #150698 (Improve comment clarity in candidate_may_shadow) - #150706 (Update wasm-component-ld) - #150707 (Fix ICE when transmute Assume field is invalid) - #150708 (Enable merge queue in new bors) r? `@ghost` `@rustbot` modify labels: rollup
bors
added a commit
that referenced
this pull request
Jan 6, 2026
…uwer Rollup of 10 pull requests Successful merges: - #144113 (Impls and impl items inherit `dead_code` lint level of the corresponding traits and trait items) - #149880 (rustc_codegen_llvm: update alignment for double on AIX) - #150122 (Refactor function names of `rustc_ast_lowering`) - #150412 (use PIDFD_GET_INFO ioctl when available) - #150670 (THIR pattern building: Move all `thir::Pat` creation into `rustc_mir_build::thir::pattern`) - #150695 (MGCA: pretty printing for struct expressions and tuple calls ) - #150698 (Improve comment clarity in candidate_may_shadow) - #150706 (Update wasm-component-ld) - #150707 (Fix ICE when transmute Assume field is invalid) - #150708 (Enable merge queue in new bors) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
that referenced
this pull request
Jan 6, 2026
Rollup merge of #150707 - Delta17920:fix-transmute-valtree-ice, r=BoxyUwU Fix ICE when transmute Assume field is invalid This PR fixes an internal compiler error in `rustc_transmute` where initializing an `Assume` field (like `alignment`) with a non-scalar constant (like a struct) caused a panic. The fix updates `from_const` to use `try_to_scalar()` instead of assuming the value is always a leaf. It now gracefully returns `None` for invalid types, allowing the compiler to report standard "missing field initialiser" errors instead of crashing. Fixes #150506
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes an internal compiler error in
rustc_transmutewhere initializing anAssumefield (likealignment) with a non-scalar constant (like a struct) caused a panic.The fix updates
from_constto usetry_to_scalar()instead of assuming the value is always a leaf. It now gracefully returnsNonefor invalid types, allowing the compiler to report standard "missing field initialiser" errors instead of crashing.Fixes #150506