@@ -71,11 +71,17 @@ pub struct MaybeInitializedPlaces<'a, 'tcx> {
7171 tcx : TyCtxt < ' tcx > ,
7272 body : & ' a Body < ' tcx > ,
7373 mdpe : & ' a MoveDataParamEnv < ' tcx > ,
74+ mark_inactive_variants_as_uninit : bool ,
7475}
7576
7677impl < ' a , ' tcx > MaybeInitializedPlaces < ' a , ' tcx > {
7778 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
7985 }
8086}
8187
@@ -138,8 +144,8 @@ impl<'a, 'tcx> MaybeUninitializedPlaces<'a, 'tcx> {
138144 ///
139145 /// This is correct in a vacuum but is not the default because it causes problems in the borrow
140146 /// 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 ;
143149 self
144150 }
145151}
@@ -362,6 +368,10 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
362368 _adt : & ty:: AdtDef ,
363369 variant : VariantIdx ,
364370 ) {
371+ if !self . mark_inactive_variants_as_uninit {
372+ return ;
373+ }
374+
365375 // Kill all move paths that correspond to variants we know to be inactive along this
366376 // particular outgoing edge of a `SwitchInt`.
367377 drop_flag_effects:: on_all_inactive_variants (
0 commit comments