rust-clippy/tests/ui/exhaustive_items.fixed

83 lines
1.3 KiB
Rust
Raw Normal View History

2021-01-21 20:48:30 +00:00
// run-rustfix
2021-01-21 21:41:57 +00:00
#![deny(clippy::exhaustive_enums, clippy::exhaustive_structs)]
2021-01-21 20:48:30 +00:00
#![allow(unused)]
fn main() {
// nop
}
2021-01-21 21:41:57 +00:00
pub mod enums {
#[non_exhaustive]
2021-01-21 22:00:25 +00:00
pub enum Exhaustive {
2021-01-21 21:41:57 +00:00
Foo,
Bar,
Baz,
Quux(String),
}
2021-01-21 20:48:30 +00:00
2021-01-25 22:39:03 +00:00
/// Some docs
#[repr(C)]
#[non_exhaustive]
pub enum ExhaustiveWithAttrs {
Foo,
Bar,
Baz,
Quux(String),
}
2021-01-21 21:41:57 +00:00
// 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),
}
2021-01-21 21:41:57 +00:00
// no warning, private
#[non_exhaustive]
enum NonExhaustivePrivate {
Foo,
Bar,
Baz,
Quux(String),
}
}
2021-01-21 21:41:57 +00:00
pub mod structs {
#[non_exhaustive]
2021-01-21 22:00:25 +00:00
pub struct Exhaustive {
2021-01-21 21:41:57 +00:00
foo: u8,
bar: String,
}
// no warning, already non_exhaustive
#[non_exhaustive]
pub struct NonExhaustive {
foo: u8,
bar: String,
}
// no warning, private
struct ExhaustivePrivate {
foo: u8,
bar: String,
}
// no warning, private
#[non_exhaustive]
struct NonExhaustivePrivate {
foo: u8,
bar: String,
}
2021-01-21 20:48:30 +00:00
}