@@ -147,6 +147,14 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
147
147
}
148
148
}
149
149
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
+
150
158
fn use_ecx < F , T > (
151
159
& mut self ,
152
160
source_info : SourceInfo ,
@@ -296,7 +304,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
296
304
trace ! ( "eval_place(place={:?})" , place) ;
297
305
place. iterate ( |place_base, place_projection| {
298
306
let mut eval = match place_base {
299
- PlaceBase :: Local ( loc) => self . places [ * loc] . clone ( ) ?,
307
+ PlaceBase :: Local ( loc) => self . get_const ( * loc) . clone ( ) ?,
300
308
PlaceBase :: Static ( box Static { kind : StaticKind :: Promoted ( promoted) , ..} ) => {
301
309
let generics = self . tcx . generics_of ( self . source . def_id ( ) ) ;
302
310
if generics. requires_monomorphization ( self . tcx ) {
@@ -699,8 +707,8 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
699
707
trace ! ( "checking whether {:?} can be stored to {:?}" , value, local) ;
700
708
if self . can_const_prop [ local] {
701
709
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) ) ;
704
712
705
713
if self . should_const_prop ( ) {
706
714
self . replace_with_const (
@@ -740,7 +748,7 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
740
748
place = & proj. base ;
741
749
}
742
750
if let Place :: Base ( PlaceBase :: Local ( local) ) = * place {
743
- self . places [ local] = None ;
751
+ self . set_const ( local, None ) ;
744
752
}
745
753
} ,
746
754
Operand :: Constant ( _) => { }
0 commit comments