Skip to content

Commit b86ed4a

Browse files
committed
panic when trying to destructure union as enum
1 parent df3e003 commit b86ed4a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler/rustc_mir_build/src/check_unsafety.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,14 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
201201
AscribeUserType { .. } |
202202
// creating a union literal
203203
Constant { .. } => {},
204-
Variant { .. } | Leaf { .. } | Or { .. } => {
204+
Leaf { .. } | Or { .. } => {
205205
// pattern matching with a union and not doing something like v = Union { bar: 5 }
206206
self.in_union_destructure = true;
207207
visit::walk_pat(self, pat);
208208
self.in_union_destructure = false;
209209
return; // don't walk pattern
210210
}
211-
Deref { .. } | Range { .. } | Slice { .. } | Array { .. } =>
211+
Variant { .. } | Deref { .. } | Range { .. } | Slice { .. } | Array { .. } =>
212212
unreachable!("impossible union destructuring type"),
213213
}
214214
}

0 commit comments

Comments
 (0)