about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-08-18 16:52:49 +0200
committerMazdak Farrokhzad <twingoow@gmail.com>2019-08-24 21:32:48 +0200
commit5f57feec0a3038ffc085ba897717b4ffd75445ee (patch)
tree01d151b0798206a9c932abb09b318ed6d43909e7
parentd34ee769b061975bf637776052179058c1f00bd7 (diff)
downloadrust-5f57feec0a3038ffc085ba897717b4ffd75445ee.tar.gz
rust-5f57feec0a3038ffc085ba897717b4ffd75445ee.zip
parser: `multiple-pattern-typo`: cover more or-pattern places.
-rw-r--r--src/test/ui/or-patterns/multiple-pattern-typo.rs33
-rw-r--r--src/test/ui/or-patterns/multiple-pattern-typo.stderr42
2 files changed, 73 insertions, 2 deletions
diff --git a/src/test/ui/or-patterns/multiple-pattern-typo.rs b/src/test/ui/or-patterns/multiple-pattern-typo.rs
index 14ad33d53b0..5d1da56674b 100644
--- a/src/test/ui/or-patterns/multiple-pattern-typo.rs
+++ b/src/test/ui/or-patterns/multiple-pattern-typo.rs
@@ -1,7 +1,40 @@
+#![feature(or_patterns)]
+//~^ WARN the feature `or_patterns` is incomplete and may cause the compiler to crash
+
 fn main() {
     let x = 3;
+
     match x {
         1 | 2 || 3 => (), //~ ERROR unexpected token `||` after pattern
         _ => (),
     }
+
+    match x {
+        (1 | 2 || 3) => (), //~ ERROR unexpected token `||` after pattern
+        _ => (),
+    }
+
+    match (x,) {
+        (1 | 2 || 3,) => (), //~ ERROR unexpected token `||` after pattern
+        _ => (),
+    }
+
+    struct TS(u8);
+
+    match TS(x) {
+        TS(1 | 2 || 3) => (), //~ ERROR unexpected token `||` after pattern
+        _ => (),
+    }
+
+    struct NS { f: u8 }
+
+    match (NS { f: x }) {
+        NS { f: 1 | 2 || 3 } => (), //~ ERROR unexpected token `||` after pattern
+        _ => (),
+    }
+
+    match [x] {
+        [1 | 2 || 3] => (), //~ ERROR unexpected token `||` after pattern
+        _ => (),
+    }
 }
diff --git a/src/test/ui/or-patterns/multiple-pattern-typo.stderr b/src/test/ui/or-patterns/multiple-pattern-typo.stderr
index a29fa584b29..97f3470a54a 100644
--- a/src/test/ui/or-patterns/multiple-pattern-typo.stderr
+++ b/src/test/ui/or-patterns/multiple-pattern-typo.stderr
@@ -1,8 +1,46 @@
 error: unexpected token `||` after pattern
-  --> $DIR/multiple-pattern-typo.rs:4:15
+  --> $DIR/multiple-pattern-typo.rs:8:15
    |
 LL |         1 | 2 || 3 => (),
    |               ^^ help: use a single `|` to specify multiple patterns: `|`
 
-error: aborting due to previous error
+error: unexpected token `||` after pattern
+  --> $DIR/multiple-pattern-typo.rs:13:16
+   |
+LL |         (1 | 2 || 3) => (),
+   |                ^^ help: use a single `|` to specify multiple patterns: `|`
+
+error: unexpected token `||` after pattern
+  --> $DIR/multiple-pattern-typo.rs:18:16
+   |
+LL |         (1 | 2 || 3,) => (),
+   |                ^^ help: use a single `|` to specify multiple patterns: `|`
+
+error: unexpected token `||` after pattern
+  --> $DIR/multiple-pattern-typo.rs:25:18
+   |
+LL |         TS(1 | 2 || 3) => (),
+   |                  ^^ help: use a single `|` to specify multiple patterns: `|`
+
+error: unexpected token `||` after pattern
+  --> $DIR/multiple-pattern-typo.rs:32:23
+   |
+LL |         NS { f: 1 | 2 || 3 } => (),
+   |                       ^^ help: use a single `|` to specify multiple patterns: `|`
+
+error: unexpected token `||` after pattern
+  --> $DIR/multiple-pattern-typo.rs:37:16
+   |
+LL |         [1 | 2 || 3] => (),
+   |                ^^ help: use a single `|` to specify multiple patterns: `|`
+
+warning: the feature `or_patterns` is incomplete and may cause the compiler to crash
+  --> $DIR/multiple-pattern-typo.rs:1:12
+   |
+LL | #![feature(or_patterns)]
+   |            ^^^^^^^^^^^
+   |
+   = note: `#[warn(incomplete_features)]` on by default
+
+error: aborting due to 6 previous errors