]> git.proxmox.com Git - rustc.git/blob - src/test/ui/proc-macro/weird-hygiene.rs
New upstream version 1.46.0~beta.2+dfsg1
[rustc.git] / src / test / ui / proc-macro / weird-hygiene.rs
1 // aux-build:weird-hygiene.rs
2 // check-pass
3 // FIXME: This should actually error, see PR #73084
4
5 #![feature(stmt_expr_attributes)]
6 #![feature(proc_macro_hygiene)]
7
8 extern crate weird_hygiene;
9 use weird_hygiene::*;
10
11 macro_rules! other {
12 ($tokens:expr) => {
13 macro_rules! call_it {
14 ($outer_ident:ident) => {
15 macro_rules! inner {
16 () => {
17 $outer_ident;
18 }
19 }
20 }
21 }
22
23 #[derive(WeirdDerive)]
24 enum MyEnum {
25 Value = (stringify!($tokens + hidden_ident), 1).1
26 }
27
28 inner!();
29 }
30 }
31
32 macro_rules! invoke_it {
33 ($token:expr) => {
34 #[recollect_attr] {
35 $token;
36 hidden_ident
37 }
38 }
39 }
40
41 fn main() {
42 // `other` and `invoke_it` are both macro_rules! macros,
43 // so it should be impossible for them to ever see `hidden_ident`,
44 // even if they invoke a proc macro.
45 let hidden_ident = "Hello1";
46 other!(50);
47 invoke_it!(25);
48 }