]> git.lizzy.rs Git - rust.git/blob - tests/ui/lint/dead-code/const-and-self.rs
Rollup merge of #106427 - mejrs:translation_errors, r=davidtwco
[rust.git] / tests / ui / lint / dead-code / const-and-self.rs
1 // check-pass
2
3 #![warn(dead_code)]
4
5 const TLC: usize = 4;
6
7 trait Tr { fn doit(&self); }
8
9 impl Tr for [usize; TLC] {
10     fn doit(&self) {
11         println!("called 4");
12     }
13 }
14
15 struct X;
16 struct Y;
17 struct Z;
18
19 trait Foo<T> {
20     type Ty;
21     fn foo() -> Self::Ty;
22 }
23
24 impl Foo<Y> for X {
25     type Ty = Z;
26     fn foo() -> Self::Ty {
27         unimplemented!()
28     }
29 }
30
31 enum E {
32     A,
33     B, //~ WARN variants `B` and `C` are never constructed
34     C,
35 }
36
37 type F = E;
38
39 impl E {
40     fn check(&self) -> bool {
41         match self {
42             Self::A => true,
43             Self::B => false,
44             F::C => false,
45         }
46     }
47 }
48
49 fn main() {
50     let s = [0,1,2,3];
51     s.doit();
52     X::foo();
53     E::A.check();
54 }