about summary refs log tree commit diff
path: root/tests/ui/macros
diff options
context:
space:
mode:
authorjullang <jullanggit@proton.me>2025-08-31 19:27:03 +0000
committerJul Lang <jullanggit@proton.me>2025-09-01 08:27:30 +0200
commitf6e7c81061c24a2210149ff94670d8672bd0224a (patch)
tree305ed74c2b140bc88e6c3fce05c1f2bd53fff693 /tests/ui/macros
parent564ee219127b796d56f74767366fd359758b97de (diff)
downloadrust-f6e7c81061c24a2210149ff94670d8672bd0224a.tar.gz
rust-f6e7c81061c24a2210149ff94670d8672bd0224a.zip
Add compiler error when trying to use concat metavar expr in repetitions
Replace unimplemented()! with a more helpful compiler error.
Diffstat (limited to 'tests/ui/macros')
-rw-r--r--tests/ui/macros/macro-metavar-expr-concat/in-repetition.rs21
-rw-r--r--tests/ui/macros/macro-metavar-expr-concat/in-repetition.stderr8
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/ui/macros/macro-metavar-expr-concat/in-repetition.rs b/tests/ui/macros/macro-metavar-expr-concat/in-repetition.rs
new file mode 100644
index 00000000000..d2bd31b06d6
--- /dev/null
+++ b/tests/ui/macros/macro-metavar-expr-concat/in-repetition.rs
@@ -0,0 +1,21 @@
+// issue: <https://github.com/rust-lang/rust/issues/140479>
+// Ensure a proper compiler error, instead of an ICE occurs.
+// FIXME(macro_metavar_expr_concat): this error message could be improved
+#![feature(macro_metavar_expr_concat)]
+
+macro_rules! InRepetition {
+    (
+        $(
+            $($arg:ident),+
+        )+
+     ) => {
+        $(
+            $(
+                ${concat(_, $arg)} //~ ERROR nested repetitions with `${concat(...)}` metavariable expressions are not yet supported
+            )*
+        )*
+    };
+}
+InRepetition!(other);
+
+fn main() {}
diff --git a/tests/ui/macros/macro-metavar-expr-concat/in-repetition.stderr b/tests/ui/macros/macro-metavar-expr-concat/in-repetition.stderr
new file mode 100644
index 00000000000..ec39ca799e1
--- /dev/null
+++ b/tests/ui/macros/macro-metavar-expr-concat/in-repetition.stderr
@@ -0,0 +1,8 @@
+error: nested repetitions with `${concat(...)}` metavariable expressions are not yet supported
+  --> $DIR/in-repetition.rs:14:30
+   |
+LL |                 ${concat(_, $arg)}
+   |                              ^^^
+
+error: aborting due to 1 previous error
+