2021-01-30 17:06:34 +00:00
|
|
|
// 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 {
|
2021-02-03 04:43:30 +00:00
|
|
|
pub foo: u8,
|
|
|
|
pub bar: String,
|
2021-01-30 17:06:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// no warning, already non_exhaustive
|
|
|
|
#[non_exhaustive]
|
|
|
|
pub struct NonExhaustive {
|
2021-02-03 04:43:30 +00: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-30 17:06:34 +00:00
|
|
|
bar: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
// no warning, private
|
|
|
|
struct ExhaustivePrivate {
|
2021-02-03 04:43:30 +00:00
|
|
|
pub foo: u8,
|
|
|
|
pub bar: String,
|
2021-01-30 17:06:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// no warning, private
|
|
|
|
#[non_exhaustive]
|
|
|
|
struct NonExhaustivePrivate {
|
2021-02-03 04:43:30 +00:00
|
|
|
pub foo: u8,
|
|
|
|
pub bar: String,
|
2021-01-30 17:06:34 +00:00
|
|
|
}
|
|
|
|
}
|