]> git.lizzy.rs Git - rust.git/blob - tests/ui/exhaustive_items.rs
Ignore associated items in trait *implementations* when considering type complexity
[rust.git] / tests / ui / exhaustive_items.rs
1 // run-rustfix
2
3 #![deny(clippy::exhaustive_enums, clippy::exhaustive_structs)]
4 #![allow(unused)]
5
6 fn main() {
7     // nop
8 }
9
10 pub mod enums {
11     pub enum Exhaustive {
12         Foo,
13         Bar,
14         Baz,
15         Quux(String),
16     }
17
18     /// Some docs
19     #[repr(C)]
20     pub enum ExhaustiveWithAttrs {
21         Foo,
22         Bar,
23         Baz,
24         Quux(String),
25     }
26
27     // no warning, already non_exhaustive
28     #[non_exhaustive]
29     pub enum NonExhaustive {
30         Foo,
31         Bar,
32         Baz,
33         Quux(String),
34     }
35
36     // no warning, private
37     enum ExhaustivePrivate {
38         Foo,
39         Bar,
40         Baz,
41         Quux(String),
42     }
43
44     // no warning, private
45     #[non_exhaustive]
46     enum NonExhaustivePrivate {
47         Foo,
48         Bar,
49         Baz,
50         Quux(String),
51     }
52 }
53
54 pub mod structs {
55     pub struct Exhaustive {
56         pub foo: u8,
57         pub bar: String,
58     }
59
60     // no warning, already non_exhaustive
61     #[non_exhaustive]
62     pub struct NonExhaustive {
63         pub foo: u8,
64         pub bar: String,
65     }
66
67     // no warning, private fields
68     pub struct ExhaustivePrivateFieldTuple(u8);
69
70     // no warning, private fields
71     pub struct ExhaustivePrivateField {
72         pub foo: u8,
73         bar: String,
74     }
75
76     // no warning, private
77     struct ExhaustivePrivate {
78         pub foo: u8,
79         pub bar: String,
80     }
81
82     // no warning, private
83     #[non_exhaustive]
84     struct NonExhaustivePrivate {
85         pub foo: u8,
86         pub bar: String,
87     }
88 }