Skip to content

Commit

Permalink
single_match: Clarify the don't lint test case
Browse files Browse the repository at this point in the history
  • Loading branch information
jubnzv committed Jan 21, 2022
1 parent a5a07e5 commit a0c5087
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions tests/ui/single_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, _) => {},
Expand All @@ -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, ..) => {},
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/single_match.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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(_), _) => {},
Expand All @@ -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!(),
Expand All @@ -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), _) => {},
Expand Down

0 comments on commit a0c5087

Please sign in to comment.