about summary refs log tree commit diff
path: root/tests/ui/parser/macro
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/parser/macro')
-rw-r--r--tests/ui/parser/macro/break-in-unlabeled-block-in-macro.rs43
-rw-r--r--tests/ui/parser/macro/break-in-unlabeled-block-in-macro.stderr69
-rw-r--r--tests/ui/parser/macro/do-not-suggest-semicolon-between-macro-without-exclamation-mark-and-array.rs3
-rw-r--r--tests/ui/parser/macro/do-not-suggest-semicolon-between-macro-without-exclamation-mark-and-array.stderr8
-rw-r--r--tests/ui/parser/macro/extern-abi-from-mac-literal-frag.rs51
-rw-r--r--tests/ui/parser/macro/lit-err-in-macro.rs10
-rw-r--r--tests/ui/parser/macro/lit-err-in-macro.stderr20
-rw-r--r--tests/ui/parser/macro/macro-bad-delimiter-ident.rs3
-rw-r--r--tests/ui/parser/macro/macro-bad-delimiter-ident.stderr8
-rw-r--r--tests/ui/parser/macro/macro-bare-trait-object-maybe-trait-bound.rs (renamed from tests/ui/parser/macro/mbe-bare-trait-object-maybe-trait-bound.rs)0
-rw-r--r--tests/ui/parser/macro/macro-braces-dot-question.rs11
-rw-r--r--tests/ui/parser/macro/macro-dotdotdot-may-not-begin-a-type.rs (renamed from tests/ui/parser/macro/mbe-dotdotdot-may-not-begin-a-type.rs)0
-rw-r--r--tests/ui/parser/macro/macro-keyword.rs5
-rw-r--r--tests/ui/parser/macro/macro-keyword.stderr13
-rw-r--r--tests/ui/parser/macro/macro-mismatched-delim-brace-paren.rs7
-rw-r--r--tests/ui/parser/macro/macro-mismatched-delim-brace-paren.stderr11
-rw-r--r--tests/ui/parser/macro/macro-mismatched-delim-paren-brace.rs5
-rw-r--r--tests/ui/parser/macro/macro-mismatched-delim-paren-brace.stderr22
-rw-r--r--tests/ui/parser/macro/macro-missing-right-paren.rs3
-rw-r--r--tests/ui/parser/macro/macro-missing-right-paren.stderr10
-rw-r--r--tests/ui/parser/macro/macros-no-semicolon-items.rs15
-rw-r--r--tests/ui/parser/macro/macros-no-semicolon-items.stderr48
-rw-r--r--tests/ui/parser/macro/macros-no-semicolon.rs5
-rw-r--r--tests/ui/parser/macro/macros-no-semicolon.stderr18
-rw-r--r--tests/ui/parser/macro/misspelled-macro-rules.fixed13
-rw-r--r--tests/ui/parser/macro/misspelled-macro-rules.rs13
-rw-r--r--tests/ui/parser/macro/misspelled-macro-rules.stderr10
-rw-r--r--tests/ui/parser/macro/pub-method-macro.rs23
-rw-r--r--tests/ui/parser/macro/pub-method-macro.stderr15
-rw-r--r--tests/ui/parser/macro/semi-after-closure-in-macro.rs14
-rw-r--r--tests/ui/parser/macro/trailing-question-in-macro-type.rs14
-rw-r--r--tests/ui/parser/macro/trailing-question-in-macro-type.stderr9
32 files changed, 499 insertions, 0 deletions
diff --git a/tests/ui/parser/macro/break-in-unlabeled-block-in-macro.rs b/tests/ui/parser/macro/break-in-unlabeled-block-in-macro.rs
new file mode 100644
index 00000000000..eecc0026b12
--- /dev/null
+++ b/tests/ui/parser/macro/break-in-unlabeled-block-in-macro.rs
@@ -0,0 +1,43 @@
+macro_rules! foo {
+    () => {
+        break (); //~ ERROR `break` outside of a loop or labeled block
+    };
+    ($e: expr) => {
+        break $e; //~ ERROR `break` outside of a loop or labeled block
+    };
+    (stmt $s: stmt) => {
+        $s
+    };
+    (@ $e: expr) => {
+        { break $e; } //~ ERROR `break` outside of a loop or labeled block
+    };
+    (=> $s: stmt) => {
+        { $s }
+    };
+}
+
+fn main() {
+    {
+        foo!();
+    }
+    {
+        foo!(());
+    }
+    {
+        foo!(stmt break ()); //~ ERROR `break` outside of a loop or labeled block
+    }
+    {
+        foo!(@ ());
+    }
+    {
+        foo!(=> break ()); //~ ERROR `break` outside of a loop or labeled block
+    }
+    {
+        macro_rules! bar {
+            () => {
+                break () //~ ERROR `break` outside of a loop or labeled block
+            };
+        }
+        bar!()
+    }
+}
diff --git a/tests/ui/parser/macro/break-in-unlabeled-block-in-macro.stderr b/tests/ui/parser/macro/break-in-unlabeled-block-in-macro.stderr
new file mode 100644
index 00000000000..2f46cb36750
--- /dev/null
+++ b/tests/ui/parser/macro/break-in-unlabeled-block-in-macro.stderr
@@ -0,0 +1,69 @@
+error[E0268]: `break` outside of a loop or labeled block
+  --> $DIR/break-in-unlabeled-block-in-macro.rs:3:9
+   |
+LL |         break ();
+   |         ^^^^^^^^ cannot `break` outside of a loop or labeled block
+...
+LL |         foo!();
+   |         ------ in this macro invocation
+   |
+   = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0268]: `break` outside of a loop or labeled block
+  --> $DIR/break-in-unlabeled-block-in-macro.rs:6:9
+   |
+LL |         break $e;
+   |         ^^^^^^^^ cannot `break` outside of a loop or labeled block
+...
+LL |         foo!(());
+   |         -------- in this macro invocation
+   |
+   = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0268]: `break` outside of a loop or labeled block
+  --> $DIR/break-in-unlabeled-block-in-macro.rs:33:17
+   |
+LL |         foo!(=> break ());
+   |                 ^^^^^^^^ cannot `break` outside of a loop or labeled block
+
+error[E0268]: `break` outside of a loop or labeled block
+  --> $DIR/break-in-unlabeled-block-in-macro.rs:38:17
+   |
+LL |                 break ()
+   |                 ^^^^^^^^ cannot `break` outside of a loop or labeled block
+...
+LL |         bar!()
+   |         ------ in this macro invocation
+   |
+   = note: this error originates in the macro `bar` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0268]: `break` outside of a loop or labeled block
+  --> $DIR/break-in-unlabeled-block-in-macro.rs:12:11
+   |
+LL |         { break $e; }
+   |           ^^^^^^^^ cannot `break` outside of a loop or labeled block
+...
+LL |         foo!(@ ());
+   |         ---------- in this macro invocation
+   |
+   = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: consider labeling this block to be able to break within it
+   |
+LL |         'block: { break 'block $e; }
+   |         +++++++         ++++++
+
+error[E0268]: `break` outside of a loop or labeled block
+  --> $DIR/break-in-unlabeled-block-in-macro.rs:27:19
+   |
+LL |         foo!(stmt break ());
+   |                   ^^^^^^^^ cannot `break` outside of a loop or labeled block
+   |
+help: consider labeling this block to be able to break within it
+   |
+LL ~     'block: {
+LL ~         foo!(stmt break 'block ());
+   |
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0268`.
diff --git a/tests/ui/parser/macro/do-not-suggest-semicolon-between-macro-without-exclamation-mark-and-array.rs b/tests/ui/parser/macro/do-not-suggest-semicolon-between-macro-without-exclamation-mark-and-array.rs
new file mode 100644
index 00000000000..d6f7981813f
--- /dev/null
+++ b/tests/ui/parser/macro/do-not-suggest-semicolon-between-macro-without-exclamation-mark-and-array.rs
@@ -0,0 +1,3 @@
+fn main() {
+    let _x = vec[1, 2, 3]; //~ ERROR expected one of `.`, `?`, `]`, or an operator
+}
diff --git a/tests/ui/parser/macro/do-not-suggest-semicolon-between-macro-without-exclamation-mark-and-array.stderr b/tests/ui/parser/macro/do-not-suggest-semicolon-between-macro-without-exclamation-mark-and-array.stderr
new file mode 100644
index 00000000000..2796312f4ad
--- /dev/null
+++ b/tests/ui/parser/macro/do-not-suggest-semicolon-between-macro-without-exclamation-mark-and-array.stderr
@@ -0,0 +1,8 @@
+error: expected one of `.`, `?`, `]`, or an operator, found `,`
+  --> $DIR/do-not-suggest-semicolon-between-macro-without-exclamation-mark-and-array.rs:2:19
+   |
+LL |     let _x = vec[1, 2, 3];
+   |                   ^ expected one of `.`, `?`, `]`, or an operator
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/parser/macro/extern-abi-from-mac-literal-frag.rs b/tests/ui/parser/macro/extern-abi-from-mac-literal-frag.rs
new file mode 100644
index 00000000000..12b6c98705c
--- /dev/null
+++ b/tests/ui/parser/macro/extern-abi-from-mac-literal-frag.rs
@@ -0,0 +1,51 @@
+#![allow(clashing_extern_declarations)]
+//@ check-pass
+
+// In this test we check that the parser accepts an ABI string when it
+// comes from a macro `literal` or `expr` fragment as opposed to a hardcoded string.
+
+fn main() {}
+
+macro_rules! abi_from_lit_frag {
+    ($abi:literal) => {
+        extern $abi {
+            fn _import();
+        }
+
+        unsafe extern $abi {}
+
+        extern $abi fn _export() {}
+
+        type _PTR = extern $abi fn();
+    }
+}
+
+macro_rules! abi_from_expr_frag {
+    ($abi:expr) => {
+        extern $abi {
+            fn _import();
+        }
+
+        unsafe extern $abi {}
+
+        extern $abi fn _export() {}
+
+        type _PTR = extern $abi fn();
+    };
+}
+
+mod rust {
+    abi_from_lit_frag!("Rust");
+}
+
+mod c {
+    abi_from_lit_frag!("C");
+}
+
+mod rust_expr {
+    abi_from_expr_frag!("Rust");
+}
+
+mod c_expr {
+    abi_from_expr_frag!("C");
+}
diff --git a/tests/ui/parser/macro/lit-err-in-macro.rs b/tests/ui/parser/macro/lit-err-in-macro.rs
new file mode 100644
index 00000000000..ca117ac4a15
--- /dev/null
+++ b/tests/ui/parser/macro/lit-err-in-macro.rs
@@ -0,0 +1,10 @@
+macro_rules! f {
+    ($abi:literal) => {
+        extern $abi fn f() {} //~ WARN missing_abi
+    }
+}
+
+f!("Foo"__);
+//~^ ERROR suffixes on string literals are invalid
+
+fn main() {}
diff --git a/tests/ui/parser/macro/lit-err-in-macro.stderr b/tests/ui/parser/macro/lit-err-in-macro.stderr
new file mode 100644
index 00000000000..08fe58643d4
--- /dev/null
+++ b/tests/ui/parser/macro/lit-err-in-macro.stderr
@@ -0,0 +1,20 @@
+error: suffixes on string literals are invalid
+  --> $DIR/lit-err-in-macro.rs:7:4
+   |
+LL | f!("Foo"__);
+   |    ^^^^^^^ invalid suffix `__`
+
+warning: `extern` declarations without an explicit ABI are deprecated
+  --> $DIR/lit-err-in-macro.rs:3:9
+   |
+LL |         extern $abi fn f() {}
+   |         ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"`
+...
+LL | f!("Foo"__);
+   | ----------- in this macro invocation
+   |
+   = note: `#[warn(missing_abi)]` on by default
+   = note: this warning originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 1 previous error; 1 warning emitted
+
diff --git a/tests/ui/parser/macro/macro-bad-delimiter-ident.rs b/tests/ui/parser/macro/macro-bad-delimiter-ident.rs
new file mode 100644
index 00000000000..f461f06b4dc
--- /dev/null
+++ b/tests/ui/parser/macro/macro-bad-delimiter-ident.rs
@@ -0,0 +1,3 @@
+fn main() {
+    foo! bar < //~ ERROR expected one of `(`, `[`, or `{`, found `bar`
+}
diff --git a/tests/ui/parser/macro/macro-bad-delimiter-ident.stderr b/tests/ui/parser/macro/macro-bad-delimiter-ident.stderr
new file mode 100644
index 00000000000..06f72cdecf2
--- /dev/null
+++ b/tests/ui/parser/macro/macro-bad-delimiter-ident.stderr
@@ -0,0 +1,8 @@
+error: expected one of `(`, `[`, or `{`, found `bar`
+  --> $DIR/macro-bad-delimiter-ident.rs:2:10
+   |
+LL |     foo! bar <
+   |          ^^^ expected one of `(`, `[`, or `{`
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/parser/macro/mbe-bare-trait-object-maybe-trait-bound.rs b/tests/ui/parser/macro/macro-bare-trait-object-maybe-trait-bound.rs
index 494e58c1ca5..494e58c1ca5 100644
--- a/tests/ui/parser/macro/mbe-bare-trait-object-maybe-trait-bound.rs
+++ b/tests/ui/parser/macro/macro-bare-trait-object-maybe-trait-bound.rs
diff --git a/tests/ui/parser/macro/macro-braces-dot-question.rs b/tests/ui/parser/macro/macro-braces-dot-question.rs
new file mode 100644
index 00000000000..9b070f201b5
--- /dev/null
+++ b/tests/ui/parser/macro/macro-braces-dot-question.rs
@@ -0,0 +1,11 @@
+//@ check-pass
+
+use std::io::Write;
+
+fn main() -> Result<(), std::io::Error> {
+    vec! { 1, 2, 3 }.len();
+    write! { vec![], "" }?;
+    println!{""}
+    [0]; // separate statement, not indexing into the result of println.
+    Ok(())
+}
diff --git a/tests/ui/parser/macro/mbe-dotdotdot-may-not-begin-a-type.rs b/tests/ui/parser/macro/macro-dotdotdot-may-not-begin-a-type.rs
index 8be99f22d2e..8be99f22d2e 100644
--- a/tests/ui/parser/macro/mbe-dotdotdot-may-not-begin-a-type.rs
+++ b/tests/ui/parser/macro/macro-dotdotdot-may-not-begin-a-type.rs
diff --git a/tests/ui/parser/macro/macro-keyword.rs b/tests/ui/parser/macro/macro-keyword.rs
new file mode 100644
index 00000000000..58489fb2c51
--- /dev/null
+++ b/tests/ui/parser/macro/macro-keyword.rs
@@ -0,0 +1,5 @@
+fn macro() {  //~ ERROR expected identifier, found reserved keyword `macro`
+}
+
+pub fn main() {
+}
diff --git a/tests/ui/parser/macro/macro-keyword.stderr b/tests/ui/parser/macro/macro-keyword.stderr
new file mode 100644
index 00000000000..bfe89e320e0
--- /dev/null
+++ b/tests/ui/parser/macro/macro-keyword.stderr
@@ -0,0 +1,13 @@
+error: expected identifier, found reserved keyword `macro`
+  --> $DIR/macro-keyword.rs:1:4
+   |
+LL | fn macro() {
+   |    ^^^^^ expected identifier, found reserved keyword
+   |
+help: escape `macro` to use it as an identifier
+   |
+LL | fn r#macro() {
+   |    ++
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/parser/macro/macro-mismatched-delim-brace-paren.rs b/tests/ui/parser/macro/macro-mismatched-delim-brace-paren.rs
new file mode 100644
index 00000000000..404aa7b806a
--- /dev/null
+++ b/tests/ui/parser/macro/macro-mismatched-delim-brace-paren.rs
@@ -0,0 +1,7 @@
+macro_rules! foo { ($($tt:tt)*) => () }
+
+fn main() {
+    foo! {
+        bar, "baz", 1, 2.0
+    ) //~ ERROR mismatched closing delimiter
+}
diff --git a/tests/ui/parser/macro/macro-mismatched-delim-brace-paren.stderr b/tests/ui/parser/macro/macro-mismatched-delim-brace-paren.stderr
new file mode 100644
index 00000000000..f9a3072229f
--- /dev/null
+++ b/tests/ui/parser/macro/macro-mismatched-delim-brace-paren.stderr
@@ -0,0 +1,11 @@
+error: mismatched closing delimiter: `)`
+  --> $DIR/macro-mismatched-delim-brace-paren.rs:4:10
+   |
+LL |     foo! {
+   |          ^ unclosed delimiter
+LL |         bar, "baz", 1, 2.0
+LL |     )
+   |     ^ mismatched closing delimiter
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/parser/macro/macro-mismatched-delim-paren-brace.rs b/tests/ui/parser/macro/macro-mismatched-delim-paren-brace.rs
new file mode 100644
index 00000000000..1a1b9edfbcb
--- /dev/null
+++ b/tests/ui/parser/macro/macro-mismatched-delim-paren-brace.rs
@@ -0,0 +1,5 @@
+fn main() {
+    foo! (
+        bar, "baz", 1, 2.0
+    } //~ ERROR mismatched closing delimiter
+} //~ ERROR unexpected closing delimiter: `}`
diff --git a/tests/ui/parser/macro/macro-mismatched-delim-paren-brace.stderr b/tests/ui/parser/macro/macro-mismatched-delim-paren-brace.stderr
new file mode 100644
index 00000000000..34217e21ae9
--- /dev/null
+++ b/tests/ui/parser/macro/macro-mismatched-delim-paren-brace.stderr
@@ -0,0 +1,22 @@
+error: mismatched closing delimiter: `}`
+  --> $DIR/macro-mismatched-delim-paren-brace.rs:2:10
+   |
+LL |     foo! (
+   |          ^ unclosed delimiter
+LL |         bar, "baz", 1, 2.0
+LL |     }
+   |     ^ mismatched closing delimiter
+
+error: unexpected closing delimiter: `}`
+  --> $DIR/macro-mismatched-delim-paren-brace.rs:5:1
+   |
+LL | fn main() {
+   |           - this delimiter might not be properly closed...
+...
+LL |     }
+   |     - ...as it matches this but it has different indentation
+LL | }
+   | ^ unexpected closing delimiter
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/parser/macro/macro-missing-right-paren.rs b/tests/ui/parser/macro/macro-missing-right-paren.rs
new file mode 100644
index 00000000000..85191931664
--- /dev/null
+++ b/tests/ui/parser/macro/macro-missing-right-paren.rs
@@ -0,0 +1,3 @@
+// ignore-tidy-trailing-newlines
+//~v ERROR this file contains an unclosed delimiter
+macro_rules! abc(ؼ
\ No newline at end of file
diff --git a/tests/ui/parser/macro/macro-missing-right-paren.stderr b/tests/ui/parser/macro/macro-missing-right-paren.stderr
new file mode 100644
index 00000000000..285f14830ce
--- /dev/null
+++ b/tests/ui/parser/macro/macro-missing-right-paren.stderr
@@ -0,0 +1,10 @@
+error: this file contains an unclosed delimiter
+  --> $DIR/macro-missing-right-paren.rs:3:19
+   |
+LL | macro_rules! abc(ؼ
+   |                 - ^
+   |                 |
+   |                 unclosed delimiter
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/parser/macro/macros-no-semicolon-items.rs b/tests/ui/parser/macro/macros-no-semicolon-items.rs
new file mode 100644
index 00000000000..86889279cea
--- /dev/null
+++ b/tests/ui/parser/macro/macros-no-semicolon-items.rs
@@ -0,0 +1,15 @@
+macro_rules! foo()  //~ ERROR semicolon
+                    //~| ERROR macros must contain at least one rule
+
+macro_rules! bar {
+    ($($tokens:tt)*) => {}
+}
+
+bar!( //~ ERROR semicolon
+    blah
+    blah
+    blah
+)
+
+fn main() {
+}
diff --git a/tests/ui/parser/macro/macros-no-semicolon-items.stderr b/tests/ui/parser/macro/macros-no-semicolon-items.stderr
new file mode 100644
index 00000000000..f8f3ed83688
--- /dev/null
+++ b/tests/ui/parser/macro/macros-no-semicolon-items.stderr
@@ -0,0 +1,48 @@
+error: macros that expand to items must be delimited with braces or followed by a semicolon
+  --> $DIR/macros-no-semicolon-items.rs:1:17
+   |
+LL | macro_rules! foo()
+   |                 ^^
+   |
+help: change the delimiters to curly braces
+   |
+LL - macro_rules! foo()
+LL + macro_rules! foo{}
+   |
+help: add a semicolon
+   |
+LL | macro_rules! foo();
+   |                   +
+
+error: macros that expand to items must be delimited with braces or followed by a semicolon
+  --> $DIR/macros-no-semicolon-items.rs:8:5
+   |
+LL |   bar!(
+   |  _____^
+LL | |     blah
+LL | |     blah
+LL | |     blah
+LL | | )
+   | |_^
+   |
+help: change the delimiters to curly braces
+   |
+LL ~ bar!{
+LL |     blah
+LL |     blah
+LL |     blah
+LL + }
+   |
+help: add a semicolon
+   |
+LL | );
+   |  +
+
+error: macros must contain at least one rule
+  --> $DIR/macros-no-semicolon-items.rs:1:1
+   |
+LL | macro_rules! foo()
+   | ^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 3 previous errors
+
diff --git a/tests/ui/parser/macro/macros-no-semicolon.rs b/tests/ui/parser/macro/macros-no-semicolon.rs
new file mode 100644
index 00000000000..24d1ae9e623
--- /dev/null
+++ b/tests/ui/parser/macro/macros-no-semicolon.rs
@@ -0,0 +1,5 @@
+fn main() {
+    assert_eq!(1, 2) //~ ERROR: expected `;`
+    assert_eq!(3, 4) //~ ERROR: expected `;`
+    println!("hello");
+}
diff --git a/tests/ui/parser/macro/macros-no-semicolon.stderr b/tests/ui/parser/macro/macros-no-semicolon.stderr
new file mode 100644
index 00000000000..f310662dbb0
--- /dev/null
+++ b/tests/ui/parser/macro/macros-no-semicolon.stderr
@@ -0,0 +1,18 @@
+error: expected `;`, found `assert_eq`
+  --> $DIR/macros-no-semicolon.rs:2:21
+   |
+LL |     assert_eq!(1, 2)
+   |                     ^ help: add `;` here
+LL |     assert_eq!(3, 4)
+   |     --------- unexpected token
+
+error: expected `;`, found `println`
+  --> $DIR/macros-no-semicolon.rs:3:21
+   |
+LL |     assert_eq!(3, 4)
+   |                     ^ help: add `;` here
+LL |     println!("hello");
+   |     ------- unexpected token
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/parser/macro/misspelled-macro-rules.fixed b/tests/ui/parser/macro/misspelled-macro-rules.fixed
new file mode 100644
index 00000000000..7471a5641c2
--- /dev/null
+++ b/tests/ui/parser/macro/misspelled-macro-rules.fixed
@@ -0,0 +1,13 @@
+// Regression test for issue #91227.
+
+//@ run-rustfix
+
+#![allow(unused_macros)]
+
+macro_rules! thing {
+//~^ ERROR: expected one of
+//~| HELP: perhaps you meant to define a macro
+    () => {}
+}
+
+fn main() {}
diff --git a/tests/ui/parser/macro/misspelled-macro-rules.rs b/tests/ui/parser/macro/misspelled-macro-rules.rs
new file mode 100644
index 00000000000..8f63f37d3d3
--- /dev/null
+++ b/tests/ui/parser/macro/misspelled-macro-rules.rs
@@ -0,0 +1,13 @@
+// Regression test for issue #91227.
+
+//@ run-rustfix
+
+#![allow(unused_macros)]
+
+marco_rules! thing {
+//~^ ERROR: expected one of
+//~| HELP: perhaps you meant to define a macro
+    () => {}
+}
+
+fn main() {}
diff --git a/tests/ui/parser/macro/misspelled-macro-rules.stderr b/tests/ui/parser/macro/misspelled-macro-rules.stderr
new file mode 100644
index 00000000000..fc718d8556d
--- /dev/null
+++ b/tests/ui/parser/macro/misspelled-macro-rules.stderr
@@ -0,0 +1,10 @@
+error: expected one of `(`, `[`, or `{`, found `thing`
+  --> $DIR/misspelled-macro-rules.rs:7:14
+   |
+LL | marco_rules! thing {
+   | -----------  ^^^^^ expected one of `(`, `[`, or `{`
+   | |
+   | help: perhaps you meant to define a macro: `macro_rules`
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/parser/macro/pub-method-macro.rs b/tests/ui/parser/macro/pub-method-macro.rs
new file mode 100644
index 00000000000..0183bdcf622
--- /dev/null
+++ b/tests/ui/parser/macro/pub-method-macro.rs
@@ -0,0 +1,23 @@
+// Issue #18317
+
+mod bleh {
+    macro_rules! defn {
+        ($n:ident) => (
+            fn $n (&self) -> i32 {
+                println!("{}", stringify!($n));
+                1
+            }
+        )
+    }
+
+    #[derive(Copy, Clone)]
+    pub struct S;
+
+    impl S {
+        pub defn!(f); //~ ERROR can't qualify macro invocation with `pub`
+        //~^ HELP remove the visibility
+        //~| HELP try adjusting the macro to put `pub` inside the invocation
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/parser/macro/pub-method-macro.stderr b/tests/ui/parser/macro/pub-method-macro.stderr
new file mode 100644
index 00000000000..2e2c30dc6ad
--- /dev/null
+++ b/tests/ui/parser/macro/pub-method-macro.stderr
@@ -0,0 +1,15 @@
+error: can't qualify macro invocation with `pub`
+  --> $DIR/pub-method-macro.rs:17:9
+   |
+LL |         pub defn!(f);
+   |         ^^^
+   |
+   = help: try adjusting the macro to put `pub` inside the invocation
+help: remove the visibility
+   |
+LL -         pub defn!(f);
+LL +          defn!(f);
+   |
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/parser/macro/semi-after-closure-in-macro.rs b/tests/ui/parser/macro/semi-after-closure-in-macro.rs
new file mode 100644
index 00000000000..1eeb04b8833
--- /dev/null
+++ b/tests/ui/parser/macro/semi-after-closure-in-macro.rs
@@ -0,0 +1,14 @@
+//@ check-pass
+
+// Checks that the fix in #103222 doesn't also disqualify semicolons after
+// closures within parentheses *in macros*, where they're totally allowed.
+
+macro_rules! m {
+    (($expr:expr ; )) => {
+        $expr
+    };
+}
+
+fn main() {
+    let x = m!(( ||() ; ));
+}
diff --git a/tests/ui/parser/macro/trailing-question-in-macro-type.rs b/tests/ui/parser/macro/trailing-question-in-macro-type.rs
new file mode 100644
index 00000000000..e2a681ddd11
--- /dev/null
+++ b/tests/ui/parser/macro/trailing-question-in-macro-type.rs
@@ -0,0 +1,14 @@
+macro_rules! fn_expr {
+    ($return_type:ty : $body:expr) => {
+        (|| -> $return_type { $body })()
+    };
+    ($body:expr) => {
+        (|| $body)()
+    };
+}
+
+
+fn main() {
+    fn_expr!{ o?.when(|&i| i > 0)?.when(|&i| i%2 == 0) };
+    //~^ ERROR cannot find value `o` in this scope
+}
diff --git a/tests/ui/parser/macro/trailing-question-in-macro-type.stderr b/tests/ui/parser/macro/trailing-question-in-macro-type.stderr
new file mode 100644
index 00000000000..e3d33bf251d
--- /dev/null
+++ b/tests/ui/parser/macro/trailing-question-in-macro-type.stderr
@@ -0,0 +1,9 @@
+error[E0425]: cannot find value `o` in this scope
+  --> $DIR/trailing-question-in-macro-type.rs:12:15
+   |
+LL |     fn_expr!{ o?.when(|&i| i > 0)?.when(|&i| i%2 == 0) };
+   |               ^ not found in this scope
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0425`.