diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-08-14 11:39:37 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-14 11:39:37 +0200 |
| commit | 952584942cdedc7e9e4d4037f2355932f8d75a2e (patch) | |
| tree | 18df474021392e1bb198db6fb3b659b0e744e607 | |
| parent | c1f9e2ab509dc8f03bf56ab9b9f109c467d3abb6 (diff) | |
| parent | 8f472e8b5c0923a36a3cd90c3d5fc990943dd034 (diff) | |
| download | rust-952584942cdedc7e9e4d4037f2355932f8d75a2e.tar.gz rust-952584942cdedc7e9e4d4037f2355932f8d75a2e.zip | |
Rollup merge of #145250 - fmease:regr-test-for-attr-meta-ice, r=jdonszelmann
Add regression test for a former ICE involving helper attributes containing interpolated tokens Add regression test for rust-lang/rust#140612 from rust-lang/rust#140601 or rather rust-lang/rust#140859 that only added it to `stable` not `master`. Supersedes https://github.com/rust-lang/rust/pull/140584. r? `@jdonszelmann` or anyone
| -rw-r--r-- | tests/ui/attributes/auxiliary/derive_macro_with_helper.rs | 8 | ||||
| -rw-r--r-- | tests/ui/attributes/helper-attr-interpolated-non-lit-arg.rs | 20 |
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() {} |
