-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mark unions non-const-propagatable in KnownPanicsLint
without calling layout
#124504
Conversation
as they have a potential to ICE during layout calculation
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
KnownPanicsLint
KnownPanicsLint
without calling layout
Though the reason it ICEs is that unions are incompatible with const propagation, as Rust has no concept of "active variant" of unions. So either we permit using unions for transmutes in const prop, or we can't support them at all. The reason we don't allow unions transmutes in const prop is that the current design of const prop just isn't compatible with it @bors r+ rollup |
Oh I see. Thanks for the context. I'll try to add it in the comments in a subsequent PR. |
Rollup of 7 pull requests Successful merges: - rust-lang#124269 (Pretty-print parenthesis around binary in postfix match) - rust-lang#124415 (Use probes more aggressively in new solver) - rust-lang#124475 (Remove direct dependencies on lazy_static, once_cell and byteorder) - rust-lang#124484 (Fix rust-lang#124478 - offset_of! returns a temporary) - rust-lang#124504 (Mark unions non-const-propagatable in `KnownPanicsLint` without calling layout) - rust-lang#124508 (coverage: Avoid hard-coded values when visiting logical ops) - rust-lang#124522 ([Refactor] Rename `Lint` and `LintGroup`'s `is_loaded` to `is_externally_loaded` ) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#124504 - gurry:123710-union-ICE, r=oli-obk Mark unions non-const-propagatable in `KnownPanicsLint` without calling layout Fixes rust-lang#123710 The ICE occurs during the layout calculation of the union `InvalidTag` in rust-lang#123710 because the following assert fails:https://github.com/rust-lang/rust/blob/5fe8b697e729b6eb64841a3905e57da1b47f4ca3/compiler/rustc_abi/src/layout.rs#L289-L292 The layout calculation is invoked by `KnownPanicsLint` when it is trying to figure out which locals it can const prop. Since `KnownPanicsLint` is never actually going to const props unions thanks to PR rust-lang#121628 there's no point calling layout to check if it can. So in this fix I skip the call to layout and just mark the local non-const propagatable if it is a union.
Updated the comment in #124550 |
…-obk Remove redundant union check in `KnownPanicsLint` const prop Removes the below check which prevents unions from being const propagated:https://github.com/rust-lang/rust/blob/f9dca46218d4b8efa062aec4fd0820cbb4942aa2/compiler/rustc_mir_transform/src/known_panics_lint.rs#L587-L594 It is not needed because after PR rust-lang#124504 we mark unions as `NoPropagation` over here: https://github.com/rust-lang/rust/blob/f9dca46218d4b8efa062aec4fd0820cbb4942aa2/compiler/rustc_mir_transform/src/known_panics_lint.rs#L899-L902 which is enough to prevent them from being const propagated.
Rollup merge of rust-lang#124550 - gurry:remove-redundant-code, r=oli-obk Remove redundant union check in `KnownPanicsLint` const prop Removes the below check which prevents unions from being const propagated:https://github.com/rust-lang/rust/blob/f9dca46218d4b8efa062aec4fd0820cbb4942aa2/compiler/rustc_mir_transform/src/known_panics_lint.rs#L587-L594 It is not needed because after PR rust-lang#124504 we mark unions as `NoPropagation` over here: https://github.com/rust-lang/rust/blob/f9dca46218d4b8efa062aec4fd0820cbb4942aa2/compiler/rustc_mir_transform/src/known_panics_lint.rs#L899-L902 which is enough to prevent them from being const propagated.
Fixes #123710
The ICE occurs during the layout calculation of the union
InvalidTag
in #123710 because the following assert fails:rust/compiler/rustc_abi/src/layout.rs
Lines 289 to 292 in 5fe8b69
The layout calculation is invoked by
KnownPanicsLint
when it is trying to figure out which locals it can const prop. SinceKnownPanicsLint
is never actually going to const props unions thanks to PR #121628 there's no point calling layout to check if it can. So in this fix I skip the call to layout and just mark the local non-const propagatable if it is a union.