about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-04-29 18:28:23 +0000
committerbors <bors@rust-lang.org>2024-04-29 18:28:23 +0000
commita8a1d3a771850e1e364eb9010e98789ce758a817 (patch)
tree7fdf1a7f3f0d05bf07fad0a587f0093627470fbb /compiler/rustc_mir_transform/src
parente27af2917b80487e9c0de00118fdcb9ccb1177f9 (diff)
parentebce31a0531ffd41221086abdf9d6eb252153082 (diff)
downloadrust-a8a1d3a771850e1e364eb9010e98789ce758a817.tar.gz
rust-a8a1d3a771850e1e364eb9010e98789ce758a817.zip
Auto merge of #124527 - jieyouxu:rollup-eslzncy, r=jieyouxu
Rollup of 7 pull requests

Successful merges:

 - #124269 (Pretty-print parenthesis around binary in postfix match)
 - #124415 (Use probes more aggressively in new solver)
 - #124475 (Remove direct dependencies on lazy_static, once_cell and byteorder)
 - #124484 (Fix #124478 - offset_of! returns a temporary)
 - #124504 (Mark unions non-const-propagatable in `KnownPanicsLint` without calling layout)
 - #124508 (coverage: Avoid hard-coded values when visiting logical ops)
 - #124522 ([Refactor] Rename `Lint` and `LintGroup`'s `is_loaded` to `is_externally_loaded` )

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_mir_transform/src')
-rw-r--r--compiler/rustc_mir_transform/src/known_panics_lint.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/compiler/rustc_mir_transform/src/known_panics_lint.rs b/compiler/rustc_mir_transform/src/known_panics_lint.rs
index b8dbf8a759f..b2030efca8f 100644
--- a/compiler/rustc_mir_transform/src/known_panics_lint.rs
+++ b/compiler/rustc_mir_transform/src/known_panics_lint.rs
@@ -896,13 +896,19 @@ impl CanConstProp {
         };
         for (local, val) in cpv.can_const_prop.iter_enumerated_mut() {
             let ty = body.local_decls[local].ty;
-            match tcx.layout_of(param_env.and(ty)) {
-                Ok(layout) if layout.size < Size::from_bytes(MAX_ALLOC_LIMIT) => {}
-                // Either the layout fails to compute, then we can't use this local anyway
-                // or the local is too large, then we don't want to.
-                _ => {
-                    *val = ConstPropMode::NoPropagation;
-                    continue;
+            if ty.is_union() {
+                // Do not const prop unions as they can
+                // ICE during layout calc
+                *val = ConstPropMode::NoPropagation;
+            } else {
+                match tcx.layout_of(param_env.and(ty)) {
+                    Ok(layout) if layout.size < Size::from_bytes(MAX_ALLOC_LIMIT) => {}
+                    // Either the layout fails to compute, then we can't use this local anyway
+                    // or the local is too large, then we don't want to.
+                    _ => {
+                        *val = ConstPropMode::NoPropagation;
+                        continue;
+                    }
                 }
             }
         }