mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-10 14:57:14 +00:00
33 lines
518 B
Rust
33 lines
518 B
Rust
|
// run-rustfix
|
||
|
|
||
|
#![warn(clippy::match_like_matches_macro)]
|
||
|
|
||
|
fn main() {
|
||
|
let x = Some(5);
|
||
|
|
||
|
// Lint
|
||
|
let _y = matches!(x, Some(0));
|
||
|
|
||
|
// Turn into is_none
|
||
|
let _z = x.is_none();
|
||
|
|
||
|
// Lint
|
||
|
let _z = !matches!(x, Some(r) if r == 0);
|
||
|
|
||
|
// Lint
|
||
|
let _zz = matches!(x, Some(5));
|
||
|
|
||
|
// No lint
|
||
|
let _a = match x {
|
||
|
Some(_) => false,
|
||
|
None => false,
|
||
|
};
|
||
|
|
||
|
// No lint
|
||
|
let _a = match x {
|
||
|
Some(0) => false,
|
||
|
Some(_) => true,
|
||
|
None => false,
|
||
|
};
|
||
|
}
|