@@ -569,11 +569,15 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
569569 base : PlaceBase :: Local ( local) ,
570570 projection : box [ ] ,
571571 } = * 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) {
573576 trace ! ( "checking whether {:?} can be stored to {:?}" , value, local) ;
574577 if self . can_const_prop [ local] {
575578 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) ) ;
577581 self . set_const ( local, value) ;
578582
579583 if self . should_const_prop ( ) {
@@ -587,19 +591,22 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
587591 }
588592 }
589593 }
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+ _ => { }
601607 }
602608 }
609+
603610 self . super_statement ( statement, location) ;
604611 }
605612
0 commit comments