fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1#![deny(clippy::exhaustive_enums, clippy::exhaustive_structs)] 2#![allow(unused)] 3 4fn main() { 5 // nop 6} 7 8pub mod enums { 9 #[non_exhaustive] 10 pub enum Exhaustive { 11 Foo, 12 Bar, 13 Baz, 14 Quux(String), 15 } 16 17 /// Some docs 18 #[repr(C)] 19 #[non_exhaustive] 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 54pub mod structs { 55 #[non_exhaustive] 56 pub struct Exhaustive { 57 pub foo: u8, 58 pub bar: String, 59 } 60 61 // no warning, already non_exhaustive 62 #[non_exhaustive] 63 pub struct NonExhaustive { 64 pub foo: u8, 65 pub bar: String, 66 } 67 68 // no warning, private fields 69 pub struct ExhaustivePrivateFieldTuple(u8); 70 71 // no warning, private fields 72 pub struct ExhaustivePrivateField { 73 pub foo: u8, 74 bar: String, 75 } 76 77 // no warning, private 78 struct ExhaustivePrivate { 79 pub foo: u8, 80 pub bar: String, 81 } 82 83 // no warning, private 84 #[non_exhaustive] 85 struct NonExhaustivePrivate { 86 pub foo: u8, 87 pub bar: String, 88 } 89}