rust/tests/ui/match_expr_like_matches_macro.fixed

37 lines
592 B
Rust
Raw Normal View History

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