]> git.lizzy.rs Git - rust.git/blob - tests/ui/exhaustive_items.rs
Auto merge of #6617 - Manishearth:exhaustive_enums, r=camsteffen
[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         foo: u8,
57         bar: String,
58     }
59
60     // no warning, already non_exhaustive
61     #[non_exhaustive]
62     pub struct NonExhaustive {
63         foo: u8,
64         bar: String,
65     }
66
67     // no warning, private
68     struct ExhaustivePrivate {
69         foo: u8,
70         bar: String,
71     }
72
73     // no warning, private
74     #[non_exhaustive]
75     struct NonExhaustivePrivate {
76         foo: u8,
77         bar: String,
78     }
79 }