@@ -335,34 +335,9 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
335335 }
336336
337337 fn get_const ( & self , local : Local ) -> Option < Const < ' tcx > > {
338- let l = & self . ecx . frame ( ) . locals [ local] ;
339-
340- // If the local is `Unitialized` or `Dead` then we haven't propagated a value into it.
341- //
342- // `InterpCx::access_local()` mostly takes care of this for us however, for ZSTs,
343- // it will synthesize a value for us. In doing so, that will cause the
344- // `get_const(l).is_empty()` assert right before we call `set_const()` in `visit_statement`
345- // to fail.
346- if let LocalValue :: Uninitialized | LocalValue :: Dead = l. value {
347- return None ;
348- }
349-
350338 self . ecx . access_local ( self . ecx . frame ( ) , local, None ) . ok ( )
351339 }
352340
353- fn set_const ( & mut self , local : Local , c : Const < ' tcx > ) {
354- let frame = self . ecx . frame_mut ( ) ;
355-
356- if let Some ( layout) = frame. locals [ local] . layout . get ( ) {
357- debug_assert_eq ! ( c. layout, layout) ;
358- }
359-
360- frame. locals [ local] = LocalState {
361- value : LocalValue :: Live ( * c) ,
362- layout : Cell :: new ( Some ( c. layout ) ) ,
363- } ;
364- }
365-
366341 fn remove_const ( & mut self , local : Local ) {
367342 self . ecx . frame_mut ( ) . locals [ local] = LocalState {
368343 value : LocalValue :: Uninitialized ,
@@ -735,10 +710,8 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
735710 place) {
736711 trace ! ( "checking whether {:?} can be stored to {:?}" , value, local) ;
737712 if self . can_const_prop [ local] {
738- trace ! ( "storing {:?} to {:?}" , value, local) ;
739- assert ! ( self . get_const( local) . is_none( ) ||
740- self . get_const( local) == Some ( value) ) ;
741- self . set_const ( local, value) ;
713+ trace ! ( "stored {:?} to {:?}" , value, local) ;
714+ assert_eq ! ( self . get_const( local) , Some ( value) ) ;
742715
743716 if self . should_const_prop ( ) {
744717 self . replace_with_const (
@@ -747,6 +720,9 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
747720 statement. source_info ,
748721 ) ;
749722 }
723+ } else {
724+ trace ! ( "can't propagate {:?} to {:?}" , value, local) ;
725+ self . remove_const ( local) ;
750726 }
751727 }
752728 }
0 commit comments