@@ -74,11 +74,11 @@ pub trait ValueAnalysis<'tcx> {
7474 StatementKind :: StorageLive ( local) | StatementKind :: StorageDead ( local) => {
7575 // StorageLive leaves the local in an uninitialized state.
7676 // StorageDead makes it UB to access the local afterwards.
77- state. flood_with ( Place :: from ( * local) . as_ref ( ) , self . map ( ) , Self :: Value :: bottom ( ) ) ;
77+ state. flood_with ( Place :: from ( * local) . as_ref ( ) , self . map ( ) , Self :: Value :: BOTTOM ) ;
7878 }
7979 StatementKind :: Deinit ( box place) => {
8080 // Deinit makes the place uninitialized.
81- state. flood_with ( place. as_ref ( ) , self . map ( ) , Self :: Value :: bottom ( ) ) ;
81+ state. flood_with ( place. as_ref ( ) , self . map ( ) , Self :: Value :: BOTTOM ) ;
8282 }
8383 StatementKind :: Retag ( ..) => {
8484 // We don't track references.
@@ -154,7 +154,7 @@ pub trait ValueAnalysis<'tcx> {
154154 Rvalue :: CopyForDeref ( place) => self . handle_operand ( & Operand :: Copy ( * place) , state) ,
155155 Rvalue :: Ref ( ..) | Rvalue :: AddressOf ( ..) => {
156156 // We don't track such places.
157- ValueOrPlace :: top ( )
157+ ValueOrPlace :: TOP
158158 }
159159 Rvalue :: Repeat ( ..)
160160 | Rvalue :: ThreadLocalRef ( ..)
@@ -168,7 +168,7 @@ pub trait ValueAnalysis<'tcx> {
168168 | Rvalue :: Aggregate ( ..)
169169 | Rvalue :: ShallowInitBox ( ..) => {
170170 // No modification is possible through these r-values.
171- ValueOrPlace :: top ( )
171+ ValueOrPlace :: TOP
172172 }
173173 }
174174 }
@@ -196,7 +196,7 @@ pub trait ValueAnalysis<'tcx> {
196196 self . map ( )
197197 . find ( place. as_ref ( ) )
198198 . map ( ValueOrPlace :: Place )
199- . unwrap_or ( ValueOrPlace :: top ( ) )
199+ . unwrap_or ( ValueOrPlace :: TOP )
200200 }
201201 }
202202 }
@@ -214,7 +214,7 @@ pub trait ValueAnalysis<'tcx> {
214214 _constant : & Constant < ' tcx > ,
215215 _state : & mut State < Self :: Value > ,
216216 ) -> Self :: Value {
217- Self :: Value :: top ( )
217+ Self :: Value :: TOP
218218 }
219219
220220 /// The effect of a successful function call return should not be
@@ -229,7 +229,7 @@ pub trait ValueAnalysis<'tcx> {
229229 // Effect is applied by `handle_call_return`.
230230 }
231231 TerminatorKind :: Drop { place, .. } => {
232- state. flood_with ( place. as_ref ( ) , self . map ( ) , Self :: Value :: bottom ( ) ) ;
232+ state. flood_with ( place. as_ref ( ) , self . map ( ) , Self :: Value :: BOTTOM ) ;
233233 }
234234 TerminatorKind :: Yield { .. } => {
235235 // They would have an effect, but are not allowed in this phase.
@@ -307,7 +307,7 @@ impl<'tcx, T: ValueAnalysis<'tcx>> AnalysisDomain<'tcx> for ValueAnalysisWrapper
307307 fn initialize_start_block ( & self , body : & Body < ' tcx > , state : & mut Self :: Domain ) {
308308 // The initial state maps all tracked places of argument projections to ⊤ and the rest to ⊥.
309309 assert ! ( matches!( state. 0 , StateData :: Unreachable ) ) ;
310- let values = IndexVec :: from_elem_n ( T :: Value :: bottom ( ) , self . 0 . map ( ) . value_count ) ;
310+ let values = IndexVec :: from_elem_n ( T :: Value :: BOTTOM , self . 0 . map ( ) . value_count ) ;
311311 * state = State ( StateData :: Reachable ( values) ) ;
312312 for arg in body. args_iter ( ) {
313313 state. flood ( PlaceRef { local : arg, projection : & [ ] } , self . 0 . map ( ) ) ;
@@ -437,7 +437,7 @@ impl<V: Clone + HasTop + HasBottom> State<V> {
437437 }
438438
439439 pub fn flood_all ( & mut self ) {
440- self . flood_all_with ( V :: top ( ) )
440+ self . flood_all_with ( V :: TOP )
441441 }
442442
443443 pub fn flood_all_with ( & mut self , value : V ) {
@@ -455,7 +455,7 @@ impl<V: Clone + HasTop + HasBottom> State<V> {
455455 }
456456
457457 pub fn flood ( & mut self , place : PlaceRef < ' _ > , map : & Map ) {
458- self . flood_with ( place, map, V :: top ( ) )
458+ self . flood_with ( place, map, V :: TOP )
459459 }
460460
461461 pub fn flood_discr_with ( & mut self , place : PlaceRef < ' _ > , map : & Map , value : V ) {
@@ -468,7 +468,7 @@ impl<V: Clone + HasTop + HasBottom> State<V> {
468468 }
469469
470470 pub fn flood_discr ( & mut self , place : PlaceRef < ' _ > , map : & Map ) {
471- self . flood_discr_with ( place, map, V :: top ( ) )
471+ self . flood_discr_with ( place, map, V :: TOP )
472472 }
473473
474474 /// Low-level method that assigns to a place.
@@ -538,26 +538,26 @@ impl<V: Clone + HasTop + HasBottom> State<V> {
538538
539539 /// Retrieve the value stored for a place, or ⊤ if it is not tracked.
540540 pub fn get ( & self , place : PlaceRef < ' _ > , map : & Map ) -> V {
541- map. find ( place) . map ( |place| self . get_idx ( place, map) ) . unwrap_or ( V :: top ( ) )
541+ map. find ( place) . map ( |place| self . get_idx ( place, map) ) . unwrap_or ( V :: TOP )
542542 }
543543
544544 /// Retrieve the value stored for a place, or ⊤ if it is not tracked.
545545 pub fn get_discr ( & self , place : PlaceRef < ' _ > , map : & Map ) -> V {
546546 match map. find_discr ( place) {
547547 Some ( place) => self . get_idx ( place, map) ,
548- None => V :: top ( ) ,
548+ None => V :: TOP ,
549549 }
550550 }
551551
552552 /// Retrieve the value stored for a place index, or ⊤ if it is not tracked.
553553 pub fn get_idx ( & self , place : PlaceIndex , map : & Map ) -> V {
554554 match & self . 0 {
555555 StateData :: Reachable ( values) => {
556- map. places [ place] . value_index . map ( |v| values[ v] . clone ( ) ) . unwrap_or ( V :: top ( ) )
556+ map. places [ place] . value_index . map ( |v| values[ v] . clone ( ) ) . unwrap_or ( V :: TOP )
557557 }
558558 StateData :: Unreachable => {
559559 // Because this is unreachable, we can return any value we want.
560- V :: bottom ( )
560+ V :: BOTTOM
561561 }
562562 }
563563 }
@@ -909,9 +909,7 @@ pub enum ValueOrPlace<V> {
909909}
910910
911911impl < V : HasTop > ValueOrPlace < V > {
912- pub fn top ( ) -> Self {
913- ValueOrPlace :: Value ( V :: top ( ) )
914- }
912+ pub const TOP : Self = ValueOrPlace :: Value ( V :: TOP ) ;
915913}
916914
917915/// The set of projection elements that can be used by a tracked place.
0 commit comments