Skip to content

Commit 3bf94b2

Browse files
committed
Naming
1 parent b7cfb6a commit 3bf94b2

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/librustc_mir_build/hair/pattern/_match.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -1025,11 +1025,11 @@ enum Fields<'p, 'tcx> {
10251025
/// have not measured if it really made a difference.
10261026
Slice(&'p [Pat<'tcx>]),
10271027
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.
10301030
Filtered {
10311031
fields: SmallVec<[FilteredField<'p, 'tcx>; 2]>,
1032-
len: usize,
1032+
kept_count: usize,
10331033
},
10341034
}
10351035

@@ -1092,7 +1092,7 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
10921092
if has_no_hidden_fields {
10931093
Fields::wildcards_from_tys(cx, field_tys)
10941094
} else {
1095-
let mut len = 0;
1095+
let mut kept_count = 0;
10961096
let fields = variant
10971097
.fields
10981098
.iter()
@@ -1109,12 +1109,12 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
11091109
if is_uninhabited && (!is_visible || is_non_exhaustive) {
11101110
FilteredField::Hidden(ty)
11111111
} else {
1112-
len += 1;
1112+
kept_count += 1;
11131113
FilteredField::Kept(wildcard_from_ty(ty))
11141114
}
11151115
})
11161116
.collect();
1117-
Fields::Filtered { fields, len }
1117+
Fields::Filtered { fields, kept_count }
11181118
}
11191119
}
11201120
}
@@ -1133,11 +1133,14 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
11331133
ret
11341134
}
11351135

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`.
11361139
fn len(&self) -> usize {
11371140
match self {
11381141
Fields::Slice(pats) => pats.len(),
11391142
Fields::Vec(pats) => pats.len(),
1140-
Fields::Filtered { len, .. } => *len,
1143+
Fields::Filtered { kept_count, .. } => *kept_count,
11411144
}
11421145
}
11431146

@@ -1207,7 +1210,7 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
12071210
let pats: &[_] = cx.pattern_arena.alloc_from_iter(pats);
12081211

12091212
match self {
1210-
Fields::Filtered { fields, len } => {
1213+
Fields::Filtered { fields, kept_count } => {
12111214
let mut pats = pats.iter();
12121215
let mut fields = fields.clone();
12131216
for f in &mut fields {
@@ -1216,7 +1219,7 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
12161219
*p = pats.next().unwrap();
12171220
}
12181221
}
1219-
Fields::Filtered { fields, len: *len }
1222+
Fields::Filtered { fields, kept_count: *kept_count }
12201223
}
12211224
_ => Fields::Slice(pats),
12221225
}

0 commit comments

Comments
 (0)