2020-07-05 15:10:59 -05:00
|
|
|
// run-rustfix
|
|
|
|
|
|
|
|
#![warn(clippy::match_like_matches_macro)]
|
2020-07-08 11:04:51 -05:00
|
|
|
#![allow(unreachable_patterns)]
|
2020-07-05 15:10:59 -05:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let x = Some(5);
|
|
|
|
|
|
|
|
// Lint
|
|
|
|
let _y = match x {
|
|
|
|
Some(0) => true,
|
|
|
|
_ => false,
|
|
|
|
};
|
|
|
|
|
2020-07-08 11:04:51 -05:00
|
|
|
// Lint
|
|
|
|
let _w = match x {
|
|
|
|
Some(_) => true,
|
|
|
|
_ => false,
|
|
|
|
};
|
|
|
|
|
2020-07-05 15:10:59 -05:00
|
|
|
// Turn into is_none
|
|
|
|
let _z = match x {
|
|
|
|
Some(_) => false,
|
|
|
|
None => true,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Lint
|
2020-07-08 11:04:51 -05:00
|
|
|
let _zz = match x {
|
2020-07-05 15:10:59 -05:00
|
|
|
Some(r) if r == 0 => false,
|
|
|
|
_ => true,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Lint
|
2020-07-08 11:04:51 -05:00
|
|
|
let _zzz = if let Some(5) = x { true } else { false };
|
2020-07-05 15:10:59 -05:00
|
|
|
|
|
|
|
// No lint
|
|
|
|
let _a = match x {
|
|
|
|
Some(_) => false,
|
2020-07-08 11:04:51 -05:00
|
|
|
_ => false,
|
2020-07-05 15:10:59 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// No lint
|
2020-07-08 11:04:51 -05:00
|
|
|
let _ab = match x {
|
2020-07-05 15:10:59 -05:00
|
|
|
Some(0) => false,
|
2020-07-08 11:04:51 -05:00
|
|
|
_ => true,
|
2020-07-05 15:10:59 -05:00
|
|
|
None => false,
|
|
|
|
};
|
|
|
|
}
|