@@ -67,15 +67,15 @@ pub use self::storage_liveness::{MaybeRequiresStorage, MaybeStorageLive};
6767/// Similarly, at a given `drop` statement, the set-intersection
6868/// between this data and `MaybeUninitializedPlaces` yields the set of
6969/// places that would require a dynamic drop-flag at that statement.
70- pub struct MaybeInitializedPlaces < ' a , ' tcx > {
70+ pub struct MaybeInitializedPlaces < ' a , ' tcx , M = & ' a MoveDataParamEnv < ' tcx > > {
7171 tcx : TyCtxt < ' tcx > ,
7272 body : & ' a Body < ' tcx > ,
73- mdpe : & ' a MoveDataParamEnv < ' tcx > ,
73+ pub ( crate ) mdpe : M ,
7474 mark_inactive_variants_as_uninit : bool ,
7575}
7676
77- impl < ' a , ' tcx > MaybeInitializedPlaces < ' a , ' tcx > {
78- pub fn new ( tcx : TyCtxt < ' tcx > , body : & ' a Body < ' tcx > , mdpe : & ' a MoveDataParamEnv < ' tcx > ) -> Self {
77+ impl < ' a , ' tcx , M > MaybeInitializedPlaces < ' a , ' tcx , M > {
78+ pub fn new ( tcx : TyCtxt < ' tcx > , body : & ' a Body < ' tcx > , mdpe : M ) -> Self {
7979 MaybeInitializedPlaces { tcx, body, mdpe, mark_inactive_variants_as_uninit : false }
8080 }
8181
@@ -85,9 +85,12 @@ impl<'a, 'tcx> MaybeInitializedPlaces<'a, 'tcx> {
8585 }
8686}
8787
88- impl < ' a , ' tcx > HasMoveData < ' tcx > for MaybeInitializedPlaces < ' a , ' tcx > {
88+ impl < ' a , ' tcx , M > HasMoveData < ' tcx > for MaybeInitializedPlaces < ' a , ' tcx , M >
89+ where
90+ M : std:: borrow:: Borrow < MoveDataParamEnv < ' tcx > > ,
91+ {
8992 fn move_data ( & self ) -> & MoveData < ' tcx > {
90- & self . mdpe . move_data
93+ & self . mdpe . borrow ( ) . move_data
9194 }
9295}
9396
@@ -256,7 +259,7 @@ impl<'a, 'tcx> HasMoveData<'tcx> for EverInitializedPlaces<'a, 'tcx> {
256259 }
257260}
258261
259- impl < ' a , ' tcx > MaybeInitializedPlaces < ' a , ' tcx > {
262+ impl < ' a , ' tcx , M > MaybeInitializedPlaces < ' a , ' tcx , M > {
260263 fn update_bits (
261264 trans : & mut impl GenKill < MovePathIndex > ,
262265 path : MovePathIndex ,
@@ -295,7 +298,10 @@ impl<'a, 'tcx> DefinitelyInitializedPlaces<'a, 'tcx> {
295298 }
296299}
297300
298- impl < ' tcx > AnalysisDomain < ' tcx > for MaybeInitializedPlaces < ' _ , ' tcx > {
301+ impl < ' tcx , M > AnalysisDomain < ' tcx > for MaybeInitializedPlaces < ' _ , ' tcx , M >
302+ where
303+ M : std:: borrow:: Borrow < MoveDataParamEnv < ' tcx > > ,
304+ {
299305 type Idx = MovePathIndex ;
300306
301307 const NAME : & ' static str = "maybe_init" ;
@@ -305,7 +311,7 @@ impl<'tcx> AnalysisDomain<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
305311 }
306312
307313 fn initialize_start_block ( & self , _: & mir:: Body < ' tcx > , state : & mut BitSet < Self :: Idx > ) {
308- drop_flag_effects_for_function_entry ( self . tcx , self . body , self . mdpe , |path, s| {
314+ drop_flag_effects_for_function_entry ( self . tcx , self . body , self . mdpe . borrow ( ) , |path, s| {
309315 assert ! ( s == DropFlagState :: Present ) ;
310316 state. insert ( path) ;
311317 } ) ;
@@ -316,16 +322,23 @@ impl<'tcx> AnalysisDomain<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
316322 }
317323}
318324
319- impl < ' tcx > GenKillAnalysis < ' tcx > for MaybeInitializedPlaces < ' _ , ' tcx > {
325+ impl < ' tcx , M > GenKillAnalysis < ' tcx > for MaybeInitializedPlaces < ' _ , ' tcx , M >
326+ where
327+ M : std:: borrow:: Borrow < MoveDataParamEnv < ' tcx > > ,
328+ {
320329 fn statement_effect (
321330 & self ,
322331 trans : & mut impl GenKill < Self :: Idx > ,
323332 _statement : & mir:: Statement < ' tcx > ,
324333 location : Location ,
325334 ) {
326- drop_flag_effects_for_location ( self . tcx , self . body , self . mdpe , location, |path, s| {
327- Self :: update_bits ( trans, path, s)
328- } )
335+ drop_flag_effects_for_location (
336+ self . tcx ,
337+ self . body ,
338+ self . mdpe . borrow ( ) ,
339+ location,
340+ |path, s| Self :: update_bits ( trans, path, s) ,
341+ )
329342 }
330343
331344 fn terminator_effect (
@@ -334,9 +347,13 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
334347 _terminator : & mir:: Terminator < ' tcx > ,
335348 location : Location ,
336349 ) {
337- drop_flag_effects_for_location ( self . tcx , self . body , self . mdpe , location, |path, s| {
338- Self :: update_bits ( trans, path, s)
339- } )
350+ drop_flag_effects_for_location (
351+ self . tcx ,
352+ self . body ,
353+ self . mdpe . borrow ( ) ,
354+ location,
355+ |path, s| Self :: update_bits ( trans, path, s) ,
356+ )
340357 }
341358
342359 fn call_return_effect (
@@ -636,7 +653,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for EverInitializedPlaces<'_, 'tcx> {
636653 }
637654}
638655
639- impl < ' a , ' tcx > BottomValue for MaybeInitializedPlaces < ' a , ' tcx > {
656+ impl < ' a , ' tcx , M > BottomValue for MaybeInitializedPlaces < ' a , ' tcx , M > {
640657 /// bottom = uninitialized
641658 const BOTTOM_VALUE : bool = false ;
642659}
0 commit comments