summaryrefslogtreecommitdiffstats
path: root/tests/ui/uninhabited/uninhabited-irrefutable.rs
blob: cfd60a8d903fa0c1945668caf61e3be4893eba3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#![feature(never_type)]
#![feature(exhaustive_patterns)]

mod foo {
    pub struct SecretlyEmpty {
        _priv: !,
    }

    pub struct NotSoSecretlyEmpty {
        pub _pub: !,
    }
}

struct NotSoSecretlyEmpty {
    _priv: !,
}

enum Foo {
    //~^ NOTE `Foo` defined here
    A(foo::SecretlyEmpty),
    //~^ NOTE not covered
    B(foo::NotSoSecretlyEmpty),
    C(NotSoSecretlyEmpty),
    D(u32, u32),
}

fn main() {
    let x: Foo = Foo::D(123, 456);
    let Foo::D(_y, _z) = x;
    //~^ ERROR refutable pattern in local binding
    //~| `Foo::A(_)` not covered
    //~| NOTE `let` bindings require an "irrefutable pattern"
    //~| NOTE for more information
    //~| NOTE pattern `Foo::A(_)` is currently uninhabited
    //~| NOTE the matched value is of type `Foo`
    //~| HELP you might want to use `let else`
}