1- use rustc_index:: bit_set:: { BitSet , ChunkedBitSet } ;
2- use rustc_index:: Idx ;
3- use rustc_middle:: mir:: { self , Body , CallReturnPlaces , Location , TerminatorEdges } ;
4- use rustc_middle:: ty:: { self , TyCtxt } ;
5-
61use crate :: drop_flag_effects_for_function_entry;
72use crate :: drop_flag_effects_for_location;
83use crate :: elaborate_drops:: DropFlagState ;
@@ -12,6 +7,11 @@ use crate::on_lookup_result_bits;
127use crate :: MoveDataParamEnv ;
138use crate :: { drop_flag_effects, on_all_children_bits, on_all_drop_children_bits} ;
149use crate :: { lattice, AnalysisDomain , GenKill , GenKillAnalysis , MaybeReachable } ;
10+ use rustc_index:: bit_set:: { BitSet , ChunkedBitSet } ;
11+ use rustc_index:: Idx ;
12+ use rustc_middle:: mir:: { self , Body , CallReturnPlaces , Location , TerminatorEdges } ;
13+ use rustc_middle:: ty:: ParamEnv ;
14+ use rustc_middle:: ty:: { self , TyCtxt } ;
1515
1616/// `MaybeInitializedPlaces` tracks all places that might be
1717/// initialized upon reaching a particular point in the control flow
@@ -759,7 +759,15 @@ fn switch_on_enum_discriminant<'mir, 'tcx>(
759759 mir:: StatementKind :: Assign ( box ( lhs, mir:: Rvalue :: Discriminant ( discriminated) ) )
760760 if * lhs == switch_on =>
761761 {
762- match discriminated. ty ( body, tcx) . ty . kind ( ) {
762+ let mut kind = discriminated. ty ( body, tcx) . ty . kind ( ) ;
763+ if discriminated. ty ( body, tcx) . ty . is_impl_trait ( ) {
764+ let ty = tcx. normalize_erasing_regions (
765+ ParamEnv :: reveal_all ( ) ,
766+ discriminated. ty ( body, tcx) . ty ,
767+ ) ;
768+ kind = ty. kind ( ) ;
769+ }
770+ match kind {
763771 ty:: Adt ( def, _) => return Some ( ( * discriminated, * def) ) ,
764772
765773 // `Rvalue::Discriminant` is also used to get the active yield point for a
0 commit comments