@@ -1025,11 +1025,11 @@ enum Fields<'p, 'tcx> {
1025
1025
/// have not measured if it really made a difference.
1026
1026
Slice ( & ' p [ Pat < ' tcx > ] ) ,
1027
1027
Vec ( SmallVec < [ & ' p Pat < ' tcx > ; 2 ] > ) ,
1028
- /// Patterns where some of the fields need to be hidden. `len ` caches the number of non-hidden
1029
- /// fields.
1028
+ /// Patterns where some of the fields need to be hidden. `kept_count ` caches the number of
1029
+ /// non-hidden fields.
1030
1030
Filtered {
1031
1031
fields : SmallVec < [ FilteredField < ' p , ' tcx > ; 2 ] > ,
1032
- len : usize ,
1032
+ kept_count : usize ,
1033
1033
} ,
1034
1034
}
1035
1035
@@ -1092,7 +1092,7 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
1092
1092
if has_no_hidden_fields {
1093
1093
Fields :: wildcards_from_tys ( cx, field_tys)
1094
1094
} else {
1095
- let mut len = 0 ;
1095
+ let mut kept_count = 0 ;
1096
1096
let fields = variant
1097
1097
. fields
1098
1098
. iter ( )
@@ -1109,12 +1109,12 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
1109
1109
if is_uninhabited && ( !is_visible || is_non_exhaustive) {
1110
1110
FilteredField :: Hidden ( ty)
1111
1111
} else {
1112
- len += 1 ;
1112
+ kept_count += 1 ;
1113
1113
FilteredField :: Kept ( wildcard_from_ty ( ty) )
1114
1114
}
1115
1115
} )
1116
1116
. collect ( ) ;
1117
- Fields :: Filtered { fields, len }
1117
+ Fields :: Filtered { fields, kept_count }
1118
1118
}
1119
1119
}
1120
1120
}
@@ -1133,11 +1133,14 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
1133
1133
ret
1134
1134
}
1135
1135
1136
+ /// Returns the number of patterns from the viewpoint of match-checking, i.e. excluding hidden
1137
+ /// fields. This is what we want in most cases in this file, the only exception being
1138
+ /// conversion to/from `Pat`.
1136
1139
fn len ( & self ) -> usize {
1137
1140
match self {
1138
1141
Fields :: Slice ( pats) => pats. len ( ) ,
1139
1142
Fields :: Vec ( pats) => pats. len ( ) ,
1140
- Fields :: Filtered { len , .. } => * len ,
1143
+ Fields :: Filtered { kept_count , .. } => * kept_count ,
1141
1144
}
1142
1145
}
1143
1146
@@ -1207,7 +1210,7 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
1207
1210
let pats: & [ _ ] = cx. pattern_arena . alloc_from_iter ( pats) ;
1208
1211
1209
1212
match self {
1210
- Fields :: Filtered { fields, len } => {
1213
+ Fields :: Filtered { fields, kept_count } => {
1211
1214
let mut pats = pats. iter ( ) ;
1212
1215
let mut fields = fields. clone ( ) ;
1213
1216
for f in & mut fields {
@@ -1216,7 +1219,7 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
1216
1219
* p = pats. next ( ) . unwrap ( ) ;
1217
1220
}
1218
1221
}
1219
- Fields :: Filtered { fields, len : * len }
1222
+ Fields :: Filtered { fields, kept_count : * kept_count }
1220
1223
}
1221
1224
_ => Fields :: Slice ( pats) ,
1222
1225
}
0 commit comments