Skip to content

Commit 0c6918f

Browse files
committed
Reuse a helper method instead of manually rolling it
1 parent 7a8a048 commit 0c6918f

File tree

1 file changed

+1
-3
lines changed
  • compiler/rustc_mir_build/src/build/matches

1 file changed

+1
-3
lines changed

compiler/rustc_mir_build/src/build/matches/test.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -724,9 +724,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
724724
// So, if we have a match-pattern like `x @ Enum::Variant(P1, P2)`,
725725
// we want to create a set of derived match-patterns like
726726
// `(x as Variant).0 @ P1` and `(x as Variant).1 @ P1`.
727-
let elem =
728-
ProjectionElem::Downcast(Some(adt_def.variant(variant_index).name), variant_index);
729-
let downcast_place = match_pair.place.project(elem); // `(x as Variant)`
727+
let downcast_place = match_pair.place.downcast(adt_def, variant_index); // `(x as Variant)`
730728
let consequent_match_pairs = subpatterns.iter().map(|subpattern| {
731729
// e.g., `(x as Variant).0`
732730
let place = downcast_place.clone().field(subpattern.field, subpattern.pattern.ty);

0 commit comments

Comments
 (0)