Skip to content

Commit

Permalink
panic when trying to destructure union as enum
Browse files Browse the repository at this point in the history
  • Loading branch information
syvb committed Jul 9, 2021
1 parent df3e003 commit b86ed4a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_mir_build/src/check_unsafety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,14 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, '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"),
}
}
Expand Down

0 comments on commit b86ed4a

Please sign in to comment.