2 // aux-build:non-exhaustive-enum.rs
4 #![deny(clippy::wildcard_enum_match_arm)]
10 clippy::wildcard_in_or_patterns,
11 clippy::unnested_or_patterns,
12 clippy::diverging_sub_expression
15 extern crate non_exhaustive_enum;
17 use non_exhaustive_enum::ErrorKind;
19 #[derive(Clone, Copy, Debug, Eq, PartialEq)]
29 fn is_monochrome(self) -> bool {
31 Color::Red | Color::Green | Color::Blue => true,
32 Color::Rgb(r, g, b) => r | g == 0 || r | b == 0 || g | b == 0,
39 let color = Color::Rgb(0, 0, 127);
41 Color::Red => println!("Red"),
42 _ => eprintln!("Not red"),
45 Color::Red => println!("Red"),
46 _not_red => eprintln!("Not red"),
48 let _str = match color {
49 Color::Red => "Red".to_owned(),
50 not_red => format!("{:?}", not_red),
57 c if c.is_monochrome() => {},
58 Color::Rgb(_, _, _) => {},
60 let _str = match color {
62 c @ Color::Green | c @ Color::Blue | c @ Color::Rgb(_, _, _) | c @ Color::Cyan => "Not red",
65 Color::Rgb(r, _, _) if r > 0 => "Some red",
69 Color::Red | Color::Green | Color::Blue | Color::Cyan => {},
72 let x: u8 = unimplemented!();
78 // We need to use an enum not defined in this test because non_exhaustive is ignored for the
79 // purposes of dead code analysis within a crate.
80 let error_kind = ErrorKind::NotFound;
82 ErrorKind::NotFound => {},
86 ErrorKind::NotFound => {},
87 ErrorKind::PermissionDenied => {},
92 #![allow(clippy::manual_non_exhaustive)]