about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGeorgy Komarov <jubnzv@gmail.com>2022-01-21 07:24:07 +0300
committerGeorgy Komarov <jubnzv@gmail.com>2022-01-21 07:28:26 +0300
commita0c50875202e8d13b70d4cf8e4d347ddb04b876c (patch)
tree90f0f3effc86a4685d062fcb5341b2088192623d
parenta5a07e503f524a0e8b92938301857b3007579115 (diff)
downloadrust-a0c50875202e8d13b70d4cf8e4d347ddb04b876c.tar.gz
rust-a0c50875202e8d13b70d4cf8e4d347ddb04b876c.zip
single_match: Clarify the `don't lint` test case
-rw-r--r--tests/ui/single_match.rs10
-rw-r--r--tests/ui/single_match.stderr6
2 files changed, 9 insertions, 7 deletions
diff --git a/tests/ui/single_match.rs b/tests/ui/single_match.rs
index aa93f4d8ca5..0e50b3e4a6e 100644
--- a/tests/ui/single_match.rs
+++ b/tests/ui/single_match.rs
@@ -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, ..) => {},
diff --git a/tests/ui/single_match.stderr b/tests/ui/single_match.stderr
index f72ad853fed..318faf25717 100644
--- a/tests/ui/single_match.stderr
+++ b/tests/ui/single_match.stderr
@@ -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), _) => {},