about summary refs log tree commit diff
path: root/tests/ui/lint/dead-code/lint-unused-adt-appeared-in-pattern.rs
blob: 25777438456b64ae3f7bf3f74c5a521f21f262f6 (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
#![deny(dead_code)]

struct Foo(u8); //~ ERROR struct `Foo` is never constructed

enum Bar { //~ ERROR enum `Bar` is never used
    Var1(u8),
    Var2(u8),
}

pub trait Tr1 {
    fn f1() -> Self;
}

impl Tr1 for Foo {
    fn f1() -> Foo {
        let f = Foo(0);
        let Foo(tag) = f;
        Foo(tag)
    }
}

impl Tr1 for Bar {
    fn f1() -> Bar {
        let b = Bar::Var1(0);
        let b = if let Bar::Var1(_) = b {
            Bar::Var1(0)
        } else {
            Bar::Var2(0)
        };
        match b {
            Bar::Var1(_) => Bar::Var2(0),
            Bar::Var2(_) => Bar::Var1(0),
        }
    }
}

fn main() {}