]> git.lizzy.rs Git - rust.git/blob - tests/ui/proc-macro/weird-hygiene.rs
Rollup merge of #107532 - compiler-errors:erase-regions-in-uninhabited, r=jackh726
[rust.git] / tests / ui / proc-macro / weird-hygiene.rs
1 // aux-build:weird-hygiene.rs
2
3 #![feature(stmt_expr_attributes)]
4 #![feature(proc_macro_hygiene)]
5
6 extern crate weird_hygiene;
7 use weird_hygiene::*;
8
9 macro_rules! other {
10     ($tokens:expr) => {
11         macro_rules! call_it {
12             ($outer_ident:ident) => {
13                 macro_rules! inner {
14                     () => {
15                         $outer_ident;
16                     }
17                 }
18             }
19         }
20
21         #[derive(WeirdDerive)]
22         enum MyEnum {
23             Value = (stringify!($tokens + hidden_ident), 1).1 //~ ERROR cannot find
24         }
25
26         inner!();
27     }
28 }
29
30 macro_rules! invoke_it {
31     ($token:expr) => {
32         #[recollect_attr] {
33             $token;
34             hidden_ident //~ ERROR cannot find
35         }
36     }
37 }
38
39 fn main() {
40     // `other` and `invoke_it` are both macro_rules! macros,
41     // so it should be impossible for them to ever see `hidden_ident`,
42     // even if they invoke a proc macro.
43     let hidden_ident = "Hello1";
44     other!(50);
45     invoke_it!(25);
46 }