@@ -71,11 +71,17 @@ pub struct MaybeInitializedPlaces<'a, 'tcx> {
71
71
tcx : TyCtxt < ' tcx > ,
72
72
body : & ' a Body < ' tcx > ,
73
73
mdpe : & ' a MoveDataParamEnv < ' tcx > ,
74
+ mark_inactive_variants_as_uninit : bool ,
74
75
}
75
76
76
77
impl < ' a , ' tcx > MaybeInitializedPlaces < ' a , ' tcx > {
77
78
pub fn new ( tcx : TyCtxt < ' tcx > , body : & ' a Body < ' tcx > , mdpe : & ' a MoveDataParamEnv < ' tcx > ) -> Self {
78
- MaybeInitializedPlaces { tcx, body, mdpe }
79
+ MaybeInitializedPlaces { tcx, body, mdpe, mark_inactive_variants_as_uninit : false }
80
+ }
81
+
82
+ pub fn mark_inactive_variants_as_uninit ( mut self , yes : bool ) -> Self {
83
+ self . mark_inactive_variants_as_uninit = yes;
84
+ self
79
85
}
80
86
}
81
87
@@ -138,8 +144,8 @@ impl<'a, 'tcx> MaybeUninitializedPlaces<'a, 'tcx> {
138
144
///
139
145
/// This is correct in a vacuum but is not the default because it causes problems in the borrow
140
146
/// checker, where this information gets propagated along `FakeEdge`s.
141
- pub fn mark_inactive_variants_as_uninit ( mut self ) -> Self {
142
- self . mark_inactive_variants_as_uninit = true ;
147
+ pub fn mark_inactive_variants_as_uninit ( mut self , yes : bool ) -> Self {
148
+ self . mark_inactive_variants_as_uninit = yes ;
143
149
self
144
150
}
145
151
}
@@ -362,6 +368,10 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
362
368
_adt : & ty:: AdtDef ,
363
369
variant : VariantIdx ,
364
370
) {
371
+ if !self . mark_inactive_variants_as_uninit {
372
+ return ;
373
+ }
374
+
365
375
// Kill all move paths that correspond to variants we know to be inactive along this
366
376
// particular outgoing edge of a `SwitchInt`.
367
377
drop_flag_effects:: on_all_inactive_variants (
0 commit comments