Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-i-m committed Feb 7, 2019
1 parent 1d94cc2 commit 3e790a7
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/test/ui/macros/macro-multiple-matcher-bindings.rs
@@ -0,0 +1,19 @@
// Test that duplicate matcher binding names are caught at declaration time, rather than at macro
// invocation time.

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() {}
50 changes: 50 additions & 0 deletions src/test/ui/macros/macro-multiple-matcher-bindings.stderr
@@ -0,0 +1,50 @@
error: duplicate matcher binding
--> $DIR/macro-multiple-matcher-bindings.rs:5:16
|
LL | ($a:ident, $a:ident) => {}; //~ERROR duplicate matcher binding
| ^^^^^^^^
|
note: previous declaration was here
--> $DIR/macro-multiple-matcher-bindings.rs:5:6
|
LL | ($a:ident, $a:ident) => {}; //~ERROR duplicate matcher binding
| ^^^^^^^^

error: duplicate matcher binding
--> $DIR/macro-multiple-matcher-bindings.rs:6:16
|
LL | ($a:ident, $a:path) => {}; //~ERROR duplicate matcher binding
| ^^^^^^^
|
note: previous declaration was here
--> $DIR/macro-multiple-matcher-bindings.rs:6:6
|
LL | ($a:ident, $a:path) => {}; //~ERROR duplicate matcher binding
| ^^^^^^^^

error: duplicate matcher binding
--> $DIR/macro-multiple-matcher-bindings.rs:15:18
|
LL | ($a:ident, $($a:ident),*) => {}; //~ERROR duplicate matcher binding
| ^^^^^^^^
|
note: previous declaration was here
--> $DIR/macro-multiple-matcher-bindings.rs:15:6
|
LL | ($a:ident, $($a:ident),*) => {}; //~ERROR duplicate matcher binding
| ^^^^^^^^

error: duplicate matcher binding
--> $DIR/macro-multiple-matcher-bindings.rs:16:25
|
LL | ($($a:ident)+ # $($($a:path),+);*) => {}; //~ERROR duplicate matcher binding
| ^^^^^^^
|
note: previous declaration was here
--> $DIR/macro-multiple-matcher-bindings.rs:16:8
|
LL | ($($a:ident)+ # $($($a:path),+);*) => {}; //~ERROR duplicate matcher binding
| ^^^^^^^^

error: aborting due to 4 previous errors

0 comments on commit 3e790a7

Please sign in to comment.