about summary refs log tree commit diff
path: root/tests/ui/parser
diff options
context:
space:
mode:
authorNadrieril <nadrieril+git@gmail.com>2023-11-27 03:15:56 +0100
committerNadrieril <nadrieril+git@gmail.com>2023-12-03 12:25:46 +0100
commit80bdcbf50a63845dd3cfeb05751ba3dcbd1025b8 (patch)
tree3309db5b82d4bc8d8d30ffd0e02d96137f5853f9 /tests/ui/parser
parentcaa488b96e65131e4d70f219d5e89008031f9229 (diff)
downloadrust-80bdcbf50a63845dd3cfeb05751ba3dcbd1025b8.tar.gz
rust-80bdcbf50a63845dd3cfeb05751ba3dcbd1025b8.zip
Parse a pattern with no arm
Diffstat (limited to 'tests/ui/parser')
-rw-r--r--tests/ui/parser/attribute/attr-stmt-expr-attr-bad.rs6
-rw-r--r--tests/ui/parser/attribute/attr-stmt-expr-attr-bad.stderr12
-rw-r--r--tests/ui/parser/issues/issue-24375.rs2
-rw-r--r--tests/ui/parser/issues/issue-24375.stderr4
-rw-r--r--tests/ui/parser/macro/macro-expand-to-match-arm.rs6
-rw-r--r--tests/ui/parser/macro/macro-expand-to-match-arm.stderr11
-rw-r--r--tests/ui/parser/match-arm-without-body.rs11
-rw-r--r--tests/ui/parser/match-arm-without-body.stderr84
-rw-r--r--tests/ui/parser/pat-lt-bracket-1.rs2
-rw-r--r--tests/ui/parser/pat-lt-bracket-1.stderr4
10 files changed, 39 insertions, 103 deletions
diff --git a/tests/ui/parser/attribute/attr-stmt-expr-attr-bad.rs b/tests/ui/parser/attribute/attr-stmt-expr-attr-bad.rs
index d1950087c4c..2c402e4c65e 100644
--- a/tests/ui/parser/attribute/attr-stmt-expr-attr-bad.rs
+++ b/tests/ui/parser/attribute/attr-stmt-expr-attr-bad.rs
@@ -84,15 +84,15 @@ fn main() {}
 
 #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } }
 //~^ ERROR inclusive range with no end
-//~| ERROR expected one of `=>`, `if`, or `|`, found `#`
+//~| ERROR expected one of `,`, `=>`, `if`, `|`, or `}`, found `#`
 #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } }
 //~^ ERROR inclusive range with no end
-//~| ERROR expected one of `=>`, `if`, or `|`, found `#`
+//~| ERROR expected one of `,`, `=>`, `if`, `|`, or `}`, found `#`
 #[cfg(FALSE)] fn e() { match 0 { 0..=-#[attr] 10 => () } }
 //~^ ERROR unexpected token: `#`
 #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } }
 //~^ ERROR inclusive range with no end
-//~| ERROR expected one of `=>`, `if`, or `|`, found `#`
+//~| ERROR expected one of `,`, `=>`, `if`, `|`, or `}`, found `#`
 
 #[cfg(FALSE)] fn e() { let _ = x.#![attr]foo(); }
 //~^ ERROR unexpected token: `#`
diff --git a/tests/ui/parser/attribute/attr-stmt-expr-attr-bad.stderr b/tests/ui/parser/attribute/attr-stmt-expr-attr-bad.stderr
index e46c591080d..a0e95c5c1ed 100644
--- a/tests/ui/parser/attribute/attr-stmt-expr-attr-bad.stderr
+++ b/tests/ui/parser/attribute/attr-stmt-expr-attr-bad.stderr
@@ -365,11 +365,11 @@ LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } }
    |
    = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
 
-error: expected one of `=>`, `if`, or `|`, found `#`
+error: expected one of `,`, `=>`, `if`, `|`, or `}`, found `#`
   --> $DIR/attr-stmt-expr-attr-bad.rs:85:38
    |
 LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } }
-   |                                      ^ expected one of `=>`, `if`, or `|`
+   |                                      ^ expected one of `,`, `=>`, `if`, `|`, or `}`
 
 error[E0586]: inclusive range with no end
   --> $DIR/attr-stmt-expr-attr-bad.rs:88:35
@@ -379,11 +379,11 @@ LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } }
    |
    = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
 
-error: expected one of `=>`, `if`, or `|`, found `#`
+error: expected one of `,`, `=>`, `if`, `|`, or `}`, found `#`
   --> $DIR/attr-stmt-expr-attr-bad.rs:88:38
    |
 LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } }
-   |                                      ^ expected one of `=>`, `if`, or `|`
+   |                                      ^ expected one of `,`, `=>`, `if`, `|`, or `}`
 
 error: unexpected token: `#`
   --> $DIR/attr-stmt-expr-attr-bad.rs:91:39
@@ -399,11 +399,11 @@ LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } }
    |
    = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
 
-error: expected one of `=>`, `if`, or `|`, found `#`
+error: expected one of `,`, `=>`, `if`, `|`, or `}`, found `#`
   --> $DIR/attr-stmt-expr-attr-bad.rs:93:38
    |
 LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } }
-   |                                      ^ expected one of `=>`, `if`, or `|`
+   |                                      ^ expected one of `,`, `=>`, `if`, `|`, or `}`
 
 error: unexpected token: `#`
   --> $DIR/attr-stmt-expr-attr-bad.rs:97:34
diff --git a/tests/ui/parser/issues/issue-24375.rs b/tests/ui/parser/issues/issue-24375.rs
index 1d128d33e4f..8d1bc579e7b 100644
--- a/tests/ui/parser/issues/issue-24375.rs
+++ b/tests/ui/parser/issues/issue-24375.rs
@@ -3,7 +3,7 @@ static tmp : [&'static str; 2]  = ["hello", "he"];
 fn main() {
     let z = "hello";
     match z {
-        tmp[0] => {} //~ ERROR expected one of `=>`, `@`, `if`, or `|`, found `[`
+        tmp[0] => {} //~ ERROR expected one of `,`, `=>`, `@`, `if`, `|`, or `}`, found `[`
         _ => {}
     }
 }
diff --git a/tests/ui/parser/issues/issue-24375.stderr b/tests/ui/parser/issues/issue-24375.stderr
index bb1e19e9e6d..2b980a5520f 100644
--- a/tests/ui/parser/issues/issue-24375.stderr
+++ b/tests/ui/parser/issues/issue-24375.stderr
@@ -1,8 +1,8 @@
-error: expected one of `=>`, `@`, `if`, or `|`, found `[`
+error: expected one of `,`, `=>`, `@`, `if`, `|`, or `}`, found `[`
   --> $DIR/issue-24375.rs:6:12
    |
 LL |         tmp[0] => {}
-   |            ^ expected one of `=>`, `@`, `if`, or `|`
+   |            ^ expected one of `,`, `=>`, `@`, `if`, `|`, or `}`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/parser/macro/macro-expand-to-match-arm.rs b/tests/ui/parser/macro/macro-expand-to-match-arm.rs
index 39d1d065ed9..972ca61cc84 100644
--- a/tests/ui/parser/macro/macro-expand-to-match-arm.rs
+++ b/tests/ui/parser/macro/macro-expand-to-match-arm.rs
@@ -1,6 +1,8 @@
 macro_rules! arm {
     ($pattern:pat => $block:block) => {
         $pattern => $block
+        //~^ ERROR macro expansion ignores token `=>` and any following
+        //~| NOTE the usage of `arm!` is likely invalid in pattern context
     };
 }
 
@@ -9,9 +11,7 @@ fn main() {
     match x {
         Some(1) => {},
         arm!(None => {}),
-        //~^ NOTE macros cannot expand to match arms
-        //~| ERROR unexpected `,` in pattern
-        // doesn't recover
+        //~^ NOTE caused by the macro expansion here
         Some(2) => {},
         _ => {},
     };
diff --git a/tests/ui/parser/macro/macro-expand-to-match-arm.stderr b/tests/ui/parser/macro/macro-expand-to-match-arm.stderr
index 1b34d2d12b2..a62109c5050 100644
--- a/tests/ui/parser/macro/macro-expand-to-match-arm.stderr
+++ b/tests/ui/parser/macro/macro-expand-to-match-arm.stderr
@@ -1,10 +1,13 @@
-error: unexpected `,` in pattern
-  --> $DIR/macro-expand-to-match-arm.rs:11:25
+error: macro expansion ignores token `=>` and any following
+  --> $DIR/macro-expand-to-match-arm.rs:3:18
    |
+LL |         $pattern => $block
+   |                  ^^
+...
 LL |         arm!(None => {}),
-   |                         ^
+   |         ---------------- caused by the macro expansion here
    |
-   = note: macros cannot expand to match arms
+   = note: the usage of `arm!` is likely invalid in pattern context
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/parser/match-arm-without-body.rs b/tests/ui/parser/match-arm-without-body.rs
index 5f009c7a355..c33bd0c3031 100644
--- a/tests/ui/parser/match-arm-without-body.rs
+++ b/tests/ui/parser/match-arm-without-body.rs
@@ -6,7 +6,6 @@ fn main() {
     match Some(false) {
         Some(_)
     }
-    //~^ ERROR expected one of
     match Some(false) {
         Some(_)
         _ => {}
@@ -28,7 +27,6 @@ fn main() {
     match Some(false) {
         Some(_) if true
     }
-    //~^ ERROR expected one of
     match Some(false) {
         Some(_) if true
         _ => {}
@@ -36,33 +34,28 @@ fn main() {
     }
     match Some(false) {
         Some(_) if true,
-        //~^ ERROR expected one of
     }
     match Some(false) {
         Some(_) if true,
-        //~^ ERROR expected one of
         _ => {}
     }
     match Some(false) {
         pat!()
     }
-    //~^ ERROR expected one of
     match Some(false) {
         pat!(),
-        //~^ ERROR unexpected `,` in pattern
     }
     match Some(false) {
         pat!() if true,
-        //~^ ERROR expected one of
     }
     match Some(false) {
         pat!()
+        //~^ ERROR expected `,` following `match` arm
+        //~| HELP missing a comma here
         _ => {}
-        //~^ ERROR expected one of
     }
     match Some(false) {
         pat!(),
-        //~^ ERROR unexpected `,` in pattern
         _ => {}
     }
 }
diff --git a/tests/ui/parser/match-arm-without-body.stderr b/tests/ui/parser/match-arm-without-body.stderr
index 210007628db..77fd9176633 100644
--- a/tests/ui/parser/match-arm-without-body.stderr
+++ b/tests/ui/parser/match-arm-without-body.stderr
@@ -1,21 +1,13 @@
-error: expected one of `=>`, `if`, or `|`, found `}`
-  --> $DIR/match-arm-without-body.rs:8:5
+error: expected one of `,`, `=>`, `if`, `|`, or `}`, found reserved identifier `_`
+  --> $DIR/match-arm-without-body.rs:11:9
    |
 LL |         Some(_)
-   |                - expected one of `=>`, `if`, or `|`
-LL |     }
-   |     ^ unexpected token
-
-error: expected one of `=>`, `if`, or `|`, found reserved identifier `_`
-  --> $DIR/match-arm-without-body.rs:12:9
-   |
-LL |         Some(_)
-   |                - expected one of `=>`, `if`, or `|`
+   |                - expected one of `,`, `=>`, `if`, `|`, or `}`
 LL |         _ => {}
    |         ^ unexpected token
 
 error: unexpected `,` in pattern
-  --> $DIR/match-arm-without-body.rs:16:16
+  --> $DIR/match-arm-without-body.rs:15:16
    |
 LL |         Some(_),
    |                ^
@@ -30,7 +22,7 @@ LL |         Some(_) |
    |
 
 error: unexpected `,` in pattern
-  --> $DIR/match-arm-without-body.rs:22:16
+  --> $DIR/match-arm-without-body.rs:21:16
    |
 LL |         Some(_),
    |                ^
@@ -52,71 +44,19 @@ LL +
 LL ~         _ => {}
    |
 
-error: expected one of `.`, `=>`, `?`, or an operator, found `}`
-  --> $DIR/match-arm-without-body.rs:30:5
+error: expected one of `,`, `.`, `=>`, `?`, `}`, or an operator, found reserved identifier `_`
+  --> $DIR/match-arm-without-body.rs:32:9
    |
 LL |         Some(_) if true
-   |                        - expected one of `.`, `=>`, `?`, or an operator
-LL |     }
-   |     ^ unexpected token
-
-error: expected one of `.`, `=>`, `?`, or an operator, found reserved identifier `_`
-  --> $DIR/match-arm-without-body.rs:34:9
-   |
-LL |         Some(_) if true
-   |                        - expected one of `.`, `=>`, `?`, or an operator
+   |                        - expected one of `,`, `.`, `=>`, `?`, `}`, or an operator
 LL |         _ => {}
    |         ^ unexpected token
 
-error: expected one of `.`, `=>`, `?`, or an operator, found `,`
-  --> $DIR/match-arm-without-body.rs:38:24
-   |
-LL |         Some(_) if true,
-   |                        ^ expected one of `.`, `=>`, `?`, or an operator
-
-error: expected one of `.`, `=>`, `?`, or an operator, found `,`
-  --> $DIR/match-arm-without-body.rs:42:24
-   |
-LL |         Some(_) if true,
-   |                        ^ expected one of `.`, `=>`, `?`, or an operator
-
-error: expected one of `=>`, `if`, or `|`, found `}`
-  --> $DIR/match-arm-without-body.rs:48:5
+error: expected `,` following `match` arm
+  --> $DIR/match-arm-without-body.rs:52:15
    |
 LL |         pat!()
-   |               - expected one of `=>`, `if`, or `|`
-LL |     }
-   |     ^ unexpected token
-
-error: unexpected `,` in pattern
-  --> $DIR/match-arm-without-body.rs:51:15
-   |
-LL |         pat!(),
-   |               ^
-   |
-   = note: macros cannot expand to match arms
-
-error: expected one of `.`, `=>`, `?`, or an operator, found `,`
-  --> $DIR/match-arm-without-body.rs:55:23
-   |
-LL |         pat!() if true,
-   |                       ^ expected one of `.`, `=>`, `?`, or an operator
-
-error: expected one of `=>`, `if`, or `|`, found reserved identifier `_`
-  --> $DIR/match-arm-without-body.rs:60:9
-   |
-LL |         pat!()
-   |               - expected one of `=>`, `if`, or `|`
-LL |         _ => {}
-   |         ^ unexpected token
-
-error: unexpected `,` in pattern
-  --> $DIR/match-arm-without-body.rs:64:15
-   |
-LL |         pat!(),
-   |               ^
-   |
-   = note: macros cannot expand to match arms
+   |               ^ help: missing a comma here to end this `match` arm: `,`
 
-error: aborting due to 13 previous errors
+error: aborting due to 5 previous errors
 
diff --git a/tests/ui/parser/pat-lt-bracket-1.rs b/tests/ui/parser/pat-lt-bracket-1.rs
index 2e2001434f2..33da15adb9e 100644
--- a/tests/ui/parser/pat-lt-bracket-1.rs
+++ b/tests/ui/parser/pat-lt-bracket-1.rs
@@ -1,7 +1,7 @@
 fn main() {
   match 42 {
     x < 7 => (),
-   //~^ error: expected one of `=>`, `@`, `if`, or `|`, found `<`
+   //~^ error: expected one of `,`, `=>`, `@`, `if`, `|`, or `}`, found `<`
     _ => ()
   }
 }
diff --git a/tests/ui/parser/pat-lt-bracket-1.stderr b/tests/ui/parser/pat-lt-bracket-1.stderr
index 14e679bbee0..f39487052ad 100644
--- a/tests/ui/parser/pat-lt-bracket-1.stderr
+++ b/tests/ui/parser/pat-lt-bracket-1.stderr
@@ -1,8 +1,8 @@
-error: expected one of `=>`, `@`, `if`, or `|`, found `<`
+error: expected one of `,`, `=>`, `@`, `if`, `|`, or `}`, found `<`
   --> $DIR/pat-lt-bracket-1.rs:3:7
    |
 LL |     x < 7 => (),
-   |       ^ expected one of `=>`, `@`, `if`, or `|`
+   |       ^ expected one of `,`, `=>`, `@`, `if`, `|`, or `}`
 
 error: aborting due to 1 previous error