@@ -147,6 +147,14 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
147147 }
148148 }
149149
150+ fn get_const ( & self , local : Local ) -> Option < Const < ' tcx > > {
151+ self . places [ local]
152+ }
153+
154+ fn set_const ( & mut self , local : Local , c : Option < Const < ' tcx > > ) {
155+ self . places [ local] = c;
156+ }
157+
150158 fn use_ecx < F , T > (
151159 & mut self ,
152160 source_info : SourceInfo ,
@@ -296,7 +304,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
296304 trace ! ( "eval_place(place={:?})" , place) ;
297305 place. iterate ( |place_base, place_projection| {
298306 let mut eval = match place_base {
299- PlaceBase :: Local ( loc) => self . places [ * loc] . clone ( ) ?,
307+ PlaceBase :: Local ( loc) => self . get_const ( * loc) . clone ( ) ?,
300308 PlaceBase :: Static ( box Static { kind : StaticKind :: Promoted ( promoted) , ..} ) => {
301309 let generics = self . tcx . generics_of ( self . source . def_id ( ) ) ;
302310 if generics. requires_monomorphization ( self . tcx ) {
@@ -699,8 +707,8 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
699707 trace ! ( "checking whether {:?} can be stored to {:?}" , value, local) ;
700708 if self . can_const_prop [ local] {
701709 trace ! ( "storing {:?} to {:?}" , value, local) ;
702- assert ! ( self . places [ local] . is_none( ) ) ;
703- self . places [ local] = Some ( value) ;
710+ assert ! ( self . get_const ( local) . is_none( ) ) ;
711+ self . set_const ( local, Some ( value) ) ;
704712
705713 if self . should_const_prop ( ) {
706714 self . replace_with_const (
@@ -740,7 +748,7 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
740748 place = & proj. base ;
741749 }
742750 if let Place :: Base ( PlaceBase :: Local ( local) ) = * place {
743- self . places [ local] = None ;
751+ self . set_const ( local, None ) ;
744752 }
745753 } ,
746754 Operand :: Constant ( _) => { }
0 commit comments