@@ -74,11 +74,11 @@ pub trait ValueAnalysis<'tcx> {
74
74
StatementKind :: StorageLive ( local) | StatementKind :: StorageDead ( local) => {
75
75
// StorageLive leaves the local in an uninitialized state.
76
76
// 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 ) ;
78
78
}
79
79
StatementKind :: Deinit ( box place) => {
80
80
// 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 ) ;
82
82
}
83
83
StatementKind :: Retag ( ..) => {
84
84
// We don't track references.
@@ -154,7 +154,7 @@ pub trait ValueAnalysis<'tcx> {
154
154
Rvalue :: CopyForDeref ( place) => self . handle_operand ( & Operand :: Copy ( * place) , state) ,
155
155
Rvalue :: Ref ( ..) | Rvalue :: AddressOf ( ..) => {
156
156
// We don't track such places.
157
- ValueOrPlace :: top ( )
157
+ ValueOrPlace :: TOP
158
158
}
159
159
Rvalue :: Repeat ( ..)
160
160
| Rvalue :: ThreadLocalRef ( ..)
@@ -168,7 +168,7 @@ pub trait ValueAnalysis<'tcx> {
168
168
| Rvalue :: Aggregate ( ..)
169
169
| Rvalue :: ShallowInitBox ( ..) => {
170
170
// No modification is possible through these r-values.
171
- ValueOrPlace :: top ( )
171
+ ValueOrPlace :: TOP
172
172
}
173
173
}
174
174
}
@@ -196,7 +196,7 @@ pub trait ValueAnalysis<'tcx> {
196
196
self . map ( )
197
197
. find ( place. as_ref ( ) )
198
198
. map ( ValueOrPlace :: Place )
199
- . unwrap_or ( ValueOrPlace :: top ( ) )
199
+ . unwrap_or ( ValueOrPlace :: TOP )
200
200
}
201
201
}
202
202
}
@@ -214,7 +214,7 @@ pub trait ValueAnalysis<'tcx> {
214
214
_constant : & Constant < ' tcx > ,
215
215
_state : & mut State < Self :: Value > ,
216
216
) -> Self :: Value {
217
- Self :: Value :: top ( )
217
+ Self :: Value :: TOP
218
218
}
219
219
220
220
/// The effect of a successful function call return should not be
@@ -229,7 +229,7 @@ pub trait ValueAnalysis<'tcx> {
229
229
// Effect is applied by `handle_call_return`.
230
230
}
231
231
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 ) ;
233
233
}
234
234
TerminatorKind :: Yield { .. } => {
235
235
// 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
307
307
fn initialize_start_block ( & self , body : & Body < ' tcx > , state : & mut Self :: Domain ) {
308
308
// The initial state maps all tracked places of argument projections to ⊤ and the rest to ⊥.
309
309
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 ) ;
311
311
* state = State ( StateData :: Reachable ( values) ) ;
312
312
for arg in body. args_iter ( ) {
313
313
state. flood ( PlaceRef { local : arg, projection : & [ ] } , self . 0 . map ( ) ) ;
@@ -437,7 +437,7 @@ impl<V: Clone + HasTop + HasBottom> State<V> {
437
437
}
438
438
439
439
pub fn flood_all ( & mut self ) {
440
- self . flood_all_with ( V :: top ( ) )
440
+ self . flood_all_with ( V :: TOP )
441
441
}
442
442
443
443
pub fn flood_all_with ( & mut self , value : V ) {
@@ -455,7 +455,7 @@ impl<V: Clone + HasTop + HasBottom> State<V> {
455
455
}
456
456
457
457
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 )
459
459
}
460
460
461
461
pub fn flood_discr_with ( & mut self , place : PlaceRef < ' _ > , map : & Map , value : V ) {
@@ -468,7 +468,7 @@ impl<V: Clone + HasTop + HasBottom> State<V> {
468
468
}
469
469
470
470
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 )
472
472
}
473
473
474
474
/// Low-level method that assigns to a place.
@@ -538,26 +538,26 @@ impl<V: Clone + HasTop + HasBottom> State<V> {
538
538
539
539
/// Retrieve the value stored for a place, or ⊤ if it is not tracked.
540
540
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 )
542
542
}
543
543
544
544
/// Retrieve the value stored for a place, or ⊤ if it is not tracked.
545
545
pub fn get_discr ( & self , place : PlaceRef < ' _ > , map : & Map ) -> V {
546
546
match map. find_discr ( place) {
547
547
Some ( place) => self . get_idx ( place, map) ,
548
- None => V :: top ( ) ,
548
+ None => V :: TOP ,
549
549
}
550
550
}
551
551
552
552
/// Retrieve the value stored for a place index, or ⊤ if it is not tracked.
553
553
pub fn get_idx ( & self , place : PlaceIndex , map : & Map ) -> V {
554
554
match & self . 0 {
555
555
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 )
557
557
}
558
558
StateData :: Unreachable => {
559
559
// Because this is unreachable, we can return any value we want.
560
- V :: bottom ( )
560
+ V :: BOTTOM
561
561
}
562
562
}
563
563
}
@@ -909,9 +909,7 @@ pub enum ValueOrPlace<V> {
909
909
}
910
910
911
911
impl < V : HasTop > ValueOrPlace < V > {
912
- pub fn top ( ) -> Self {
913
- ValueOrPlace :: Value ( V :: top ( ) )
914
- }
912
+ pub const TOP : Self = ValueOrPlace :: Value ( V :: TOP ) ;
915
913
}
916
914
917
915
/// The set of projection elements that can be used by a tracked place.
0 commit comments