-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make match_like_matches_macro only apply to matches with a wildcard
- Loading branch information
1 parent
1740dda
commit 37d75da
Showing
8 changed files
with
77 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,36 @@ | ||
// run-rustfix | ||
|
||
#![warn(clippy::match_like_matches_macro)] | ||
#![allow(unreachable_patterns)] | ||
|
||
fn main() { | ||
let x = Some(5); | ||
|
||
// Lint | ||
let _y = matches!(x, Some(0)); | ||
|
||
// Lint | ||
let _w = matches!(x, Some(_)); | ||
|
||
// Turn into is_none | ||
let _z = x.is_none(); | ||
|
||
// Lint | ||
let _z = !matches!(x, Some(r) if r == 0); | ||
let _zz = !matches!(x, Some(r) if r == 0); | ||
|
||
// Lint | ||
let _zz = matches!(x, Some(5)); | ||
let _zzz = matches!(x, Some(5)); | ||
|
||
// No lint | ||
let _a = match x { | ||
Some(_) => false, | ||
None => false, | ||
_ => false, | ||
}; | ||
|
||
// No lint | ||
let _a = match x { | ||
let _ab = match x { | ||
Some(0) => false, | ||
Some(_) => true, | ||
_ => true, | ||
None => false, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters