single_match: Clarify the don't lint test case

This commit is contained in:
Georgy Komarov 2022-01-21 07:24:07 +03:00
parent a5a07e503f
commit a0c5087520
2 changed files with 9 additions and 7 deletions

View file

@ -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, ..) => {},

View file

@ -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), _) => {},