summaryrefslogtreecommitdiffstats
path: root/src/test/ui/hygiene/macro-metavars-legacy.rs
blob: 09070f0f561a6eb53ce05f756af2b954a5cadaee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Ensure macro metavariables are compared with legacy hygiene

#![feature(rustc_attrs)]

// run-pass

macro_rules! make_mac {
    ( $($dollar:tt $arg:ident),+ ) => {
        macro_rules! mac {
            ( $($dollar $arg : ident),+ ) => {
                $( $dollar $arg )-+
            }
        }
    }
}

macro_rules! show_hygiene {
    ( $dollar:tt $arg:ident ) => {
        make_mac!($dollar $arg, $dollar arg);
    }
}

show_hygiene!( $arg );

fn main() {
    let x = 5;
    let y = 3;
    assert_eq!(2, mac!(x, y));
}