Skip to content

Commit 479fb4b

Browse files
committed
Test match underscore on void from union.
1 parent 3ec03f5 commit 479fb4b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
fn main() {
2+
#[derive(Copy, Clone)]
3+
enum Void {}
4+
union Uninit<T: Copy> {
5+
value: T,
6+
uninit: (),
7+
}
8+
unsafe {
9+
let x: Uninit<Void> = Uninit { uninit: () };
10+
match x.value {
11+
// rustc warns about un unreachable pattern,
12+
// but is wrong in unsafe code.
13+
#[allow(unreachable_patterns)]
14+
_ => println!("hi from the void!"),
15+
}
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hi from the void!

0 commit comments

Comments
 (0)