diff options
| author | bors <bors@rust-lang.org> | 2024-04-30 13:13:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-04-30 13:13:54 +0000 |
| commit | 20aa2d81e36036073a9acf418c7d413cb4b22fa6 (patch) | |
| tree | 940e8f0c9df0d84df08c5955c2f84ca1783c1c3f /compiler/rustc_mir_transform/src | |
| parent | a7431167e0b8d6ae9fd60650694fbefc3d0fac2f (diff) | |
| parent | 5a4e83c2e031560849ad1e6ba8f6b78b6e572a8c (diff) | |
| download | rust-20aa2d81e36036073a9acf418c7d413cb4b22fa6.tar.gz rust-20aa2d81e36036073a9acf418c7d413cb4b22fa6.zip | |
Auto merge of #124558 - matthiaskrgr:rollup-axi1bxu, r=matthiaskrgr
Rollup of 3 pull requests Successful merges: - #123247 (Mention Both HRTB and Generic Lifetime Param in `E0637` documentation) - #124511 (Remove many `#[macro_use] extern crate foo` items) - #124550 (Remove redundant union check in `KnownPanicsLint` const prop) 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.rs | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/compiler/rustc_mir_transform/src/known_panics_lint.rs b/compiler/rustc_mir_transform/src/known_panics_lint.rs index b2030efca8f..90c1c7ba63b 100644 --- a/compiler/rustc_mir_transform/src/known_panics_lint.rs +++ b/compiler/rustc_mir_transform/src/known_panics_lint.rs @@ -583,33 +583,21 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { val.into() } - Aggregate(ref kind, ref fields) => { - // Do not const prop union fields as they can be - // made to produce values that don't match their - // underlying layout's type (see ICE #121534). - // If the last element of the `Adt` tuple - // is `Some` it indicates the ADT is a union - if let AggregateKind::Adt(_, _, _, _, Some(_)) = **kind { - return None; - }; - Value::Aggregate { - fields: fields - .iter() - .map(|field| { - self.eval_operand(field).map_or(Value::Uninit, Value::Immediate) - }) - .collect(), - variant: match **kind { - AggregateKind::Adt(_, variant, _, _, _) => variant, - AggregateKind::Array(_) - | AggregateKind::Tuple - | AggregateKind::RawPtr(_, _) - | AggregateKind::Closure(_, _) - | AggregateKind::Coroutine(_, _) - | AggregateKind::CoroutineClosure(_, _) => VariantIdx::ZERO, - }, - } - } + Aggregate(ref kind, ref fields) => Value::Aggregate { + fields: fields + .iter() + .map(|field| self.eval_operand(field).map_or(Value::Uninit, Value::Immediate)) + .collect(), + variant: match **kind { + AggregateKind::Adt(_, variant, _, _, _) => variant, + AggregateKind::Array(_) + | AggregateKind::Tuple + | AggregateKind::RawPtr(_, _) + | AggregateKind::Closure(_, _) + | AggregateKind::Coroutine(_, _) + | AggregateKind::CoroutineClosure(_, _) => VariantIdx::ZERO, + }, + }, Repeat(ref op, n) => { trace!(?op, ?n); @@ -897,8 +885,9 @@ impl CanConstProp { for (local, val) in cpv.can_const_prop.iter_enumerated_mut() { let ty = body.local_decls[local].ty; if ty.is_union() { - // Do not const prop unions as they can - // ICE during layout calc + // Unions are incompatible with the current implementation of + // const prop because Rust has no concept of an active + // variant of a union *val = ConstPropMode::NoPropagation; } else { match tcx.layout_of(param_env.and(ty)) { |
