Skip to content

Commit 950845c

Browse files
committed
Add a test for proc macro generating $ IDENT
1 parent 06fbb0b commit 950845c

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// force-host
2+
// no-prefer-dynamic
3+
4+
#![feature(proc_macro_hygiene)]
5+
#![feature(proc_macro_quote)]
6+
#![crate_type = "proc-macro"]
7+
8+
extern crate proc_macro;
9+
use proc_macro::*;
10+
11+
#[proc_macro]
12+
pub fn dollar_ident(input: TokenStream) -> TokenStream {
13+
let black_hole = input.into_iter().next().unwrap();
14+
quote! {
15+
$black_hole!($$var);
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Proc macros can generate token sequence `$ IDENT`
2+
// without it being recognized as an unknown macro variable.
3+
4+
// check-pass
5+
// aux-build:generate-dollar-ident.rs
6+
7+
extern crate generate_dollar_ident;
8+
use generate_dollar_ident::*;
9+
10+
macro_rules! black_hole {
11+
($($tt:tt)*) => {};
12+
}
13+
14+
black_hole!($var);
15+
16+
dollar_ident!(black_hole);
17+
18+
fn main() {}

0 commit comments

Comments
 (0)