about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/ui/attributes/auxiliary/derive_macro_with_helper.rs8
-rw-r--r--tests/ui/attributes/helper-attr-interpolated-non-lit-arg.rs20
2 files changed, 28 insertions, 0 deletions
diff --git a/tests/ui/attributes/auxiliary/derive_macro_with_helper.rs b/tests/ui/attributes/auxiliary/derive_macro_with_helper.rs
new file mode 100644
index 00000000000..128af50ce36
--- /dev/null
+++ b/tests/ui/attributes/auxiliary/derive_macro_with_helper.rs
@@ -0,0 +1,8 @@
+extern crate proc_macro;
+
+use proc_macro::TokenStream;
+
+#[proc_macro_derive(Derive, attributes(arg))]
+pub fn derive(_: TokenStream) -> TokenStream {
+    TokenStream::new()
+}
diff --git a/tests/ui/attributes/helper-attr-interpolated-non-lit-arg.rs b/tests/ui/attributes/helper-attr-interpolated-non-lit-arg.rs
new file mode 100644
index 00000000000..17c9ad1bd48
--- /dev/null
+++ b/tests/ui/attributes/helper-attr-interpolated-non-lit-arg.rs
@@ -0,0 +1,20 @@
+// Regression test for <https://github.com/rust-lang/rust/issues/140612>.
+//@ proc-macro: derive_macro_with_helper.rs
+//@ edition: 2018
+//@ check-pass
+
+macro_rules! expand {
+    ($text:expr) => {
+        #[derive(derive_macro_with_helper::Derive)]
+        // This inert attr is completely valid because it follows the grammar
+        // `#` `[` SimplePath DelimitedTokenStream `]`.
+        // However, we used to incorrectly delay a bug here and ICE when trying to parse `$text` as
+        // the inside of a "meta item list" which may only begin with literals or paths.
+        #[arg($text)]
+        pub struct Foo;
+    };
+}
+
+expand!(1 + 1);
+
+fn main() {}