diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /src/tools/clippy/tests/ui/exhaustive_items.fixed | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/clippy/tests/ui/exhaustive_items.fixed')
-rw-r--r-- | src/tools/clippy/tests/ui/exhaustive_items.fixed | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/exhaustive_items.fixed b/src/tools/clippy/tests/ui/exhaustive_items.fixed new file mode 100644 index 000000000..c209f5b4b --- /dev/null +++ b/src/tools/clippy/tests/ui/exhaustive_items.fixed @@ -0,0 +1,91 @@ +// run-rustfix + +#![deny(clippy::exhaustive_enums, clippy::exhaustive_structs)] +#![allow(unused)] + +fn main() { + // nop +} + +pub mod enums { + #[non_exhaustive] + pub enum Exhaustive { + Foo, + Bar, + Baz, + Quux(String), + } + + /// Some docs + #[repr(C)] + #[non_exhaustive] + pub enum ExhaustiveWithAttrs { + Foo, + Bar, + Baz, + Quux(String), + } + + // no warning, already non_exhaustive + #[non_exhaustive] + pub enum NonExhaustive { + Foo, + Bar, + Baz, + Quux(String), + } + + // no warning, private + enum ExhaustivePrivate { + Foo, + Bar, + Baz, + Quux(String), + } + + // no warning, private + #[non_exhaustive] + enum NonExhaustivePrivate { + Foo, + Bar, + Baz, + Quux(String), + } +} + +pub mod structs { + #[non_exhaustive] + pub struct Exhaustive { + pub foo: u8, + pub bar: String, + } + + // no warning, already non_exhaustive + #[non_exhaustive] + pub struct NonExhaustive { + pub foo: u8, + pub bar: String, + } + + // no warning, private fields + pub struct ExhaustivePrivateFieldTuple(u8); + + // no warning, private fields + pub struct ExhaustivePrivateField { + pub foo: u8, + bar: String, + } + + // no warning, private + struct ExhaustivePrivate { + pub foo: u8, + pub bar: String, + } + + // no warning, private + #[non_exhaustive] + struct NonExhaustivePrivate { + pub foo: u8, + pub bar: String, + } +} |