Reuse a helper method instead of manually rolling it
This commit is contained in:
parent
7a8a048b58
commit
0c6918fe21
@ -724,9 +724,7 @@ fn candidate_after_variant_switch<'pat>(
|
|||||||
// So, if we have a match-pattern like `x @ Enum::Variant(P1, P2)`,
|
// So, if we have a match-pattern like `x @ Enum::Variant(P1, P2)`,
|
||||||
// we want to create a set of derived match-patterns like
|
// we want to create a set of derived match-patterns like
|
||||||
// `(x as Variant).0 @ P1` and `(x as Variant).1 @ P1`.
|
// `(x as Variant).0 @ P1` and `(x as Variant).1 @ P1`.
|
||||||
let elem =
|
let downcast_place = match_pair.place.downcast(adt_def, variant_index); // `(x as Variant)`
|
||||||
ProjectionElem::Downcast(Some(adt_def.variant(variant_index).name), variant_index);
|
|
||||||
let downcast_place = match_pair.place.project(elem); // `(x as Variant)`
|
|
||||||
let consequent_match_pairs = subpatterns.iter().map(|subpattern| {
|
let consequent_match_pairs = subpatterns.iter().map(|subpattern| {
|
||||||
// e.g., `(x as Variant).0`
|
// e.g., `(x as Variant).0`
|
||||||
let place = downcast_place.clone().field(subpattern.field, subpattern.pattern.ty);
|
let place = downcast_place.clone().field(subpattern.field, subpattern.pattern.ty);
|
||||||
|
Loading…
Reference in New Issue
Block a user