]> git.proxmox.com Git - rustc.git/blob - src/test/ui/pattern/usefulness/always-inhabited-union-ref.rs
New upstream version 1.44.1+dfsg1
[rustc.git] / src / test / ui / pattern / usefulness / always-inhabited-union-ref.rs
1 // The precise semantics of inhabitedness with respect to unions and references is currently
2 // undecided. This test file currently checks a conservative choice.
3
4 #![feature(exhaustive_patterns)]
5 #![feature(never_type)]
6
7 #![allow(dead_code)]
8 #![allow(unreachable_code)]
9
10 pub union Foo {
11 foo: !,
12 }
13
14 fn uninhab_ref() -> &'static ! {
15 unimplemented!()
16 }
17
18 fn uninhab_union() -> Foo {
19 unimplemented!()
20 }
21
22 fn match_on_uninhab() {
23 match uninhab_ref() {
24 //~^ ERROR non-exhaustive patterns: type `&!` is non-empty
25 }
26
27 match uninhab_union() {
28 //~^ ERROR non-exhaustive patterns: type `Foo` is non-empty
29 }
30 }
31
32 fn main() {}