@@ -67,15 +67,15 @@ pub use self::storage_liveness::{MaybeRequiresStorage, MaybeStorageLive};
67
67
/// Similarly, at a given `drop` statement, the set-intersection
68
68
/// between this data and `MaybeUninitializedPlaces` yields the set of
69
69
/// 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 > > {
71
71
tcx : TyCtxt < ' tcx > ,
72
72
body : & ' a Body < ' tcx > ,
73
- mdpe : & ' a MoveDataParamEnv < ' tcx > ,
73
+ pub ( crate ) mdpe : M ,
74
74
mark_inactive_variants_as_uninit : bool ,
75
75
}
76
76
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 {
79
79
MaybeInitializedPlaces { tcx, body, mdpe, mark_inactive_variants_as_uninit : false }
80
80
}
81
81
@@ -85,9 +85,12 @@ impl<'a, 'tcx> MaybeInitializedPlaces<'a, 'tcx> {
85
85
}
86
86
}
87
87
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
+ {
89
92
fn move_data ( & self ) -> & MoveData < ' tcx > {
90
- & self . mdpe . move_data
93
+ & self . mdpe . borrow ( ) . move_data
91
94
}
92
95
}
93
96
@@ -256,7 +259,7 @@ impl<'a, 'tcx> HasMoveData<'tcx> for EverInitializedPlaces<'a, 'tcx> {
256
259
}
257
260
}
258
261
259
- impl < ' a , ' tcx > MaybeInitializedPlaces < ' a , ' tcx > {
262
+ impl < ' a , ' tcx , M > MaybeInitializedPlaces < ' a , ' tcx , M > {
260
263
fn update_bits (
261
264
trans : & mut impl GenKill < MovePathIndex > ,
262
265
path : MovePathIndex ,
@@ -295,7 +298,10 @@ impl<'a, 'tcx> DefinitelyInitializedPlaces<'a, 'tcx> {
295
298
}
296
299
}
297
300
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
+ {
299
305
type Idx = MovePathIndex ;
300
306
301
307
const NAME : & ' static str = "maybe_init" ;
@@ -305,7 +311,7 @@ impl<'tcx> AnalysisDomain<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
305
311
}
306
312
307
313
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| {
309
315
assert ! ( s == DropFlagState :: Present ) ;
310
316
state. insert ( path) ;
311
317
} ) ;
@@ -316,16 +322,23 @@ impl<'tcx> AnalysisDomain<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
316
322
}
317
323
}
318
324
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
+ {
320
329
fn statement_effect (
321
330
& self ,
322
331
trans : & mut impl GenKill < Self :: Idx > ,
323
332
_statement : & mir:: Statement < ' tcx > ,
324
333
location : Location ,
325
334
) {
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
+ )
329
342
}
330
343
331
344
fn terminator_effect (
@@ -334,9 +347,13 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
334
347
_terminator : & mir:: Terminator < ' tcx > ,
335
348
location : Location ,
336
349
) {
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
+ )
340
357
}
341
358
342
359
fn call_return_effect (
@@ -636,7 +653,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for EverInitializedPlaces<'_, 'tcx> {
636
653
}
637
654
}
638
655
639
- impl < ' a , ' tcx > BottomValue for MaybeInitializedPlaces < ' a , ' tcx > {
656
+ impl < ' a , ' tcx , M > BottomValue for MaybeInitializedPlaces < ' a , ' tcx , M > {
640
657
/// bottom = uninitialized
641
658
const BOTTOM_VALUE : bool = false ;
642
659
}
0 commit comments