]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/exhaustive_items.fixed
Auto merge of #101969 - reez12g:issue-101306, r=reez12g
[rust.git] / src / tools / clippy / tests / ui / exhaustive_items.fixed
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     #[non_exhaustive]
12     pub enum Exhaustive {
13         Foo,
14         Bar,
15         Baz,
16         Quux(String),
17     }
18
19     /// Some docs
20     #[repr(C)]
21     #[non_exhaustive]
22     pub enum ExhaustiveWithAttrs {
23         Foo,
24         Bar,
25         Baz,
26         Quux(String),
27     }
28
29     // no warning, already non_exhaustive
30     #[non_exhaustive]
31     pub enum NonExhaustive {
32         Foo,
33         Bar,
34         Baz,
35         Quux(String),
36     }
37
38     // no warning, private
39     enum ExhaustivePrivate {
40         Foo,
41         Bar,
42         Baz,
43         Quux(String),
44     }
45
46     // no warning, private
47     #[non_exhaustive]
48     enum NonExhaustivePrivate {
49         Foo,
50         Bar,
51         Baz,
52         Quux(String),
53     }
54 }
55
56 pub mod structs {
57     #[non_exhaustive]
58     pub struct Exhaustive {
59         pub foo: u8,
60         pub bar: String,
61     }
62
63     // no warning, already non_exhaustive
64     #[non_exhaustive]
65     pub struct NonExhaustive {
66         pub foo: u8,
67         pub bar: String,
68     }
69
70     // no warning, private fields
71     pub struct ExhaustivePrivateFieldTuple(u8);
72
73     // no warning, private fields
74     pub struct ExhaustivePrivateField {
75         pub foo: u8,
76         bar: String,
77     }
78
79     // no warning, private
80     struct ExhaustivePrivate {
81         pub foo: u8,
82         pub bar: String,
83     }
84
85     // no warning, private
86     #[non_exhaustive]
87     struct NonExhaustivePrivate {
88         pub foo: u8,
89         pub bar: String,
90     }
91 }