Skip to content

Commit b3c3604

Browse files
committed
Add regression test for issue 99173
Adds a test for nested proc-macro calls where the inner macro returns an empty TokenStream. This previously caused an ICE in rustc_resolve.
1 parent 0850949 commit b3c3604

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Auxiliary proc-macro for issue #99173
2+
// Tests that nested proc-macro calls with empty output don't cause ICE
3+
4+
extern crate proc_macro;
5+
6+
use proc_macro::TokenStream;
7+
8+
// This macro returns an empty TokenStream
9+
#[proc_macro]
10+
pub fn ignore(_input: TokenStream) -> TokenStream {
11+
TokenStream::new()
12+
}
13+
14+
// This macro generates code that calls the `ignore` macro
15+
#[proc_macro]
16+
pub fn outer_macro(_input: TokenStream) -> TokenStream {
17+
"nested_empty_proc_macro::ignore!(42)".parse().unwrap()
18+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ check-pass
2+
//@ proc-macro: nested-empty-proc-macro.rs
3+
4+
// Regression test for issue #99173
5+
// Tests that nested proc-macro calls where the inner macro returns
6+
// an empty TokenStream don't cause an ICE.
7+
8+
extern crate nested_empty_proc_macro;
9+
10+
fn main() {
11+
nested_empty_proc_macro::outer_macro!(1 * 2 * 3 * 7);
12+
}

0 commit comments

Comments
 (0)