2019-09-21 05:26:18 +00:00
|
|
|
// run-rustfix
|
|
|
|
|
|
|
|
#![deny(clippy::wildcard_enum_match_arm)]
|
2019-12-27 04:42:28 +00:00
|
|
|
#![allow(
|
|
|
|
unreachable_code,
|
|
|
|
unused_variables,
|
|
|
|
dead_code,
|
|
|
|
clippy::single_match,
|
2020-01-05 14:05:16 +00:00
|
|
|
clippy::wildcard_in_or_patterns
|
2019-12-27 04:42:28 +00:00
|
|
|
)]
|
2019-12-22 02:13:39 +00:00
|
|
|
|
|
|
|
use std::io::ErrorKind;
|
2019-09-21 05:26:18 +00:00
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
|
|
|
enum Color {
|
|
|
|
Red,
|
|
|
|
Green,
|
|
|
|
Blue,
|
|
|
|
Rgb(u8, u8, u8),
|
|
|
|
Cyan,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Color {
|
|
|
|
fn is_monochrome(self) -> bool {
|
|
|
|
match self {
|
|
|
|
Color::Red | Color::Green | Color::Blue => true,
|
|
|
|
Color::Rgb(r, g, b) => r | g == 0 || r | b == 0 || g | b == 0,
|
|
|
|
Color::Cyan => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let color = Color::Rgb(0, 0, 127);
|
|
|
|
match color {
|
|
|
|
Color::Red => println!("Red"),
|
|
|
|
Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan => eprintln!("Not red"),
|
|
|
|
};
|
|
|
|
match color {
|
|
|
|
Color::Red => println!("Red"),
|
|
|
|
_not_red @ Color::Green | _not_red @ Color::Blue | _not_red @ Color::Rgb(..) | _not_red @ Color::Cyan => eprintln!("Not red"),
|
|
|
|
};
|
|
|
|
let _str = match color {
|
|
|
|
Color::Red => "Red".to_owned(),
|
|
|
|
not_red @ Color::Green | not_red @ Color::Blue | not_red @ Color::Rgb(..) | not_red @ Color::Cyan => format!("{:?}", not_red),
|
|
|
|
};
|
|
|
|
match color {
|
|
|
|
Color::Red => {},
|
|
|
|
Color::Green => {},
|
|
|
|
Color::Blue => {},
|
|
|
|
Color::Cyan => {},
|
|
|
|
c if c.is_monochrome() => {},
|
|
|
|
Color::Rgb(_, _, _) => {},
|
|
|
|
};
|
|
|
|
let _str = match color {
|
|
|
|
Color::Red => "Red",
|
|
|
|
c @ Color::Green | c @ Color::Blue | c @ Color::Rgb(_, _, _) | c @ Color::Cyan => "Not red",
|
|
|
|
};
|
|
|
|
match color {
|
|
|
|
Color::Rgb(r, _, _) if r > 0 => "Some red",
|
|
|
|
Color::Red | Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan => "No red",
|
|
|
|
};
|
|
|
|
match color {
|
|
|
|
Color::Red | Color::Green | Color::Blue | Color::Cyan => {},
|
|
|
|
Color::Rgb(..) => {},
|
|
|
|
};
|
|
|
|
let x: u8 = unimplemented!();
|
|
|
|
match x {
|
|
|
|
0 => {},
|
|
|
|
140 => {},
|
|
|
|
_ => {},
|
|
|
|
};
|
2019-12-22 02:13:39 +00:00
|
|
|
// We need to use an enum not defined in this test because non_exhaustive is ignored for the
|
|
|
|
// purposes of dead code analysis within a crate.
|
|
|
|
let error_kind = ErrorKind::NotFound;
|
|
|
|
match error_kind {
|
|
|
|
ErrorKind::NotFound => {},
|
|
|
|
std::io::ErrorKind::PermissionDenied | std::io::ErrorKind::ConnectionRefused | std::io::ErrorKind::ConnectionReset | std::io::ErrorKind::ConnectionAborted | std::io::ErrorKind::NotConnected | std::io::ErrorKind::AddrInUse | std::io::ErrorKind::AddrNotAvailable | std::io::ErrorKind::BrokenPipe | std::io::ErrorKind::AlreadyExists | std::io::ErrorKind::WouldBlock | std::io::ErrorKind::InvalidInput | std::io::ErrorKind::InvalidData | std::io::ErrorKind::TimedOut | std::io::ErrorKind::WriteZero | std::io::ErrorKind::Interrupted | std::io::ErrorKind::Other | std::io::ErrorKind::UnexpectedEof | _ => {},
|
|
|
|
}
|
|
|
|
match error_kind {
|
|
|
|
ErrorKind::NotFound => {},
|
|
|
|
ErrorKind::PermissionDenied => {},
|
|
|
|
ErrorKind::ConnectionRefused => {},
|
|
|
|
ErrorKind::ConnectionReset => {},
|
|
|
|
ErrorKind::ConnectionAborted => {},
|
|
|
|
ErrorKind::NotConnected => {},
|
|
|
|
ErrorKind::AddrInUse => {},
|
|
|
|
ErrorKind::AddrNotAvailable => {},
|
|
|
|
ErrorKind::BrokenPipe => {},
|
|
|
|
ErrorKind::AlreadyExists => {},
|
|
|
|
ErrorKind::WouldBlock => {},
|
|
|
|
ErrorKind::InvalidInput => {},
|
|
|
|
ErrorKind::InvalidData => {},
|
|
|
|
ErrorKind::TimedOut => {},
|
|
|
|
ErrorKind::WriteZero => {},
|
|
|
|
ErrorKind::Interrupted => {},
|
|
|
|
ErrorKind::Other => {},
|
|
|
|
ErrorKind::UnexpectedEof => {},
|
|
|
|
_ => {},
|
|
|
|
}
|
2019-09-21 05:26:18 +00:00
|
|
|
}
|