2020-04-30 23:44:17 +00:00
|
|
|
#![warn(clippy::manual_non_exhaustive)]
|
|
|
|
#![allow(unused)]
|
2023-07-27 11:40:22 +00:00
|
|
|
//@no-rustfix
|
2020-04-30 23:44:17 +00:00
|
|
|
mod structs {
|
|
|
|
struct S {
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: this seems like a manual implementation of the non-exhaustive pattern
|
2020-04-30 23:44:17 +00:00
|
|
|
pub a: i32,
|
|
|
|
pub b: i32,
|
|
|
|
_c: (),
|
|
|
|
}
|
|
|
|
|
2020-05-01 20:37:14 +00:00
|
|
|
// user forgot to remove the private field
|
|
|
|
#[non_exhaustive]
|
|
|
|
struct Sp {
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: this seems like a manual implementation of the non-exhaustive pattern
|
2020-05-01 20:37:14 +00:00
|
|
|
pub a: i32,
|
|
|
|
pub b: i32,
|
|
|
|
_c: (),
|
|
|
|
}
|
|
|
|
|
2020-04-30 23:44:17 +00:00
|
|
|
// some other fields are private, should be ignored
|
|
|
|
struct PrivateFields {
|
|
|
|
a: i32,
|
|
|
|
pub b: i32,
|
|
|
|
_c: (),
|
|
|
|
}
|
|
|
|
|
|
|
|
// private field name does not start with underscore, should be ignored
|
|
|
|
struct NoUnderscore {
|
|
|
|
pub a: i32,
|
|
|
|
pub b: i32,
|
|
|
|
c: (),
|
|
|
|
}
|
|
|
|
|
|
|
|
// private field is not unit type, should be ignored
|
|
|
|
struct NotUnit {
|
|
|
|
pub a: i32,
|
|
|
|
pub b: i32,
|
|
|
|
_c: i32,
|
|
|
|
}
|
|
|
|
|
|
|
|
// private field is the only field, should be ignored
|
|
|
|
struct OnlyMarker {
|
|
|
|
_a: (),
|
|
|
|
}
|
|
|
|
|
2020-05-01 20:37:14 +00:00
|
|
|
// already non exhaustive and no private fields, should be ignored
|
2020-04-30 23:44:17 +00:00
|
|
|
#[non_exhaustive]
|
|
|
|
struct NonExhaustive {
|
|
|
|
pub a: i32,
|
|
|
|
pub b: i32,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mod tuple_structs {
|
|
|
|
struct T(pub i32, pub i32, ());
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: this seems like a manual implementation of the non-exhaustive pattern
|
2020-04-30 23:44:17 +00:00
|
|
|
|
2020-05-01 20:37:14 +00:00
|
|
|
// user forgot to remove the private field
|
|
|
|
#[non_exhaustive]
|
|
|
|
struct Tp(pub i32, pub i32, ());
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: this seems like a manual implementation of the non-exhaustive pattern
|
2020-05-01 20:37:14 +00:00
|
|
|
|
2020-04-30 23:44:17 +00:00
|
|
|
// some other fields are private, should be ignored
|
|
|
|
struct PrivateFields(pub i32, i32, ());
|
|
|
|
|
|
|
|
// private field is not unit type, should be ignored
|
|
|
|
struct NotUnit(pub i32, pub i32, i32);
|
|
|
|
|
|
|
|
// private field is the only field, should be ignored
|
|
|
|
struct OnlyMarker(());
|
|
|
|
|
2020-05-01 20:37:14 +00:00
|
|
|
// already non exhaustive and no private fields, should be ignored
|
2020-04-30 23:44:17 +00:00
|
|
|
#[non_exhaustive]
|
|
|
|
struct NonExhaustive(pub i32, pub i32);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|