about summary refs log tree commit diff
path: root/src/test/ui/or-patterns
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2019-12-27 17:53:00 +0000
committerMatthew Jasper <mjjasper1@gmail.com>2020-02-01 22:10:58 +0000
commit30058df867fbe5c43f90707d6fb644fba6201c2a (patch)
tree00c9815ad4b466ecfb5fc1814b0b19d9fb01d55f /src/test/ui/or-patterns
parenta20969c489d7f415f8073aacef1d480de6459ce8 (diff)
downloadrust-30058df867fbe5c43f90707d6fb644fba6201c2a.tar.gz
rust-30058df867fbe5c43f90707d6fb644fba6201c2a.zip
Update existing tests for or-patterns
Diffstat (limited to 'src/test/ui/or-patterns')
-rw-r--r--src/test/ui/or-patterns/consistent-bindings.rs46
-rw-r--r--src/test/ui/or-patterns/consistent-bindings.stderr9
-rw-r--r--src/test/ui/or-patterns/exhaustiveness-non-exhaustive.rs7
-rw-r--r--src/test/ui/or-patterns/exhaustiveness-non-exhaustive.stderr14
-rw-r--r--src/test/ui/or-patterns/exhaustiveness-pass.rs9
-rw-r--r--src/test/ui/or-patterns/exhaustiveness-pass.stderr8
-rw-r--r--src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs7
-rw-r--r--src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr48
-rw-r--r--src/test/ui/or-patterns/feature-gate-const-fn.rs2
-rw-r--r--src/test/ui/or-patterns/feature-gate-const-fn.stderr17
10 files changed, 68 insertions, 99 deletions
diff --git a/src/test/ui/or-patterns/consistent-bindings.rs b/src/test/ui/or-patterns/consistent-bindings.rs
index ec71afed872..3ee57978bb0 100644
--- a/src/test/ui/or-patterns/consistent-bindings.rs
+++ b/src/test/ui/or-patterns/consistent-bindings.rs
@@ -2,6 +2,8 @@
 
 // edition:2018
 
+// check-pass
+
 #![feature(or_patterns)]
 
 fn main() {
@@ -11,35 +13,29 @@ fn main() {
     let Ok(ref mut a) | Err(ref mut a) = Ok(0);
 
     // Two levels:
-    enum Tri<S, T, U> { V1(S), V2(T), V3(U) }
+    enum Tri<S, T, U> {
+        V1(S),
+        V2(T),
+        V3(U),
+    }
     use Tri::*;
 
-    let Ok((V1(a) | V2(a) | V3(a), b)) | Err(Ok((a, b)) | Err((a, b)))
-        : Result<_, Result<_, _>>
-        = Ok((V1(1), 1));
+    let Ok((V1(a) | V2(a) | V3(a), b)) | Err(Ok((a, b)) | Err((a, b))): Result<_, Result<_, _>> =
+        Ok((V1(1), 1));
 
-    let Ok((V1(a) | V2(a) | V3(a), ref b)) | Err(Ok((a, ref b)) | Err((a, ref b)))
-        : Result<_, Result<_, _>>
-        = Ok((V1(1), 1));
+    let Ok((V1(a) | V2(a) | V3(a), ref b)) | Err(Ok((a, ref b)) | Err((a, ref b))): Result<
+        _,
+        Result<_, _>,
+    > = Ok((V1(1), 1));
 
     // Three levels:
     let (
-            a,
-            Err((ref mut b, ref c, d)) |
-            Ok((
-                Ok(
-                    V1((ref c, d)) |
-                    V2((d, ref c)) |
-                    V3((ref c, Ok((_, d)) | Err((d, _))))
-                ) |
-                Err((ref c, d)),
-                ref mut b
-            ))
-        ) =
-        (1, Ok((Ok(V3((1, Ok((1, 1))))), 1)));
-
-    // FIXME(or_patterns; Centril | dlrobertson): remove this line below and
-    // change this test to check-pass once MIR can handle or-patterns with bindings.
-    let () = 0;
-    //~^ ERROR mismatched types
+        a,
+        Err((ref mut b, ref c, d))
+        | Ok((
+            Ok(V1((ref c, d)) | V2((d, ref c)) | V3((ref c, Ok((_, d)) | Err((d, _)))))
+            | Err((ref c, d)),
+            ref mut b,
+        )),
+    ): (_, Result<_, _>) = (1, Ok((Ok(V3((1, Ok::<_, (i32, i32)>((1, 1))))), 1)));
 }
diff --git a/src/test/ui/or-patterns/consistent-bindings.stderr b/src/test/ui/or-patterns/consistent-bindings.stderr
deleted file mode 100644
index bb8e90af5f2..00000000000
--- a/src/test/ui/or-patterns/consistent-bindings.stderr
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/consistent-bindings.rs:43:9
-   |
-LL |     let () = 0;
-   |         ^^ expected integer, found `()`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.rs b/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.rs
index 2e8baf978e2..c8bc4a2a8d5 100644
--- a/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.rs
+++ b/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.rs
@@ -1,13 +1,8 @@
 #![feature(or_patterns)]
 #![deny(unreachable_patterns)]
 
-// We wrap patterns in a tuple because top-level or-patterns are special-cased for now.
+// We wrap patterns in a tuple because top-level or-patterns were special-cased.
 fn main() {
-    // Get the fatal error out of the way
-    match (0u8,) {
-        (0 | _,) => {} //~^ ERROR or-patterns are not fully implemented yet
-    }
-
     match (0u8, 0u8) {
         //~^ ERROR non-exhaustive patterns: `(2u8..=std::u8::MAX, _)`
         (0 | 1, 2 | 3) => {}
diff --git a/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.stderr b/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.stderr
index 7fbd846a22f..3ba26de10d3 100644
--- a/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.stderr
+++ b/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.stderr
@@ -1,5 +1,5 @@
 error[E0004]: non-exhaustive patterns: `(2u8..=std::u8::MAX, _)` not covered
-  --> $DIR/exhaustiveness-non-exhaustive.rs:13:11
+  --> $DIR/exhaustiveness-non-exhaustive.rs:6:11
    |
 LL |     match (0u8, 0u8) {
    |           ^^^^^^^^^^ pattern `(2u8..=std::u8::MAX, _)` not covered
@@ -7,7 +7,7 @@ LL |     match (0u8, 0u8) {
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
 error[E0004]: non-exhaustive patterns: `((4u8..=std::u8::MAX))` not covered
-  --> $DIR/exhaustiveness-non-exhaustive.rs:17:11
+  --> $DIR/exhaustiveness-non-exhaustive.rs:10:11
    |
 LL |     match ((0u8,),) {
    |           ^^^^^^^^^ pattern `((4u8..=std::u8::MAX))` not covered
@@ -15,19 +15,13 @@ LL |     match ((0u8,),) {
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
 error[E0004]: non-exhaustive patterns: `(Some(2u8..=std::u8::MAX))` not covered
-  --> $DIR/exhaustiveness-non-exhaustive.rs:21:11
+  --> $DIR/exhaustiveness-non-exhaustive.rs:14:11
    |
 LL |     match (Some(0u8),) {
    |           ^^^^^^^^^^^^ pattern `(Some(2u8..=std::u8::MAX))` not covered
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
-error: or-patterns are not fully implemented yet
-  --> $DIR/exhaustiveness-non-exhaustive.rs:9:10
-   |
-LL |         (0 | _,) => {}
-   |          ^^^^^
-
-error: aborting due to 4 previous errors
+error: aborting due to 3 previous errors
 
 For more information about this error, try `rustc --explain E0004`.
diff --git a/src/test/ui/or-patterns/exhaustiveness-pass.rs b/src/test/ui/or-patterns/exhaustiveness-pass.rs
index 9b62810d29d..8dcf8792f6f 100644
--- a/src/test/ui/or-patterns/exhaustiveness-pass.rs
+++ b/src/test/ui/or-patterns/exhaustiveness-pass.rs
@@ -1,13 +1,10 @@
 #![feature(or_patterns)]
 #![deny(unreachable_patterns)]
 
-// We wrap patterns in a tuple because top-level or-patterns are special-cased for now.
-fn main() {
-    // Get the fatal error out of the way
-    match (0,) {
-        (0 | _,) => {} //~^ ERROR or-patterns are not fully implemented yet
-    }
+// check-pass
 
+// We wrap patterns in a tuple because top-level or-patterns were special-cased.
+fn main() {
     match (0,) {
         (1 | 2,) => {}
         _ => {}
diff --git a/src/test/ui/or-patterns/exhaustiveness-pass.stderr b/src/test/ui/or-patterns/exhaustiveness-pass.stderr
deleted file mode 100644
index dc5a4186ac7..00000000000
--- a/src/test/ui/or-patterns/exhaustiveness-pass.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: or-patterns are not fully implemented yet
-  --> $DIR/exhaustiveness-pass.rs:9:10
-   |
-LL |         (0 | _,) => {}
-   |          ^^^^^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs
index dd1c16f5000..44bae282d88 100644
--- a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs
+++ b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs
@@ -1,13 +1,8 @@
 #![feature(or_patterns)]
 #![deny(unreachable_patterns)]
 
-// We wrap patterns in a tuple because top-level or-patterns are special-cased for now.
+// We wrap patterns in a tuple because top-level or-patterns were special-cased.
 fn main() {
-    // Get the fatal error out of the way
-    match (0u8,) {
-        (0 | _,) => {} //~^ ERROR or-patterns are not fully implemented yet
-    }
-
     match (0u8,) {
         (1 | 2,) => {}
         (1,) => {} //~ ERROR unreachable pattern
diff --git a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr
index 1f07c27afad..bef6f8270bc 100644
--- a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr
+++ b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr
@@ -1,110 +1,104 @@
 error: unreachable pattern
-  --> $DIR/exhaustiveness-unreachable-pattern.rs:15:9
+  --> $DIR/exhaustiveness-unreachable-pattern.rs:8:9
    |
 LL |         (1,) => {}
    |         ^^^^
    |
 note: the lint level is defined here
-  --> $DIR/exhaustiveness-unreachable-pattern.rs:3:9
+  --> $DIR/exhaustiveness-unreachable-pattern.rs:2:9
    |
 LL | #![deny(unreachable_patterns)]
    |         ^^^^^^^^^^^^^^^^^^^^
 
 error: unreachable pattern
-  --> $DIR/exhaustiveness-unreachable-pattern.rs:20:9
+  --> $DIR/exhaustiveness-unreachable-pattern.rs:13:9
    |
 LL |         (2,) => {}
    |         ^^^^
 
 error: unreachable pattern
-  --> $DIR/exhaustiveness-unreachable-pattern.rs:26:9
+  --> $DIR/exhaustiveness-unreachable-pattern.rs:19:9
    |
 LL |         (1 | 2,) => {}
    |         ^^^^^^^^
 
 error: unreachable pattern
-  --> $DIR/exhaustiveness-unreachable-pattern.rs:31:9
+  --> $DIR/exhaustiveness-unreachable-pattern.rs:24:9
    |
 LL |         (1, 3) => {}
    |         ^^^^^^
 
 error: unreachable pattern
-  --> $DIR/exhaustiveness-unreachable-pattern.rs:32:9
+  --> $DIR/exhaustiveness-unreachable-pattern.rs:25:9
    |
 LL |         (1, 4) => {}
    |         ^^^^^^
 
 error: unreachable pattern
-  --> $DIR/exhaustiveness-unreachable-pattern.rs:33:9
+  --> $DIR/exhaustiveness-unreachable-pattern.rs:26:9
    |
 LL |         (2, 4) => {}
    |         ^^^^^^
 
 error: unreachable pattern
-  --> $DIR/exhaustiveness-unreachable-pattern.rs:34:9
+  --> $DIR/exhaustiveness-unreachable-pattern.rs:27:9
    |
 LL |         (2 | 1, 4) => {}
    |         ^^^^^^^^^^
 
 error: unreachable pattern
-  --> $DIR/exhaustiveness-unreachable-pattern.rs:36:9
+  --> $DIR/exhaustiveness-unreachable-pattern.rs:29:9
    |
 LL |         (1, 4 | 5) => {}
    |         ^^^^^^^^^^
 
 error: unreachable pattern
-  --> $DIR/exhaustiveness-unreachable-pattern.rs:41:9
+  --> $DIR/exhaustiveness-unreachable-pattern.rs:34:9
    |
 LL |         (Some(1),) => {}
    |         ^^^^^^^^^^
 
 error: unreachable pattern
-  --> $DIR/exhaustiveness-unreachable-pattern.rs:42:9
+  --> $DIR/exhaustiveness-unreachable-pattern.rs:35:9
    |
 LL |         (None,) => {}
    |         ^^^^^^^
 
 error: unreachable pattern
-  --> $DIR/exhaustiveness-unreachable-pattern.rs:47:9
+  --> $DIR/exhaustiveness-unreachable-pattern.rs:40:9
    |
-LL |         ((1..=4,),) => {},
+LL |         ((1..=4,),) => {}
    |         ^^^^^^^^^^^
 
 error: unreachable pattern
-  --> $DIR/exhaustiveness-unreachable-pattern.rs:53:12
+  --> $DIR/exhaustiveness-unreachable-pattern.rs:45:14
    |
-LL |          | 1,) => {}
-   |            ^
+LL |         (1 | 1,) => {}
+   |              ^
 
 error: unreachable pattern
-  --> $DIR/exhaustiveness-unreachable-pattern.rs:60:15
+  --> $DIR/exhaustiveness-unreachable-pattern.rs:52:15
    |
 LL |             | 0] => {}
    |               ^
 
 error: unreachable pattern
-  --> $DIR/exhaustiveness-unreachable-pattern.rs:58:15
+  --> $DIR/exhaustiveness-unreachable-pattern.rs:50:15
    |
 LL |             | 0
    |               ^
 
 error: unreachable pattern
-  --> $DIR/exhaustiveness-unreachable-pattern.rs:68:10
+  --> $DIR/exhaustiveness-unreachable-pattern.rs:60:10
    |
 LL |         [1
    |          ^
 
 error: unreachable pattern
-  --> $DIR/exhaustiveness-unreachable-pattern.rs:74:14
+  --> $DIR/exhaustiveness-unreachable-pattern.rs:66:14
    |
 LL |         Some(0
    |              ^
 
-error: or-patterns are not fully implemented yet
-  --> $DIR/exhaustiveness-unreachable-pattern.rs:9:10
-   |
-LL |         (0 | _,) => {}
-   |          ^^^^^
-
-error: aborting due to 17 previous errors
+error: aborting due to 16 previous errors
 
diff --git a/src/test/ui/or-patterns/feature-gate-const-fn.rs b/src/test/ui/or-patterns/feature-gate-const-fn.rs
index d21cf3dc72c..2ef5537db60 100644
--- a/src/test/ui/or-patterns/feature-gate-const-fn.rs
+++ b/src/test/ui/or-patterns/feature-gate-const-fn.rs
@@ -30,6 +30,8 @@ fn main() {
         let x = Ok(3);
         let Ok(y) | Err(y) = x;
         //~^ ERROR or-pattern is not allowed in a `const`
+        //~| ERROR constant contains unimplemented expression type
+        //~| ERROR constant contains unimplemented expression type
         2
     }];
 }
diff --git a/src/test/ui/or-patterns/feature-gate-const-fn.stderr b/src/test/ui/or-patterns/feature-gate-const-fn.stderr
index 112bc625172..9284e2d442d 100644
--- a/src/test/ui/or-patterns/feature-gate-const-fn.stderr
+++ b/src/test/ui/or-patterns/feature-gate-const-fn.stderr
@@ -52,6 +52,19 @@ LL |         let Ok(y) | Err(y) = x;
    = note: for more information, see https://github.com/rust-lang/rust/issues/49146
    = help: add `#![feature(const_if_match)]` to the crate attributes to enable
 
-error: aborting due to 6 previous errors
+error[E0019]: constant contains unimplemented expression type
+  --> $DIR/feature-gate-const-fn.rs:31:25
+   |
+LL |         let Ok(y) | Err(y) = x;
+   |                         ^
+
+error[E0019]: constant contains unimplemented expression type
+  --> $DIR/feature-gate-const-fn.rs:31:16
+   |
+LL |         let Ok(y) | Err(y) = x;
+   |                ^
+
+error: aborting due to 8 previous errors
 
-For more information about this error, try `rustc --explain E0658`.
+Some errors have detailed explanations: E0019, E0658.
+For more information about an error, try `rustc --explain E0019`.