about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/parser/macro/bad-macro-definition.rs22
-rw-r--r--tests/ui/parser/macro/bad-macro-definition.stderr56
2 files changed, 78 insertions, 0 deletions
diff --git a/tests/ui/parser/macro/bad-macro-definition.rs b/tests/ui/parser/macro/bad-macro-definition.rs
new file mode 100644
index 00000000000..3c5c93ea3b3
--- /dev/null
+++ b/tests/ui/parser/macro/bad-macro-definition.rs
@@ -0,0 +1,22 @@
+#![crate_type = "lib"]
+
+macro_rules! a { {} => }
+//~^ ERROR: macro definition ended unexpectedly
+
+macro_rules! b { 0 => }
+//~^ ERROR: macro definition ended unexpectedly
+//~| ERROR: invalid macro matcher
+
+macro_rules! c { x => }
+//~^ ERROR: macro definition ended unexpectedly
+//~| ERROR: invalid macro matcher
+
+macro_rules! d { _ => }
+//~^ ERROR: macro definition ended unexpectedly
+//~| ERROR: invalid macro matcher
+
+macro_rules! e { {} }
+//~^ ERROR: expected `=>`, found end of macro arguments
+
+macro_rules! f {}
+//~^ ERROR: macros must contain at least one rule
diff --git a/tests/ui/parser/macro/bad-macro-definition.stderr b/tests/ui/parser/macro/bad-macro-definition.stderr
new file mode 100644
index 00000000000..de6d9d6a38b
--- /dev/null
+++ b/tests/ui/parser/macro/bad-macro-definition.stderr
@@ -0,0 +1,56 @@
+error: macro definition ended unexpectedly
+  --> $DIR/bad-macro-definition.rs:3:23
+   |
+LL | macro_rules! a { {} => }
+   |                       ^ expected right-hand side of macro rule
+
+error: invalid macro matcher; matchers must be contained in balanced delimiters
+  --> $DIR/bad-macro-definition.rs:6:18
+   |
+LL | macro_rules! b { 0 => }
+   |                  ^
+
+error: macro definition ended unexpectedly
+  --> $DIR/bad-macro-definition.rs:6:22
+   |
+LL | macro_rules! b { 0 => }
+   |                      ^ expected right-hand side of macro rule
+
+error: invalid macro matcher; matchers must be contained in balanced delimiters
+  --> $DIR/bad-macro-definition.rs:10:18
+   |
+LL | macro_rules! c { x => }
+   |                  ^
+
+error: macro definition ended unexpectedly
+  --> $DIR/bad-macro-definition.rs:10:22
+   |
+LL | macro_rules! c { x => }
+   |                      ^ expected right-hand side of macro rule
+
+error: invalid macro matcher; matchers must be contained in balanced delimiters
+  --> $DIR/bad-macro-definition.rs:14:18
+   |
+LL | macro_rules! d { _ => }
+   |                  ^
+
+error: macro definition ended unexpectedly
+  --> $DIR/bad-macro-definition.rs:14:22
+   |
+LL | macro_rules! d { _ => }
+   |                      ^ expected right-hand side of macro rule
+
+error: expected `=>`, found end of macro arguments
+  --> $DIR/bad-macro-definition.rs:18:20
+   |
+LL | macro_rules! e { {} }
+   |                    ^ expected `=>`
+
+error: macros must contain at least one rule
+  --> $DIR/bad-macro-definition.rs:21:1
+   |
+LL | macro_rules! f {}
+   | ^^^^^^^^^^^^^^^^^
+
+error: aborting due to 9 previous errors
+