Skip to content

Commit

Permalink
Add a test for proc macro generating $ IDENT
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Feb 17, 2020
1 parent 06fbb0b commit 950845c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/test/ui/proc-macro/auxiliary/generate-dollar-ident.rs
@@ -0,0 +1,17 @@
// force-host
// no-prefer-dynamic

#![feature(proc_macro_hygiene)]
#![feature(proc_macro_quote)]
#![crate_type = "proc-macro"]

extern crate proc_macro;
use proc_macro::*;

#[proc_macro]
pub fn dollar_ident(input: TokenStream) -> TokenStream {
let black_hole = input.into_iter().next().unwrap();
quote! {
$black_hole!($$var);
}
}
18 changes: 18 additions & 0 deletions src/test/ui/proc-macro/generate-dollar-ident.rs
@@ -0,0 +1,18 @@
// Proc macros can generate token sequence `$ IDENT`
// without it being recognized as an unknown macro variable.

// check-pass
// aux-build:generate-dollar-ident.rs

extern crate generate_dollar_ident;
use generate_dollar_ident::*;

macro_rules! black_hole {
($($tt:tt)*) => {};
}

black_hole!($var);

dollar_ident!(black_hole);

fn main() {}

0 comments on commit 950845c

Please sign in to comment.