about summary refs log tree commit diff
path: root/tests/ui/macros
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2024-12-26 21:56:47 -0500
committerGitHub <noreply@github.com>2024-12-26 21:56:47 -0500
commitb919afa70fe4a77bfdb548a7a54d08803de26842 (patch)
tree72273a6c0a8b3e97a163b09d9649d13a4b0010c6 /tests/ui/macros
parent917bfa78478cbcc77406e5ea37b24c3eedefacf4 (diff)
parentb661e98f09a195cd13457525b09b6db628835734 (diff)
downloadrust-b919afa70fe4a77bfdb548a7a54d08803de26842.tar.gz
rust-b919afa70fe4a77bfdb548a7a54d08803de26842.zip
Rollup merge of #131522 - c410-f3r:unlock-rfc-2011, r=chenyukang
[macro_metavar_expr_concat] Fix #128346

Fix #128346
Fix #131393

The syntax is invalid in both issues so I guess that theoretically the compiler should have aborted early.

This PR tries to fix a local problem but let me know if there are better options.

cc `@petrochenkov` if you are interested
Diffstat (limited to 'tests/ui/macros')
-rw-r--r--tests/ui/macros/macro-metavar-expr-concat/repetitions.rs22
-rw-r--r--tests/ui/macros/macro-metavar-expr-concat/repetitions.stderr22
2 files changed, 42 insertions, 2 deletions
diff --git a/tests/ui/macros/macro-metavar-expr-concat/repetitions.rs b/tests/ui/macros/macro-metavar-expr-concat/repetitions.rs
index 781443207ac..52a7d5cd8a7 100644
--- a/tests/ui/macros/macro-metavar-expr-concat/repetitions.rs
+++ b/tests/ui/macros/macro-metavar-expr-concat/repetitions.rs
@@ -1,5 +1,3 @@
-//@ run-pass
-
 #![feature(macro_metavar_expr_concat)]
 
 macro_rules! one_rep {
@@ -10,9 +8,29 @@ macro_rules! one_rep {
     };
 }
 
+macro_rules! issue_128346 {
+    ( $($a:ident)* ) => {
+        A(
+            const ${concat($a, Z)}: i32 = 3;
+            //~^ ERROR invalid syntax
+        )*
+    };
+}
+
+macro_rules! issue_131393 {
+    ($t:ident $($en:ident)?) => {
+        read::<${concat($t, $en)}>()
+        //~^ ERROR invalid syntax
+        //~| ERROR invalid syntax
+    }
+}
+
 fn main() {
     one_rep!(A B C);
     assert_eq!(AZ, 3);
     assert_eq!(BZ, 3);
     assert_eq!(CZ, 3);
+    issue_128346!(A B C);
+    issue_131393!(u8);
+    issue_131393!(u16 le);
 }
diff --git a/tests/ui/macros/macro-metavar-expr-concat/repetitions.stderr b/tests/ui/macros/macro-metavar-expr-concat/repetitions.stderr
new file mode 100644
index 00000000000..c3006c4be5d
--- /dev/null
+++ b/tests/ui/macros/macro-metavar-expr-concat/repetitions.stderr
@@ -0,0 +1,22 @@
+error: invalid syntax
+  --> $DIR/repetitions.rs:14:20
+   |
+LL |             const ${concat($a, Z)}: i32 = 3;
+   |                    ^^^^^^^^^^^^^^^
+
+error: invalid syntax
+  --> $DIR/repetitions.rs:22:17
+   |
+LL |         read::<${concat($t, $en)}>()
+   |                 ^^^^^^^^^^^^^^^^^
+
+error: invalid syntax
+  --> $DIR/repetitions.rs:22:17
+   |
+LL |         read::<${concat($t, $en)}>()
+   |                 ^^^^^^^^^^^^^^^^^
+   |
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+
+error: aborting due to 3 previous errors
+