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