@@ -569,11 +569,15 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
569
569
base : PlaceBase :: Local ( local) ,
570
570
projection : box [ ] ,
571
571
} = * place {
572
- if let Some ( value) = self . const_prop ( rval, place_layout, statement. source_info , place) {
572
+ if let Some ( value) = self . const_prop ( rval,
573
+ place_layout,
574
+ statement. source_info ,
575
+ place) {
573
576
trace ! ( "checking whether {:?} can be stored to {:?}" , value, local) ;
574
577
if self . can_const_prop [ local] {
575
578
trace ! ( "storing {:?} to {:?}" , value, local) ;
576
- assert ! ( self . get_const( local) . is_none( ) || self . get_const( local) == Some ( value) ) ;
579
+ assert ! ( self . get_const( local) . is_none( ) ||
580
+ self . get_const( local) == Some ( value) ) ;
577
581
self . set_const ( local, value) ;
578
582
579
583
if self . should_const_prop ( ) {
@@ -587,19 +591,22 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
587
591
}
588
592
}
589
593
}
590
- } else if let StatementKind :: StorageLive ( local) = statement. kind {
591
- if self . can_const_prop [ local] {
592
- let frame = self . ecx . frame_mut ( ) ;
593
-
594
- frame. locals [ local] . value = LocalValue :: Uninitialized ;
595
- }
596
- } else if let StatementKind :: StorageDead ( local) = statement. kind {
597
- if self . can_const_prop [ local] {
598
- let frame = self . ecx . frame_mut ( ) ;
599
-
600
- frame. locals [ local] . value = LocalValue :: Dead ;
594
+ } else {
595
+ match statement. kind {
596
+ StatementKind :: StorageLive ( local) |
597
+ StatementKind :: StorageDead ( local) if self . can_const_prop [ local] => {
598
+ let frame = self . ecx . frame_mut ( ) ;
599
+ frame. locals [ local] . value =
600
+ if let StatementKind :: StorageLive ( _) = statement. kind {
601
+ LocalValue :: Uninitialized
602
+ } else {
603
+ LocalValue :: Dead
604
+ } ;
605
+ }
606
+ _ => { }
601
607
}
602
608
}
609
+
603
610
self . super_statement ( statement, location) ;
604
611
}
605
612
0 commit comments