Skip to content

Commit 80bb813

Browse files
committed
Inline field_match_pairs into its callers
1 parent d1d3ef4 commit 80bb813

1 file changed

Lines changed: 8 additions & 20 deletions

File tree

compiler/rustc_mir_build/src/builder/matches/match_pair.rs

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,6 @@ use crate::builder::matches::{
1313
};
1414

1515
impl<'a, 'tcx> Builder<'a, 'tcx> {
16-
/// Builds and pushes [`MatchPairTree`] subtrees, one for each pattern in
17-
/// `subpatterns`, representing the fields of a [`PatKind::Variant`] or
18-
/// [`PatKind::Leaf`].
19-
///
20-
/// Used internally by [`MatchPairTree::for_pattern`].
21-
fn field_match_pairs(
22-
&mut self,
23-
match_pairs: &mut Vec<MatchPairTree<'tcx>>,
24-
extra_data: &mut PatternExtraData<'tcx>,
25-
place: PlaceBuilder<'tcx>,
26-
subpatterns: &[FieldPat<'tcx>],
27-
) {
28-
for fieldpat in subpatterns {
29-
let place = place.clone_project(PlaceElem::Field(fieldpat.field, fieldpat.pattern.ty));
30-
MatchPairTree::for_pattern(place, &fieldpat.pattern, self, match_pairs, extra_data);
31-
}
32-
}
33-
3416
/// Builds [`MatchPairTree`] subtrees for the prefix/middle/suffix parts of an
3517
/// array pattern or slice pattern, and adds those trees to `match_pairs`.
3618
///
@@ -294,7 +276,10 @@ impl<'tcx> MatchPairTree<'tcx> {
294276

295277
PatKind::Variant { adt_def, variant_index, args: _, ref subpatterns } => {
296278
let downcast_place = place_builder.downcast(adt_def, variant_index); // `(x as Variant)`
297-
cx.field_match_pairs(&mut subpairs, extra_data, downcast_place, subpatterns);
279+
for &FieldPat { field, pattern: ref subpat } in subpatterns {
280+
let subplace = downcast_place.clone_project(PlaceElem::Field(field, subpat.ty));
281+
MatchPairTree::for_pattern(subplace, subpat, cx, &mut subpairs, extra_data);
282+
}
298283

299284
// We treat non-exhaustive enums the same independent of the crate they are
300285
// defined in, to avoid differences in the operational semantics between crates.
@@ -308,7 +293,10 @@ impl<'tcx> MatchPairTree<'tcx> {
308293
}
309294

310295
PatKind::Leaf { ref subpatterns } => {
311-
cx.field_match_pairs(&mut subpairs, extra_data, place_builder, subpatterns);
296+
for &FieldPat { field, pattern: ref subpat } in subpatterns {
297+
let subplace = place_builder.clone_project(PlaceElem::Field(field, subpat.ty));
298+
MatchPairTree::for_pattern(subplace, subpat, cx, &mut subpairs, extra_data);
299+
}
312300
None
313301
}
314302

0 commit comments

Comments
 (0)