-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test for proc macro generating
$ IDENT
- Loading branch information
1 parent
06fbb0b
commit 950845c
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |