@@ -12,7 +12,7 @@ use crate::framework::SwitchIntEdgeEffects;
1212use crate :: move_paths:: { HasMoveData , InitIndex , InitKind , LookupResult , MoveData , MovePathIndex } ;
1313use crate :: {
1414 Analysis , GenKill , MaybeReachable , drop_flag_effects, drop_flag_effects_for_function_entry,
15- drop_flag_effects_for_location, lattice , on_all_children_bits, on_lookup_result_bits,
15+ drop_flag_effects_for_location, on_all_children_bits, on_lookup_result_bits,
1616} ;
1717
1818/// `MaybeInitializedPlaces` tracks all places that might be
@@ -42,10 +42,10 @@ use crate::{
4242/// }
4343/// ```
4444///
45- /// To determine whether a place *must* be initialized at a
46- /// particular control-flow point, one can take the set-difference
47- /// between this data and the data from `MaybeUninitializedPlaces` at the
48- /// corresponding control-flow point.
45+ /// To determine whether a place is *definitely* initialized at a
46+ /// particular control-flow point, one can take the set-complement
47+ /// of the data from `MaybeUninitializedPlaces` at the corresponding
48+ /// control-flow point.
4949///
5050/// Similarly, at a given `drop` statement, the set-intersection
5151/// between this data and `MaybeUninitializedPlaces` yields the set of
@@ -117,10 +117,10 @@ impl<'a, 'tcx> HasMoveData<'tcx> for MaybeInitializedPlaces<'a, 'tcx> {
117117/// }
118118/// ```
119119///
120- /// To determine whether a place *must* be uninitialized at a
121- /// particular control-flow point, one can take the set-difference
122- /// between this data and the data from `MaybeInitializedPlaces` at the
123- /// corresponding control-flow point.
120+ /// To determine whether a place is *definitely* uninitialized at a
121+ /// particular control-flow point, one can take the set-complement
122+ /// of the data from `MaybeInitializedPlaces` at the corresponding
123+ /// control-flow point.
124124///
125125/// Similarly, at a given `drop` statement, the set-intersection
126126/// between this data and `MaybeInitializedPlaces` yields the set of
@@ -170,57 +170,6 @@ impl<'tcx> HasMoveData<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
170170 }
171171}
172172
173- /// `DefinitelyInitializedPlaces` tracks all places that are definitely
174- /// initialized upon reaching a particular point in the control flow
175- /// for a function.
176- ///
177- /// For example, in code like the following, we have corresponding
178- /// dataflow information shown in the right-hand comments.
179- ///
180- /// ```rust
181- /// struct S;
182- /// fn foo(pred: bool) { // definite-init:
183- /// // { }
184- /// let a = S; let mut b = S; let c; let d; // {a, b }
185- ///
186- /// if pred {
187- /// drop(a); // { b, }
188- /// b = S; // { b, }
189- ///
190- /// } else {
191- /// drop(b); // {a, }
192- /// d = S; // {a, d}
193- ///
194- /// } // { }
195- ///
196- /// c = S; // { c }
197- /// }
198- /// ```
199- ///
200- /// To determine whether a place *may* be uninitialized at a
201- /// particular control-flow point, one can take the set-complement
202- /// of this data.
203- ///
204- /// Similarly, at a given `drop` statement, the set-difference between
205- /// this data and `MaybeInitializedPlaces` yields the set of places
206- /// that would require a dynamic drop-flag at that statement.
207- pub struct DefinitelyInitializedPlaces < ' a , ' tcx > {
208- body : & ' a Body < ' tcx > ,
209- move_data : & ' a MoveData < ' tcx > ,
210- }
211-
212- impl < ' a , ' tcx > DefinitelyInitializedPlaces < ' a , ' tcx > {
213- pub fn new ( body : & ' a Body < ' tcx > , move_data : & ' a MoveData < ' tcx > ) -> Self {
214- DefinitelyInitializedPlaces { body, move_data }
215- }
216- }
217-
218- impl < ' a , ' tcx > HasMoveData < ' tcx > for DefinitelyInitializedPlaces < ' a , ' tcx > {
219- fn move_data ( & self ) -> & MoveData < ' tcx > {
220- self . move_data
221- }
222- }
223-
224173/// `EverInitializedPlaces` tracks all places that might have ever been
225174/// initialized upon reaching a particular point in the control flow
226175/// for a function, without an intervening `StorageDead`.
@@ -293,19 +242,6 @@ impl<'tcx> MaybeUninitializedPlaces<'_, 'tcx> {
293242 }
294243}
295244
296- impl < ' a , ' tcx > DefinitelyInitializedPlaces < ' a , ' tcx > {
297- fn update_bits (
298- trans : & mut <Self as Analysis < ' tcx > >:: Domain ,
299- path : MovePathIndex ,
300- state : DropFlagState ,
301- ) {
302- match state {
303- DropFlagState :: Absent => trans. kill ( path) ,
304- DropFlagState :: Present => trans. gen_ ( path) ,
305- }
306- }
307- }
308-
309245impl < ' tcx > Analysis < ' tcx > for MaybeInitializedPlaces < ' _ , ' tcx > {
310246 /// There can be many more `MovePathIndex` than there are locals in a MIR body.
311247 /// We use a chunked bitset to avoid paying too high a memory footprint.
@@ -554,70 +490,6 @@ impl<'tcx> Analysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
554490 }
555491}
556492
557- impl < ' a , ' tcx > Analysis < ' tcx > for DefinitelyInitializedPlaces < ' a , ' tcx > {
558- /// Use set intersection as the join operator.
559- type Domain = lattice:: Dual < BitSet < MovePathIndex > > ;
560-
561- const NAME : & ' static str = "definite_init" ;
562-
563- fn bottom_value ( & self , _: & mir:: Body < ' tcx > ) -> Self :: Domain {
564- // bottom = initialized (start_block_effect counters this at outset)
565- lattice:: Dual ( BitSet :: new_filled ( self . move_data ( ) . move_paths . len ( ) ) )
566- }
567-
568- // sets on_entry bits for Arg places
569- fn initialize_start_block ( & self , _: & mir:: Body < ' tcx > , state : & mut Self :: Domain ) {
570- state. 0 . clear ( ) ;
571-
572- drop_flag_effects_for_function_entry ( self . body , self . move_data , |path, s| {
573- assert ! ( s == DropFlagState :: Present ) ;
574- state. 0 . insert ( path) ;
575- } ) ;
576- }
577-
578- fn apply_statement_effect (
579- & mut self ,
580- trans : & mut Self :: Domain ,
581- _statement : & mir:: Statement < ' tcx > ,
582- location : Location ,
583- ) {
584- drop_flag_effects_for_location ( self . body , self . move_data , location, |path, s| {
585- Self :: update_bits ( trans, path, s)
586- } )
587- }
588-
589- fn apply_terminator_effect < ' mir > (
590- & mut self ,
591- trans : & mut Self :: Domain ,
592- terminator : & ' mir mir:: Terminator < ' tcx > ,
593- location : Location ,
594- ) -> TerminatorEdges < ' mir , ' tcx > {
595- drop_flag_effects_for_location ( self . body , self . move_data , location, |path, s| {
596- Self :: update_bits ( trans, path, s)
597- } ) ;
598- terminator. edges ( )
599- }
600-
601- fn apply_call_return_effect (
602- & mut self ,
603- trans : & mut Self :: Domain ,
604- _block : mir:: BasicBlock ,
605- return_places : CallReturnPlaces < ' _ , ' tcx > ,
606- ) {
607- return_places. for_each ( |place| {
608- // when a call returns successfully, that means we need to set
609- // the bits for that dest_place to 1 (initialized).
610- on_lookup_result_bits (
611- self . move_data ( ) ,
612- self . move_data ( ) . rev_lookup . find ( place. as_ref ( ) ) ,
613- |mpi| {
614- trans. gen_ ( mpi) ;
615- } ,
616- ) ;
617- } ) ;
618- }
619- }
620-
621493impl < ' tcx > Analysis < ' tcx > for EverInitializedPlaces < ' _ , ' tcx > {
622494 /// There can be many more `InitIndex` than there are locals in a MIR body.
623495 /// We use a chunked bitset to avoid paying too high a memory footprint.
0 commit comments