about summary refs log tree commit diff
diff options
context:
space:
mode:
authordisco07 <koneenok@outlook.fr>2023-05-11 07:20:02 +0200
committerdisco07 <koneenok@outlook.fr>2023-05-11 07:20:02 +0200
commitc53ceba56f0b0ec5d3ee20a19f0f6aace6d26228 (patch)
treea970c31dcc64af9bda7a4201c6273b2b5c29fc5e
parent3991dd10b524637a113824ac3272620bd9a1c409 (diff)
update tests
-rw-r--r--tests/ui/redundant_pattern_matching_option.fixed14
-rw-r--r--tests/ui/redundant_pattern_matching_option.rs14
-rw-r--r--tests/ui/redundant_pattern_matching_option.stderr24
3 files changed, 30 insertions, 22 deletions
diff --git a/tests/ui/redundant_pattern_matching_option.fixed b/tests/ui/redundant_pattern_matching_option.fixed
index 2f907f7ae3d..94c89049189 100644
--- a/tests/ui/redundant_pattern_matching_option.fixed
+++ b/tests/ui/redundant_pattern_matching_option.fixed
@@ -91,15 +91,19 @@ fn issue7921() {
 }
 
 fn issue10726() {
-    Some(42).is_some();
+    let x = Some(42);
+    let y = None::<()>;
 
-    Some(42).is_none();
+    x.is_some();
 
-    None::<()>.is_some();
+    x.is_none();
 
-    None::<()>.is_none();
+    y.is_some();
+
+    y.is_none();
 
-    match Some(42) {
+    // Don't lint
+    match x {
         Some(21) => true,
         _ => false,
     };
diff --git a/tests/ui/redundant_pattern_matching_option.rs b/tests/ui/redundant_pattern_matching_option.rs
index 5e80a2b384b..303a0280e9d 100644
--- a/tests/ui/redundant_pattern_matching_option.rs
+++ b/tests/ui/redundant_pattern_matching_option.rs
@@ -106,27 +106,31 @@ fn issue7921() {
 }
 
 fn issue10726() {
-    match Some(42) {
+    let x = Some(42);
+    let y = None::<()>;
+
+    match x {
         Some(_) => true,
         _ => false,
     };
 
-    match Some(42) {
+    match x {
         None => true,
         _ => false,
     };
 
-    match None::<()> {
+    match y {
         Some(_) => true,
         _ => false,
     };
 
-    match None::<()> {
+    match y {
         None => true,
         _ => false,
     };
 
-    match Some(42) {
+    // Don't lint
+    match x {
         Some(21) => true,
         _ => false,
     };
diff --git a/tests/ui/redundant_pattern_matching_option.stderr b/tests/ui/redundant_pattern_matching_option.stderr
index 97de2f1c86f..eb4d87ba2b5 100644
--- a/tests/ui/redundant_pattern_matching_option.stderr
+++ b/tests/ui/redundant_pattern_matching_option.stderr
@@ -149,40 +149,40 @@ LL |     if let None = *&None::<()> {}
    |     -------^^^^--------------- help: try this: `if (&None::<()>).is_none()`
 
 error: redundant pattern matching, consider using `is_some()`
-  --> $DIR/redundant_pattern_matching_option.rs:109:5
+  --> $DIR/redundant_pattern_matching_option.rs:112:5
    |
-LL | /     match Some(42) {
+LL | /     match x {
 LL | |         Some(_) => true,
 LL | |         _ => false,
 LL | |     };
-   | |_____^ help: try this: `Some(42).is_some()`
+   | |_____^ help: try this: `x.is_some()`
 
 error: redundant pattern matching, consider using `is_none()`
-  --> $DIR/redundant_pattern_matching_option.rs:114:5
+  --> $DIR/redundant_pattern_matching_option.rs:117:5
    |
-LL | /     match Some(42) {
+LL | /     match x {
 LL | |         None => true,
 LL | |         _ => false,
 LL | |     };
-   | |_____^ help: try this: `Some(42).is_none()`
+   | |_____^ help: try this: `x.is_none()`
 
 error: redundant pattern matching, consider using `is_some()`
-  --> $DIR/redundant_pattern_matching_option.rs:119:5
+  --> $DIR/redundant_pattern_matching_option.rs:122:5
    |
-LL | /     match None::<()> {
+LL | /     match y {
 LL | |         Some(_) => true,
 LL | |         _ => false,
 LL | |     };
-   | |_____^ help: try this: `None::<()>.is_some()`
+   | |_____^ help: try this: `y.is_some()`
 
 error: redundant pattern matching, consider using `is_none()`
-  --> $DIR/redundant_pattern_matching_option.rs:124:5
+  --> $DIR/redundant_pattern_matching_option.rs:127:5
    |
-LL | /     match None::<()> {
+LL | /     match y {
 LL | |         None => true,
 LL | |         _ => false,
 LL | |     };
-   | |_____^ help: try this: `None::<()>.is_none()`
+   | |_____^ help: try this: `y.is_none()`
 
 error: aborting due to 26 previous errors