2020-07-05 20:10:59 +00:00
|
|
|
// run-rustfix
|
|
|
|
|
|
|
|
#![warn(clippy::match_like_matches_macro)]
|
2020-10-24 15:06:07 +00:00
|
|
|
#![allow(unreachable_patterns, dead_code)]
|
2020-07-05 20:10:59 +00:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let x = Some(5);
|
|
|
|
|
|
|
|
// Lint
|
|
|
|
let _y = match x {
|
|
|
|
Some(0) => true,
|
|
|
|
_ => false,
|
|
|
|
};
|
|
|
|
|
2020-07-08 16:04:51 +00:00
|
|
|
// Lint
|
|
|
|
let _w = match x {
|
|
|
|
Some(_) => true,
|
|
|
|
_ => false,
|
|
|
|
};
|
|
|
|
|
2020-07-05 20:10:59 +00:00
|
|
|
// Turn into is_none
|
|
|
|
let _z = match x {
|
|
|
|
Some(_) => false,
|
|
|
|
None => true,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Lint
|
2020-07-08 16:04:51 +00:00
|
|
|
let _zz = match x {
|
2020-07-05 20:10:59 +00:00
|
|
|
Some(r) if r == 0 => false,
|
|
|
|
_ => true,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Lint
|
2020-07-08 16:04:51 +00:00
|
|
|
let _zzz = if let Some(5) = x { true } else { false };
|
2020-07-05 20:10:59 +00:00
|
|
|
|
|
|
|
// No lint
|
|
|
|
let _a = match x {
|
|
|
|
Some(_) => false,
|
2020-07-08 16:04:51 +00:00
|
|
|
_ => false,
|
2020-07-05 20:10:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// No lint
|
2020-07-08 16:04:51 +00:00
|
|
|
let _ab = match x {
|
2020-07-05 20:10:59 +00:00
|
|
|
Some(0) => false,
|
2020-07-08 16:04:51 +00:00
|
|
|
_ => true,
|
2020-07-05 20:10:59 +00:00
|
|
|
None => false,
|
|
|
|
};
|
2020-10-24 15:06:07 +00:00
|
|
|
|
|
|
|
enum E {
|
|
|
|
A(u32),
|
|
|
|
B(i32),
|
|
|
|
C,
|
|
|
|
D,
|
|
|
|
};
|
|
|
|
let x = E::A(2);
|
|
|
|
{
|
|
|
|
// lint
|
|
|
|
let _ans = match x {
|
|
|
|
E::A(_) => true,
|
|
|
|
E::B(_) => true,
|
|
|
|
_ => false,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// lint
|
|
|
|
let _ans = match x {
|
|
|
|
E::B(_) => false,
|
|
|
|
E::C => false,
|
|
|
|
_ => true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// no lint
|
|
|
|
let _ans = match x {
|
|
|
|
E::A(_) => false,
|
|
|
|
E::B(_) => false,
|
|
|
|
E::C => true,
|
|
|
|
_ => true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// no lint
|
|
|
|
let _ans = match x {
|
|
|
|
E::A(_) => true,
|
|
|
|
E::B(_) => false,
|
|
|
|
E::C => false,
|
|
|
|
_ => true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// no lint
|
|
|
|
let _ans = match x {
|
|
|
|
E::A(a) if a < 10 => false,
|
|
|
|
E::B(a) if a < 10 => false,
|
|
|
|
_ => true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// no lint
|
|
|
|
let _ans = match x {
|
|
|
|
E::A(_) => false,
|
|
|
|
E::B(a) if a < 10 => false,
|
|
|
|
_ => true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// no lint
|
|
|
|
let _ans = match x {
|
|
|
|
E::A(a) => a == 10,
|
|
|
|
E::B(_) => false,
|
|
|
|
_ => true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// no lint
|
|
|
|
let _ans = match x {
|
|
|
|
E::A(_) => false,
|
|
|
|
E::B(_) => true,
|
|
|
|
_ => false,
|
|
|
|
};
|
|
|
|
}
|
2020-07-05 20:10:59 +00:00
|
|
|
}
|