Skip to content

Commit b2824c7

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 b2824c7

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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 its follows the grammar
10+
// `#` `[` SimplePath DelimitedTokenStream `]`.
11+
// However, we used to incorrectly delay a bug here and ICE
12+
// when trying to parse `$text` as the inside of a "meta item list"
13+
// which may only begin with literals or paths.
14+
#[arg($text)]
15+
pub struct Foo;
16+
};
17+
}
18+
19+
expand!(1 + 1);
20+
21+
fn main() {}

0 commit comments

Comments
 (0)