@@ -52,7 +52,6 @@ use super::{FieldPat, Pat, PatKind, PatRange};
52
52
use rustc_data_structures:: captures:: Captures ;
53
53
use rustc_index:: vec:: Idx ;
54
54
55
- use rustc_hir:: def_id:: DefId ;
56
55
use rustc_hir:: { HirId , RangeEnd } ;
57
56
use rustc_middle:: mir:: interpret:: ConstValue ;
58
57
use rustc_middle:: mir:: Field ;
@@ -590,7 +589,7 @@ pub(super) enum Constructor<'tcx> {
590
589
/// and fixed-length arrays.
591
590
Single ,
592
591
/// Enum variants.
593
- Variant ( DefId ) ,
592
+ Variant ( VariantIdx ) ,
594
593
/// Ranges of integer literal values (`2`, `2..=5` or `2..5`).
595
594
IntRange ( IntRange ) ,
596
595
/// Ranges of floating-point literal values (`2.0..=5.2`).
@@ -634,7 +633,7 @@ impl<'tcx> Constructor<'tcx> {
634
633
635
634
fn variant_index_for_adt ( & self , adt : & ' tcx ty:: AdtDef ) -> VariantIdx {
636
635
match * self {
637
- Variant ( id ) => adt . variant_index_with_id ( id ) ,
636
+ Variant ( idx ) => idx ,
638
637
Single => {
639
638
assert ! ( !adt. is_enum( ) ) ;
640
639
VariantIdx :: new ( 0 )
@@ -649,9 +648,7 @@ impl<'tcx> Constructor<'tcx> {
649
648
PatKind :: AscribeUserType { .. } => bug ! ( ) , // Handled by `expand_pattern`
650
649
PatKind :: Binding { .. } | PatKind :: Wild => Wildcard ,
651
650
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) ,
655
652
PatKind :: Constant { value } => {
656
653
if let Some ( int_range) = IntRange :: from_const ( cx. tcx , cx. param_env , value) {
657
654
IntRange ( int_range)
@@ -928,15 +925,15 @@ impl<'tcx> SplitWildcard<'tcx> {
928
925
// If `exhaustive_patterns` is enabled, we exclude variants known to be
929
926
// uninhabited.
930
927
def. variants
931
- . iter ( )
932
- . filter ( |v | {
928
+ . iter_enumerated ( )
929
+ . filter ( |( _ , v ) | {
933
930
!v. uninhabited_from ( cx. tcx , substs, def. adt_kind ( ) , cx. param_env )
934
931
. contains ( cx. tcx , cx. module )
935
932
} )
936
- . map ( |v | Variant ( v . def_id ) )
933
+ . map ( |( idx , _ ) | Variant ( idx ) )
937
934
. collect ( )
938
935
} else {
939
- def. variants . iter ( ) . map ( |v | Variant ( v . def_id ) ) . collect ( )
936
+ def. variants . indices ( ) . map ( |idx | Variant ( idx ) ) . collect ( )
940
937
}
941
938
}
942
939
ty:: Char => {
0 commit comments