@@ -583,33 +583,21 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
583
583
val. into ( )
584
584
}
585
585
586
- Aggregate ( ref kind, ref fields) => {
587
- // Do not const prop union fields as they can be
588
- // made to produce values that don't match their
589
- // underlying layout's type (see ICE #121534).
590
- // If the last element of the `Adt` tuple
591
- // is `Some` it indicates the ADT is a union
592
- if let AggregateKind :: Adt ( _, _, _, _, Some ( _) ) = * * kind {
593
- return None ;
594
- } ;
595
- Value :: Aggregate {
596
- fields : fields
597
- . iter ( )
598
- . map ( |field| {
599
- self . eval_operand ( field) . map_or ( Value :: Uninit , Value :: Immediate )
600
- } )
601
- . collect ( ) ,
602
- variant : match * * kind {
603
- AggregateKind :: Adt ( _, variant, _, _, _) => variant,
604
- AggregateKind :: Array ( _)
605
- | AggregateKind :: Tuple
606
- | AggregateKind :: RawPtr ( _, _)
607
- | AggregateKind :: Closure ( _, _)
608
- | AggregateKind :: Coroutine ( _, _)
609
- | AggregateKind :: CoroutineClosure ( _, _) => VariantIdx :: ZERO ,
610
- } ,
611
- }
612
- }
586
+ Aggregate ( ref kind, ref fields) => Value :: Aggregate {
587
+ fields : fields
588
+ . iter ( )
589
+ . map ( |field| self . eval_operand ( field) . map_or ( Value :: Uninit , Value :: Immediate ) )
590
+ . collect ( ) ,
591
+ variant : match * * kind {
592
+ AggregateKind :: Adt ( _, variant, _, _, _) => variant,
593
+ AggregateKind :: Array ( _)
594
+ | AggregateKind :: Tuple
595
+ | AggregateKind :: RawPtr ( _, _)
596
+ | AggregateKind :: Closure ( _, _)
597
+ | AggregateKind :: Coroutine ( _, _)
598
+ | AggregateKind :: CoroutineClosure ( _, _) => VariantIdx :: ZERO ,
599
+ } ,
600
+ } ,
613
601
614
602
Repeat ( ref op, n) => {
615
603
trace ! ( ?op, ?n) ;
@@ -897,8 +885,9 @@ impl CanConstProp {
897
885
for ( local, val) in cpv. can_const_prop . iter_enumerated_mut ( ) {
898
886
let ty = body. local_decls [ local] . ty ;
899
887
if ty. is_union ( ) {
900
- // Do not const prop unions as they can
901
- // ICE during layout calc
888
+ // Unions are incompatible with the current implementation of
889
+ // const prop because Rust has no concept of an active
890
+ // variant of a union
902
891
* val = ConstPropMode :: NoPropagation ;
903
892
} else {
904
893
match tcx. layout_of ( param_env. and ( ty) ) {
0 commit comments