Skip to content

Commit

Permalink
Test match underscore on void from union.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Oct 24, 2023
1 parent 2e6e707 commit 479374f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/pass/union-uninhabited-match-underscore.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
fn main() {
#[derive(Copy, Clone)]
enum Void {}
union Uninit<T: Copy> {
value: T,
uninit: (),
}
unsafe {
let x: Uninit<Void> = Uninit { uninit: () };
match x.value {
// rustc warns about un unreachable pattern,
// but is wrong in unsafe code.
#[allow(unreachable_patterns)]
_ => println!("hi from the void!"),
}
}
}
1 change: 1 addition & 0 deletions tests/pass/union-uninhabited-match-underscore.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hi from the void!

0 comments on commit 479374f

Please sign in to comment.