diff --git a/src/test/ui/macros/issue-61033-1.rs b/src/test/ui/macros/issue-61033-1.rs new file mode 100644 index 0000000000000..8f85dec017f2a --- /dev/null +++ b/src/test/ui/macros/issue-61033-1.rs @@ -0,0 +1,9 @@ +// Regression test for issue #61033. + +macro_rules! test1 { + ($x:ident, $($tt:tt)*) => { $($tt)+ } //~ERROR this must repeat at least once +} + +fn main() { + test1!(x,); +} diff --git a/src/test/ui/macros/issue-61033-1.stderr b/src/test/ui/macros/issue-61033-1.stderr new file mode 100644 index 0000000000000..f3c68f4928dbb --- /dev/null +++ b/src/test/ui/macros/issue-61033-1.stderr @@ -0,0 +1,8 @@ +error: this must repeat at least once + --> $DIR/issue-61033-1.rs:4:34 + | +LL | ($x:ident, $($tt:tt)*) => { $($tt)+ } + | ^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/macros/issue-61033-2.rs b/src/test/ui/macros/issue-61033-2.rs new file mode 100644 index 0000000000000..0799be10b96c7 --- /dev/null +++ b/src/test/ui/macros/issue-61033-2.rs @@ -0,0 +1,19 @@ +// Regression test for issue #61033. + +macro_rules! test2 { + ( + $(* $id1:ident)* + $(+ $id2:ident)* + ) => { + $( //~ERROR meta-variable `id1` repeats 2 times + $id1 + $id2 // $id1 and $id2 may repeat different numbers of times + )* + } +} + +fn main() { + test2! { + * a * b + + a + b + c + } +} diff --git a/src/test/ui/macros/issue-61033-2.stderr b/src/test/ui/macros/issue-61033-2.stderr new file mode 100644 index 0000000000000..bf502919cf794 --- /dev/null +++ b/src/test/ui/macros/issue-61033-2.stderr @@ -0,0 +1,11 @@ +error: meta-variable `id1` repeats 2 times, but `id2` repeats 3 times + --> $DIR/issue-61033-2.rs:8:10 + | +LL | $( + | __________^ +LL | | $id1 + $id2 // $id1 and $id2 may repeat different numbers of times +LL | | )* + | |_________^ + +error: aborting due to previous error +