@@ -1036,30 +1036,21 @@ impl ConstructorSet {
1036
1036
where
1037
1037
' tcx : ' a ,
1038
1038
{
1039
- let mut missing = Vec :: new ( ) ;
1040
1039
let mut present: SmallVec < [ _ ; 1 ] > = SmallVec :: new ( ) ;
1040
+ let mut missing = Vec :: new ( ) ;
1041
1041
// Constructors in `ctors`, except wildcards.
1042
- let mut seen = Vec :: new ( ) ;
1043
- for ctor in ctors. cloned ( ) {
1044
- match ctor {
1045
- // Wildcards in `ctors` are irrelevant to splitting
1046
- Opaque | Wildcard => { }
1047
- _ => {
1048
- seen. push ( ctor) ;
1049
- }
1050
- }
1051
- }
1042
+ let mut seen = ctors. filter ( |c| !( matches ! ( c, Opaque | Wildcard ) ) ) ;
1052
1043
let mut nonexhaustive_enum_missing_visible_variants = false ;
1053
1044
match self {
1054
1045
ConstructorSet :: Single => {
1055
- if seen. is_empty ( ) {
1046
+ if seen. next ( ) . is_none ( ) {
1056
1047
missing. push ( Single ) ;
1057
1048
} else {
1058
1049
present. push ( Single ) ;
1059
1050
}
1060
1051
}
1061
1052
ConstructorSet :: Variants { visible_variants, hidden_variants, non_exhaustive } => {
1062
- let seen_set: FxHashSet < _ > = seen. iter ( ) . map ( |c| c. as_variant ( ) . unwrap ( ) ) . collect ( ) ;
1053
+ let seen_set: FxHashSet < _ > = seen. map ( |c| c. as_variant ( ) . unwrap ( ) ) . collect ( ) ;
1063
1054
let mut skipped_a_hidden_variant = false ;
1064
1055
for variant in visible_variants {
1065
1056
let ctor = Variant ( * variant) ;
@@ -1089,15 +1080,16 @@ impl ConstructorSet {
1089
1080
}
1090
1081
}
1091
1082
ConstructorSet :: Integers { range_1, range_2, non_exhaustive } => {
1092
- let seen_ranges = seen. iter ( ) . map ( |ctor| ctor. as_int_range ( ) . unwrap ( ) ) . cloned ( ) ;
1093
- for ( seen, splitted_range) in range_1. split ( seen_ranges. clone ( ) ) {
1083
+ let seen_ranges: Vec < _ > =
1084
+ seen. map ( |ctor| ctor. as_int_range ( ) . unwrap ( ) . clone ( ) ) . collect ( ) ;
1085
+ for ( seen, splitted_range) in range_1. split ( seen_ranges. iter ( ) . cloned ( ) ) {
1094
1086
match seen {
1095
1087
Presence :: Unseen => missing. push ( IntRange ( splitted_range) ) ,
1096
1088
Presence :: Seen => present. push ( IntRange ( splitted_range) ) ,
1097
1089
}
1098
1090
}
1099
1091
if let Some ( range_2) = range_2 {
1100
- for ( seen, splitted_range) in range_2. split ( seen_ranges) {
1092
+ for ( seen, splitted_range) in range_2. split ( seen_ranges. into_iter ( ) ) {
1101
1093
match seen {
1102
1094
Presence :: Unseen => missing. push ( IntRange ( splitted_range) ) ,
1103
1095
Presence :: Seen => present. push ( IntRange ( splitted_range) ) ,
@@ -1110,7 +1102,7 @@ impl ConstructorSet {
1110
1102
}
1111
1103
}
1112
1104
& ConstructorSet :: Slice ( array_len) => {
1113
- let seen_slices = seen. iter ( ) . map ( |c| c. as_slice ( ) . unwrap ( ) ) ;
1105
+ let seen_slices = seen. map ( |c| c. as_slice ( ) . unwrap ( ) ) ;
1114
1106
let base_slice = Slice { kind : VarLen ( 0 , 0 ) , array_len } ;
1115
1107
for ( seen, splitted_slice) in base_slice. split ( seen_slices) {
1116
1108
let ctor = Slice ( splitted_slice) ;
@@ -1123,7 +1115,7 @@ impl ConstructorSet {
1123
1115
ConstructorSet :: SliceOfEmpty => {
1124
1116
// Behaves essentially like `Single`.
1125
1117
let slice = Slice ( Slice :: new ( None , FixedLen ( 0 ) ) ) ;
1126
- if seen. is_empty ( ) {
1118
+ if seen. next ( ) . is_none ( ) {
1127
1119
missing. push ( slice) ;
1128
1120
} else {
1129
1121
present. push ( slice) ;
@@ -1132,7 +1124,7 @@ impl ConstructorSet {
1132
1124
ConstructorSet :: Unlistable => {
1133
1125
// Since we can't list constructors, we take the ones in the column. This might list
1134
1126
// some constructors several times but there's not much we can do.
1135
- present. extend ( seen. iter ( ) . cloned ( ) ) ;
1127
+ present. extend ( seen. cloned ( ) ) ;
1136
1128
missing. push ( NonExhaustive ) ;
1137
1129
}
1138
1130
// If `exhaustive_patterns` is disabled and our scrutinee is an empty type, we cannot
0 commit comments