]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-57597.rs
Rollup merge of #62337 - Mark-Simulacrum:fix-cpu-usage-script, r=alexcrichton
[rust.git] / src / test / ui / issues / issue-57597.rs
1 // Regression test for #57597.
2 //
3 // Make sure that nested matchers work correctly rather than causing an infinite loop or crash.
4
5 // edition:2018
6
7 macro_rules! foo1 {
8     ($($($i:ident)?)+) => {};
9     //~^ ERROR repetition matches empty token tree
10 }
11
12 macro_rules! foo2 {
13     ($($($i:ident)?)*) => {};
14     //~^ ERROR repetition matches empty token tree
15 }
16
17 macro_rules! foo3 {
18     ($($($i:ident)?)?) => {};
19     //~^ ERROR repetition matches empty token tree
20 }
21
22 macro_rules! foo4 {
23     ($($($($i:ident)?)?)?) => {};
24     //~^ ERROR repetition matches empty token tree
25 }
26
27 macro_rules! foo5 {
28     ($($($($i:ident)*)?)?) => {};
29     //~^ ERROR repetition matches empty token tree
30 }
31
32 macro_rules! foo6 {
33     ($($($($i:ident)?)*)?) => {};
34     //~^ ERROR repetition matches empty token tree
35 }
36
37 macro_rules! foo7 {
38     ($($($($i:ident)?)?)*) => {};
39     //~^ ERROR repetition matches empty token tree
40 }
41
42 macro_rules! foo8 {
43     ($($($($i:ident)*)*)?) => {};
44     //~^ ERROR repetition matches empty token tree
45 }
46
47 macro_rules! foo9 {
48     ($($($($i:ident)?)*)*) => {};
49     //~^ ERROR repetition matches empty token tree
50 }
51
52 macro_rules! foo10 {
53     ($($($($i:ident)?)*)+) => {};
54     //~^ ERROR repetition matches empty token tree
55 }
56
57 macro_rules! foo11 {
58     ($($($($i:ident)+)?)*) => {};
59     //~^ ERROR repetition matches empty token tree
60 }
61
62 macro_rules! foo12 {
63     ($($($($i:ident)+)*)?) => {};
64     //~^ ERROR repetition matches empty token tree
65 }
66
67 fn main() {
68     foo1!();
69     foo2!();
70     foo3!();
71     foo4!();
72     foo5!();
73     foo6!();
74     foo7!();
75     foo8!();
76     foo9!();
77     foo10!();
78     foo11!();
79     foo12!();
80 }