]> git.lizzy.rs Git - rust.git/commitdiff
Add another test.
authorlaurent <laurent.mazare@gmail.com>
Wed, 29 Nov 2017 20:52:49 +0000 (20:52 +0000)
committerlaurent <laurent.mazare@gmail.com>
Wed, 29 Nov 2017 20:52:49 +0000 (20:52 +0000)
tests/ui/matches.rs
tests/ui/matches.stderr

index f15a57c4f856f0ec0d234a9b68a0cc483239a608..7da2858d6ecd56fd1694a69552c9a5ffdccfddbf 100644 (file)
@@ -285,6 +285,14 @@ fn match_wild_err_arm() {
         Err(_) => println!("err")
     }
 
+    // this is a current false positive, see #1996
+    match x {
+        Ok(3) => println!("ok"),
+        Ok(x) if x*x == 64 => println!("ok 64"),
+        Ok(_) => println!("ok"),
+        Err(_) => println!("err")
+    }
+
     match (x, Some(1i32)) {
         (Ok(x), Some(_)) => println!("ok {}", x),
         (Ok(_), Some(x)) => println!("ok {}", x),
index cc7c5a4fee223cef960caf6949d34dede47ee0c4..49c0e900d06117e9b5c9f51c83c73ac8ff0ac573 100644 (file)
@@ -391,20 +391,38 @@ note: consider refactoring into `Ok(3) | Ok(_)`
     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
 
 error: this `match` has identical arm bodies
-   --> $DIR/matches.rs:290:29
+   --> $DIR/matches.rs:292:18
     |
-290 |         (Ok(_), Some(x)) => println!("ok {}", x),
+292 |         Ok(_) => println!("ok"),
+    |                  ^^^^^^^^^^^^^^
+    |
+note: same as this
+   --> $DIR/matches.rs:290:18
+    |
+290 |         Ok(3) => println!("ok"),
+    |                  ^^^^^^^^^^^^^^
+note: consider refactoring into `Ok(3) | Ok(_)`
+   --> $DIR/matches.rs:290:18
+    |
+290 |         Ok(3) => println!("ok"),
+    |                  ^^^^^^^^^^^^^^
+    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+
+error: this `match` has identical arm bodies
+   --> $DIR/matches.rs:298:29
+    |
+298 |         (Ok(_), Some(x)) => println!("ok {}", x),
     |                             ^^^^^^^^^^^^^^^^^^^^
     |
 note: same as this
-   --> $DIR/matches.rs:289:29
+   --> $DIR/matches.rs:297:29
     |
-289 |         (Ok(x), Some(_)) => println!("ok {}", x),
+297 |         (Ok(x), Some(_)) => println!("ok {}", x),
     |                             ^^^^^^^^^^^^^^^^^^^^
 note: consider refactoring into `(Ok(x), Some(_)) | (Ok(_), Some(x))`
-   --> $DIR/matches.rs:289:29
+   --> $DIR/matches.rs:297:29
     |
-289 |         (Ok(x), Some(_)) => println!("ok {}", x),
+297 |         (Ok(x), Some(_)) => println!("ok {}", x),
     |                             ^^^^^^^^^^^^^^^^^^^^
     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)