mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
single_match: Clarify the don't lint
test case
This commit is contained in:
parent
a5a07e503f
commit
a0c5087520
2 changed files with 9 additions and 7 deletions
|
@ -152,7 +152,9 @@ fn ranges() {
|
|||
}
|
||||
let x = (Some(E::V), Some(42));
|
||||
|
||||
// don't lint
|
||||
// Don't lint, because the `E` enum can be extended with additional fields later. Thus, the
|
||||
// proposed replacement to `if let Some(E::V)` may hide non-exhaustive warnings that appeared
|
||||
// because of `match` construction.
|
||||
match x {
|
||||
(Some(E::V), _) => {},
|
||||
(None, _) => {},
|
||||
|
@ -176,19 +178,19 @@ fn ranges() {
|
|||
(..) => {},
|
||||
}
|
||||
|
||||
// don't lint
|
||||
// Don't lint, see above.
|
||||
match (Some(E::V), Some(E::V), Some(E::V)) {
|
||||
(.., Some(E::V), _) => {},
|
||||
(.., None, _) => {},
|
||||
}
|
||||
|
||||
// don't lint
|
||||
// Don't lint, see above.
|
||||
match (Some(E::V), Some(E::V), Some(E::V)) {
|
||||
(Some(E::V), ..) => {},
|
||||
(None, ..) => {},
|
||||
}
|
||||
|
||||
// don't lint
|
||||
// Don't lint, see above.
|
||||
match (Some(E::V), Some(E::V), Some(E::V)) {
|
||||
(_, Some(E::V), ..) => {},
|
||||
(_, None, ..) => {},
|
||||
|
|
|
@ -120,7 +120,7 @@ LL | | };
|
|||
| |_____^ help: try this: `if let None = x { println!() }`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> $DIR/single_match.rs:162:5
|
||||
--> $DIR/single_match.rs:164:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | (Some(_), _) => {},
|
||||
|
@ -129,7 +129,7 @@ LL | | }
|
|||
| |_____^ help: try this: `if let (Some(_), _) = x {}`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> $DIR/single_match.rs:168:5
|
||||
--> $DIR/single_match.rs:170:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | (Some(E::V), _) => todo!(),
|
||||
|
@ -138,7 +138,7 @@ LL | | }
|
|||
| |_____^ help: try this: `if let (Some(E::V), _) = x { todo!() }`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> $DIR/single_match.rs:174:5
|
||||
--> $DIR/single_match.rs:176:5
|
||||
|
|
||||
LL | / match (Some(42), Some(E::V), Some(42)) {
|
||||
LL | | (.., Some(E::V), _) => {},
|
||||
|
|
Loading…
Reference in a new issue