about summary refs log tree commit diff
path: root/tests/ui/macros/macro-multiple-matcher-bindings.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/macros/macro-multiple-matcher-bindings.rs')
-rw-r--r--tests/ui/macros/macro-multiple-matcher-bindings.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/ui/macros/macro-multiple-matcher-bindings.rs b/tests/ui/macros/macro-multiple-matcher-bindings.rs
new file mode 100644
index 00000000000..7d39dc0a52f
--- /dev/null
+++ b/tests/ui/macros/macro-multiple-matcher-bindings.rs
@@ -0,0 +1,21 @@
+// Test that duplicate matcher binding names are caught at declaration time, rather than at macro
+// invocation time.
+
+#![allow(unused_macros)]
+
+macro_rules! foo1 {
+    ($a:ident, $a:ident) => {}; //~ERROR duplicate matcher binding
+    ($a:ident, $a:path) => {};  //~ERROR duplicate matcher binding
+}
+
+macro_rules! foo2 {
+    ($a:ident) => {}; // OK
+    ($a:path) => {};  // OK
+}
+
+macro_rules! foo3 {
+    ($a:ident, $($a:ident),*) => {}; //~ERROR duplicate matcher binding
+    ($($a:ident)+ # $($($a:path),+);*) => {}; //~ERROR duplicate matcher binding
+}
+
+fn main() {}