panic when trying to destructure union as enum

This commit is contained in:
Smitty
2021-07-09 15:22:12 -04:00
parent df3e003378
commit b86ed4a425
@@ -201,14 +201,14 @@ fn visit_pat(&mut self, pat: &Pat<'tcx>) {
AscribeUserType { .. } |
// creating a union literal
Constant { .. } => {},
Variant { .. } | Leaf { .. } | Or { .. } => {
Leaf { .. } | Or { .. } => {
// pattern matching with a union and not doing something like v = Union { bar: 5 }
self.in_union_destructure = true;
visit::walk_pat(self, pat);
self.in_union_destructure = false;
return; // don't walk pattern
}
Deref { .. } | Range { .. } | Slice { .. } | Array { .. } =>
Variant { .. } | Deref { .. } | Range { .. } | Slice { .. } | Array { .. } =>
unreachable!("impossible union destructuring type"),
}
}