2022-06-25 07:16:33 -05:00
|
|
|
#![feature(lint_reasons)]
|
2022-04-06 08:26:59 -05:00
|
|
|
#![warn(clippy::manual_non_exhaustive)]
|
|
|
|
#![allow(unused)]
|
2023-07-27 06:40:22 -05:00
|
|
|
//@no-rustfix
|
2022-04-06 08:26:59 -05:00
|
|
|
enum E {
|
2023-07-28 14:35:48 -05:00
|
|
|
//~^ ERROR: this seems like a manual implementation of the non-exhaustive pattern
|
2022-04-06 08:26:59 -05:00
|
|
|
A,
|
|
|
|
B,
|
|
|
|
#[doc(hidden)]
|
|
|
|
_C,
|
|
|
|
}
|
|
|
|
|
2023-09-30 22:57:54 -05:00
|
|
|
// if the user explicitly marks as nonexhaustive we shouldn't warn them
|
2022-04-06 08:26:59 -05:00
|
|
|
#[non_exhaustive]
|
|
|
|
enum Ep {
|
|
|
|
A,
|
|
|
|
B,
|
|
|
|
#[doc(hidden)]
|
|
|
|
_C,
|
|
|
|
}
|
|
|
|
|
|
|
|
// marker variant does not have doc hidden attribute, should be ignored
|
|
|
|
enum NoDocHidden {
|
|
|
|
A,
|
|
|
|
B,
|
|
|
|
_C,
|
|
|
|
}
|
|
|
|
|
|
|
|
// name of variant with doc hidden does not start with underscore, should be ignored
|
|
|
|
enum NoUnderscore {
|
|
|
|
A,
|
|
|
|
B,
|
|
|
|
#[doc(hidden)]
|
|
|
|
C,
|
|
|
|
}
|
|
|
|
|
|
|
|
// variant with doc hidden is not unit, should be ignored
|
|
|
|
enum NotUnit {
|
|
|
|
A,
|
|
|
|
B,
|
|
|
|
#[doc(hidden)]
|
|
|
|
_C(bool),
|
|
|
|
}
|
|
|
|
|
|
|
|
// variant with doc hidden is the only one, should be ignored
|
|
|
|
enum OnlyMarker {
|
|
|
|
#[doc(hidden)]
|
|
|
|
_A,
|
|
|
|
}
|
|
|
|
|
|
|
|
// variant with multiple markers, should be ignored
|
|
|
|
enum MultipleMarkers {
|
|
|
|
A,
|
|
|
|
#[doc(hidden)]
|
|
|
|
_B,
|
|
|
|
#[doc(hidden)]
|
|
|
|
_C,
|
|
|
|
}
|
|
|
|
|
|
|
|
// already non_exhaustive and no markers, should be ignored
|
|
|
|
#[non_exhaustive]
|
|
|
|
enum NonExhaustive {
|
|
|
|
A,
|
|
|
|
B,
|
|
|
|
}
|
|
|
|
|
|
|
|
// marked is used, don't lint
|
|
|
|
enum UsedHidden {
|
|
|
|
#[doc(hidden)]
|
|
|
|
_A,
|
|
|
|
B,
|
|
|
|
C,
|
|
|
|
}
|
|
|
|
fn foo(x: &mut UsedHidden) {
|
|
|
|
if matches!(*x, UsedHidden::B) {
|
|
|
|
*x = UsedHidden::_A;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-25 07:16:33 -05:00
|
|
|
#[expect(clippy::manual_non_exhaustive)]
|
|
|
|
enum ExpectLint {
|
|
|
|
A,
|
|
|
|
B,
|
|
|
|
#[doc(hidden)]
|
|
|
|
_C,
|
|
|
|
}
|
|
|
|
|
2022-04-06 08:26:59 -05:00
|
|
|
fn main() {}
|