2 // aux-build:non-exhaustive-enum.rs
3 #![deny(clippy::wildcard_enum_match_arm)]
4 #![allow(dead_code, unreachable_code, unused_variables)]
6 clippy::diverging_sub_expression,
8 clippy::uninlined_format_args,
9 clippy::unnested_or_patterns,
10 clippy::wildcard_in_or_patterns
13 extern crate non_exhaustive_enum;
15 use non_exhaustive_enum::ErrorKind;
17 #[derive(Clone, Copy, Debug, Eq, PartialEq)]
27 fn is_monochrome(self) -> bool {
29 Color::Red | Color::Green | Color::Blue => true,
30 Color::Rgb(r, g, b) => r | g == 0 || r | b == 0 || g | b == 0,
37 let color = Color::Rgb(0, 0, 127);
39 Color::Red => println!("Red"),
40 Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan => eprintln!("Not red"),
43 Color::Red => println!("Red"),
44 _not_red @ Color::Green | _not_red @ Color::Blue | _not_red @ Color::Rgb(..) | _not_red @ Color::Cyan => eprintln!("Not red"),
46 let _str = match color {
47 Color::Red => "Red".to_owned(),
48 not_red @ Color::Green | not_red @ Color::Blue | not_red @ Color::Rgb(..) | not_red @ Color::Cyan => format!("{:?}", not_red),
55 c if c.is_monochrome() => {},
56 Color::Rgb(_, _, _) => {},
58 let _str = match color {
60 c @ Color::Green | c @ Color::Blue | c @ Color::Rgb(_, _, _) | c @ Color::Cyan => "Not red",
63 Color::Rgb(r, _, _) if r > 0 => "Some red",
64 Color::Red | Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan => "No red",
67 Color::Red | Color::Green | Color::Blue | Color::Cyan => {},
70 let x: u8 = unimplemented!();
76 // We need to use an enum not defined in this test because non_exhaustive is ignored for the
77 // purposes of dead code analysis within a crate.
78 let error_kind = ErrorKind::NotFound;
80 ErrorKind::NotFound => {},
81 ErrorKind::PermissionDenied | _ => {},
84 ErrorKind::NotFound => {},
85 ErrorKind::PermissionDenied => {},
90 #![allow(clippy::manual_non_exhaustive)]