Skip to content

Commit 3e790a7

Browse files
committed
add a test
1 parent 1d94cc2 commit 3e790a7

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Test that duplicate matcher binding names are caught at declaration time, rather than at macro
2+
// invocation time.
3+
4+
macro_rules! foo1 {
5+
($a:ident, $a:ident) => {}; //~ERROR duplicate matcher binding
6+
($a:ident, $a:path) => {}; //~ERROR duplicate matcher binding
7+
}
8+
9+
macro_rules! foo2 {
10+
($a:ident) => {}; // OK
11+
($a:path) => {}; // OK
12+
}
13+
14+
macro_rules! foo3 {
15+
($a:ident, $($a:ident),*) => {}; //~ERROR duplicate matcher binding
16+
($($a:ident)+ # $($($a:path),+);*) => {}; //~ERROR duplicate matcher binding
17+
}
18+
19+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
error: duplicate matcher binding
2+
--> $DIR/macro-multiple-matcher-bindings.rs:5:16
3+
|
4+
LL | ($a:ident, $a:ident) => {}; //~ERROR duplicate matcher binding
5+
| ^^^^^^^^
6+
|
7+
note: previous declaration was here
8+
--> $DIR/macro-multiple-matcher-bindings.rs:5:6
9+
|
10+
LL | ($a:ident, $a:ident) => {}; //~ERROR duplicate matcher binding
11+
| ^^^^^^^^
12+
13+
error: duplicate matcher binding
14+
--> $DIR/macro-multiple-matcher-bindings.rs:6:16
15+
|
16+
LL | ($a:ident, $a:path) => {}; //~ERROR duplicate matcher binding
17+
| ^^^^^^^
18+
|
19+
note: previous declaration was here
20+
--> $DIR/macro-multiple-matcher-bindings.rs:6:6
21+
|
22+
LL | ($a:ident, $a:path) => {}; //~ERROR duplicate matcher binding
23+
| ^^^^^^^^
24+
25+
error: duplicate matcher binding
26+
--> $DIR/macro-multiple-matcher-bindings.rs:15:18
27+
|
28+
LL | ($a:ident, $($a:ident),*) => {}; //~ERROR duplicate matcher binding
29+
| ^^^^^^^^
30+
|
31+
note: previous declaration was here
32+
--> $DIR/macro-multiple-matcher-bindings.rs:15:6
33+
|
34+
LL | ($a:ident, $($a:ident),*) => {}; //~ERROR duplicate matcher binding
35+
| ^^^^^^^^
36+
37+
error: duplicate matcher binding
38+
--> $DIR/macro-multiple-matcher-bindings.rs:16:25
39+
|
40+
LL | ($($a:ident)+ # $($($a:path),+);*) => {}; //~ERROR duplicate matcher binding
41+
| ^^^^^^^
42+
|
43+
note: previous declaration was here
44+
--> $DIR/macro-multiple-matcher-bindings.rs:16:8
45+
|
46+
LL | ($($a:ident)+ # $($($a:path),+);*) => {}; //~ERROR duplicate matcher binding
47+
| ^^^^^^^^
48+
49+
error: aborting due to 4 previous errors
50+

0 commit comments

Comments
 (0)