@@ -52,7 +52,6 @@ use super::{FieldPat, Pat, PatKind, PatRange};
5252use rustc_data_structures:: captures:: Captures ;
5353use rustc_index:: vec:: Idx ;
5454
55- use rustc_hir:: def_id:: DefId ;
5655use rustc_hir:: { HirId , RangeEnd } ;
5756use rustc_middle:: mir:: interpret:: ConstValue ;
5857use rustc_middle:: mir:: Field ;
@@ -590,7 +589,7 @@ pub(super) enum Constructor<'tcx> {
590589 /// and fixed-length arrays.
591590 Single ,
592591 /// Enum variants.
593- Variant ( DefId ) ,
592+ Variant ( VariantIdx ) ,
594593 /// Ranges of integer literal values (`2`, `2..=5` or `2..5`).
595594 IntRange ( IntRange ) ,
596595 /// Ranges of floating-point literal values (`2.0..=5.2`).
@@ -634,7 +633,7 @@ impl<'tcx> Constructor<'tcx> {
634633
635634 fn variant_index_for_adt ( & self , adt : & ' tcx ty:: AdtDef ) -> VariantIdx {
636635 match * self {
637- Variant ( id ) => adt . variant_index_with_id ( id ) ,
636+ Variant ( idx ) => idx ,
638637 Single => {
639638 assert ! ( !adt. is_enum( ) ) ;
640639 VariantIdx :: new ( 0 )
@@ -649,9 +648,7 @@ impl<'tcx> Constructor<'tcx> {
649648 PatKind :: AscribeUserType { .. } => bug ! ( ) , // Handled by `expand_pattern`
650649 PatKind :: Binding { .. } | PatKind :: Wild => Wildcard ,
651650 PatKind :: Leaf { .. } | PatKind :: Deref { .. } => Single ,
652- & PatKind :: Variant { adt_def, variant_index, .. } => {
653- Variant ( adt_def. variants [ variant_index] . def_id )
654- }
651+ & PatKind :: Variant { variant_index, .. } => Variant ( variant_index) ,
655652 PatKind :: Constant { value } => {
656653 if let Some ( int_range) = IntRange :: from_const ( cx. tcx , cx. param_env , value) {
657654 IntRange ( int_range)
@@ -928,15 +925,15 @@ impl<'tcx> SplitWildcard<'tcx> {
928925 // If `exhaustive_patterns` is enabled, we exclude variants known to be
929926 // uninhabited.
930927 def. variants
931- . iter ( )
932- . filter ( |v | {
928+ . iter_enumerated ( )
929+ . filter ( |( _ , v ) | {
933930 !v. uninhabited_from ( cx. tcx , substs, def. adt_kind ( ) , cx. param_env )
934931 . contains ( cx. tcx , cx. module )
935932 } )
936- . map ( |v | Variant ( v . def_id ) )
933+ . map ( |( idx , _ ) | Variant ( idx ) )
937934 . collect ( )
938935 } else {
939- def. variants . iter ( ) . map ( |v | Variant ( v . def_id ) ) . collect ( )
936+ def. variants . indices ( ) . map ( |idx | Variant ( idx ) ) . collect ( )
940937 }
941938 }
942939 ty:: Char => {
0 commit comments