about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-06-27 14:46:36 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-07-15 15:56:16 +0000
commit0c6918fe210ebed9639c2f1b1fbfac4eb0fef38a (patch)
tree74b2c4920e77d1ce62042893290fb97c101ab44c
parent7a8a048b5853c6e44af53d924a7c0feb2140e5af (diff)
downloadrust-0c6918fe210ebed9639c2f1b1fbfac4eb0fef38a.tar.gz
rust-0c6918fe210ebed9639c2f1b1fbfac4eb0fef38a.zip
Reuse a helper method instead of manually rolling it
-rw-r--r--compiler/rustc_mir_build/src/build/matches/test.rs4
1 files changed, 1 insertions, 3 deletions
diff --git a/compiler/rustc_mir_build/src/build/matches/test.rs b/compiler/rustc_mir_build/src/build/matches/test.rs
index 4e2a137c3fc..63acd731db7 100644
--- a/compiler/rustc_mir_build/src/build/matches/test.rs
+++ b/compiler/rustc_mir_build/src/build/matches/test.rs
@@ -724,9 +724,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
         // So, if we have a match-pattern like `x @ Enum::Variant(P1, P2)`,
         // we want to create a set of derived match-patterns like
         // `(x as Variant).0 @ P1` and `(x as Variant).1 @ P1`.
-        let elem =
-            ProjectionElem::Downcast(Some(adt_def.variant(variant_index).name), variant_index);
-        let downcast_place = match_pair.place.project(elem); // `(x as Variant)`
+        let downcast_place = match_pair.place.downcast(adt_def, variant_index); // `(x as Variant)`
         let consequent_match_pairs = subpatterns.iter().map(|subpattern| {
             // e.g., `(x as Variant).0`
             let place = downcast_place.clone().field(subpattern.field, subpattern.pattern.ty);