Skip to content

Commit 8f472e8

Browse files
fmeasejdonszelmann
andcommitted
Add regression test for a former ICE involving helper attributes containing interpolated tokens
Co-authored-by: Jana Dönszelmann <[email protected]>
1 parent 5771665 commit 8f472e8

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
extern crate proc_macro;
2+
3+
use proc_macro::TokenStream;
4+
5+
#[proc_macro_derive(Derive, attributes(arg))]
6+
pub fn derive(_: TokenStream) -> TokenStream {
7+
TokenStream::new()
8+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Regression test for <https://github.com/rust-lang/rust/issues/140612>.
2+
//@ proc-macro: derive_macro_with_helper.rs
3+
//@ edition: 2018
4+
//@ check-pass
5+
6+
macro_rules! expand {
7+
($text:expr) => {
8+
#[derive(derive_macro_with_helper::Derive)]
9+
// This inert attr is completely valid because it follows the grammar
10+
// `#` `[` SimplePath DelimitedTokenStream `]`.
11+
// However, we used to incorrectly delay a bug here and ICE when trying to parse `$text` as
12+
// the inside of a "meta item list" which may only begin with literals or paths.
13+
#[arg($text)]
14+
pub struct Foo;
15+
};
16+
}
17+
18+
expand!(1 + 1);
19+
20+
fn main() {}

0 commit comments

Comments
 (0)