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
-
6
1
use crate :: drop_flag_effects_for_function_entry;
7
2
use crate :: drop_flag_effects_for_location;
8
3
use crate :: elaborate_drops:: DropFlagState ;
@@ -12,6 +7,11 @@ use crate::on_lookup_result_bits;
12
7
use crate :: MoveDataParamEnv ;
13
8
use crate :: { drop_flag_effects, on_all_children_bits, on_all_drop_children_bits} ;
14
9
use 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 } ;
15
15
16
16
/// `MaybeInitializedPlaces` tracks all places that might be
17
17
/// initialized upon reaching a particular point in the control flow
@@ -759,7 +759,15 @@ fn switch_on_enum_discriminant<'mir, 'tcx>(
759
759
mir:: StatementKind :: Assign ( box ( lhs, mir:: Rvalue :: Discriminant ( discriminated) ) )
760
760
if * lhs == switch_on =>
761
761
{
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 {
763
771
ty:: Adt ( def, _) => return Some ( ( * discriminated, * def) ) ,
764
772
765
773
// `Rvalue::Discriminant` is also used to get the active yield point for a
0 commit comments