about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/issues/issue-39848.rs2
-rw-r--r--tests/ui/issues/issue-39848.stderr2
-rw-r--r--tests/ui/macros/nonterminal-matching.stderr2
-rw-r--r--tests/ui/macros/syntax-error-recovery.rs2
-rw-r--r--tests/ui/macros/syntax-error-recovery.stderr2
-rw-r--r--tests/ui/macros/trace_faulty_macros.rs11
-rw-r--r--tests/ui/macros/trace_faulty_macros.stderr37
-rw-r--r--tests/ui/parser/float-field-interpolated.rs4
-rw-r--r--tests/ui/parser/float-field-interpolated.stderr4
9 files changed, 56 insertions, 10 deletions
diff --git a/tests/ui/issues/issue-39848.rs b/tests/ui/issues/issue-39848.rs
index 1964d739989..2a059120e81 100644
--- a/tests/ui/issues/issue-39848.rs
+++ b/tests/ui/issues/issue-39848.rs
@@ -1,6 +1,6 @@
 macro_rules! get_opt {
     ($tgt:expr, $field:ident) => {
-        if $tgt.has_$field() {} //~ ERROR expected `{`, found `foo`
+        if $tgt.has_$field() {} //~ ERROR expected `{`, found identifier `foo`
     }
 }
 
diff --git a/tests/ui/issues/issue-39848.stderr b/tests/ui/issues/issue-39848.stderr
index 387ef0776ff..f98fde43784 100644
--- a/tests/ui/issues/issue-39848.stderr
+++ b/tests/ui/issues/issue-39848.stderr
@@ -1,4 +1,4 @@
-error: expected `{`, found `foo`
+error: expected `{`, found identifier `foo`
   --> $DIR/issue-39848.rs:3:21
    |
 LL |         if $tgt.has_$field() {}
diff --git a/tests/ui/macros/nonterminal-matching.stderr b/tests/ui/macros/nonterminal-matching.stderr
index c2b047022ed..88c2c1c773d 100644
--- a/tests/ui/macros/nonterminal-matching.stderr
+++ b/tests/ui/macros/nonterminal-matching.stderr
@@ -1,6 +1,8 @@
 error: no rules expected the token `enum E {}`
   --> $DIR/nonterminal-matching.rs:19:10
    |
+LL | macro complex_nonterminal($nt_item: item) {
+   |                           --------------
 LL |     macro n(a $nt_item b) {
    |     --------------------- when calling this macro
 ...
diff --git a/tests/ui/macros/syntax-error-recovery.rs b/tests/ui/macros/syntax-error-recovery.rs
index ae6de3c5046..f6178c137db 100644
--- a/tests/ui/macros/syntax-error-recovery.rs
+++ b/tests/ui/macros/syntax-error-recovery.rs
@@ -9,7 +9,7 @@ macro_rules! values {
         }
     };
 }
-//~^^^^^ ERROR expected one of `(`, `,`, `=`, `{`, or `}`, found `(String)`
+//~^^^^^ ERROR expected one of `(`, `,`, `=`, `{`, or `}`, found type `(String)`
 //~| ERROR macro expansion ignores token `(String)` and any following
 
 values!(STRING(1) as (String) => cfg(test),);
diff --git a/tests/ui/macros/syntax-error-recovery.stderr b/tests/ui/macros/syntax-error-recovery.stderr
index c42ee9b295e..6218bf43a1e 100644
--- a/tests/ui/macros/syntax-error-recovery.stderr
+++ b/tests/ui/macros/syntax-error-recovery.stderr
@@ -1,4 +1,4 @@
-error: expected one of `(`, `,`, `=`, `{`, or `}`, found `(String)`
+error: expected one of `(`, `,`, `=`, `{`, or `}`, found type `(String)`
   --> $DIR/syntax-error-recovery.rs:7:26
    |
 LL |                 $token $($inner)? = $value,
diff --git a/tests/ui/macros/trace_faulty_macros.rs b/tests/ui/macros/trace_faulty_macros.rs
index b2fdd2e1965..00eb7593799 100644
--- a/tests/ui/macros/trace_faulty_macros.rs
+++ b/tests/ui/macros/trace_faulty_macros.rs
@@ -41,3 +41,14 @@ fn use_bang_macro_as_attr() {}
 
 #[derive(Debug)] //~ ERROR `derive` may only be applied to `struct`s
 fn use_derive_macro_as_attr() {}
+
+macro_rules! test {
+    (let $p:pat = $e:expr) => {test!(($p,$e))};
+    // this should be expr
+    //           vvv
+    (($p:pat, $e:pat)) => {let $p = $e;}; //~ ERROR expected expression, found pattern `1 + 1`
+}
+
+fn foo() {
+    test!(let x = 1+1);
+}
diff --git a/tests/ui/macros/trace_faulty_macros.stderr b/tests/ui/macros/trace_faulty_macros.stderr
index 21e47da0757..6a89d3bfd09 100644
--- a/tests/ui/macros/trace_faulty_macros.stderr
+++ b/tests/ui/macros/trace_faulty_macros.stderr
@@ -50,7 +50,7 @@ LL |     my_recursive_macro!();
    = note: expanding `my_recursive_macro! {  }`
    = note: to `my_recursive_macro! () ;`
 
-error: expected expression, found `A { a: a, b: 0, c: _, .. }`
+error: expected expression, found pattern `A { a: a, b: 0, c: _, .. }`
   --> $DIR/trace_faulty_macros.rs:16:9
    |
 LL |         $a
@@ -69,6 +69,28 @@ LL | #[derive(Debug)]
 LL | fn use_derive_macro_as_attr() {}
    | -------------------------------- not a `struct`, `enum` or `union`
 
+error: expected expression, found pattern `1 + 1`
+  --> $DIR/trace_faulty_macros.rs:49:37
+   |
+LL |     (let $p:pat = $e:expr) => {test!(($p,$e))};
+   |                   -------                -- this is interpreted as expression, but it is expected to be pattern
+   |                   |
+   |                   this macro fragment matcher is expression
+...
+LL |     (($p:pat, $e:pat)) => {let $p = $e;};
+   |               ------                ^^ expected expression
+   |               |
+   |               this macro fragment matcher is pattern
+...
+LL |     test!(let x = 1+1);
+   |     ------------------
+   |     |             |
+   |     |             this is expected to be expression
+   |     in this macro invocation
+   |
+   = note: when forwarding a matched fragment to another macro-by-example, matchers in the second macro will see an opaque AST of the fragment type, not the underlying tokens
+   = note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
+
 note: trace_macro
   --> $DIR/trace_faulty_macros.rs:36:13
    |
@@ -80,6 +102,17 @@ LL |     let a = pat_macro!();
    = note: expanding `pat_macro! { A { a : a, b : 0, c : _, .. } }`
    = note: to `A { a: a, b: 0, c: _, .. }`
 
-error: aborting due to 4 previous errors
+note: trace_macro
+  --> $DIR/trace_faulty_macros.rs:53:5
+   |
+LL |     test!(let x = 1+1);
+   |     ^^^^^^^^^^^^^^^^^^
+   |
+   = note: expanding `test! { let x = 1 + 1 }`
+   = note: to `test! ((x, 1 + 1))`
+   = note: expanding `test! { (x, 1 + 1) }`
+   = note: to `let x = 1 + 1 ;`
+
+error: aborting due to 5 previous errors
 
 For more information about this error, try `rustc --explain E0774`.
diff --git a/tests/ui/parser/float-field-interpolated.rs b/tests/ui/parser/float-field-interpolated.rs
index a3053203536..990f2926dc8 100644
--- a/tests/ui/parser/float-field-interpolated.rs
+++ b/tests/ui/parser/float-field-interpolated.rs
@@ -6,9 +6,9 @@ macro_rules! generate_field_accesses {
 
         s.$a; // OK
         { s.$b; } //~ ERROR unexpected token: `1.1`
-                  //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `1.1`
+                  //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found literal `1.1`
         { s.$c; } //~ ERROR unexpected token: `1.1`
-                  //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `1.1`
+                  //~| ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found expression `1.1`
     };
 }
 
diff --git a/tests/ui/parser/float-field-interpolated.stderr b/tests/ui/parser/float-field-interpolated.stderr
index 664adb35818..2a1a4926cb3 100644
--- a/tests/ui/parser/float-field-interpolated.stderr
+++ b/tests/ui/parser/float-field-interpolated.stderr
@@ -9,7 +9,7 @@ LL |     generate_field_accesses!(1.1, 1.1, 1.1);
    |
    = note: this error originates in the macro `generate_field_accesses` (in Nightly builds, run with -Z macro-backtrace for more info)
 
-error: expected one of `.`, `;`, `?`, `}`, or an operator, found `1.1`
+error: expected one of `.`, `;`, `?`, `}`, or an operator, found literal `1.1`
   --> $DIR/float-field-interpolated.rs:8:13
    |
 LL |         { s.$b; }
@@ -31,7 +31,7 @@ LL |     generate_field_accesses!(1.1, 1.1, 1.1);
    |
    = note: this error originates in the macro `generate_field_accesses` (in Nightly builds, run with -Z macro-backtrace for more info)
 
-error: expected one of `.`, `;`, `?`, `}`, or an operator, found `1.1`
+error: expected one of `.`, `;`, `?`, `}`, or an operator, found expression `1.1`
   --> $DIR/float-field-interpolated.rs:10:13
    |
 LL |         { s.$c; }