about summary refs log tree commit diff
path: root/tests/ui/macros/macro-meta-items.rs
blob: 35ef10fef5a84b995918e255daf3c055e3868749 (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
30
31
32
//@ run-pass
//@ compile-flags: --cfg foo --check-cfg=cfg(foo)

#![allow(dead_code)]

macro_rules! compiles_fine {
    ($at:meta) => {
        #[cfg($at)]
        static MISTYPED: () = "foo";
    }
}
macro_rules! emit {
    ($at:meta) => {
        #[cfg($at)]
        static MISTYPED: &'static str = "foo";
    }
}

// item
compiles_fine!(FALSE);
emit!(foo);

fn foo() {
    println!("{}", MISTYPED);
}

pub fn main() {
    // statement
    compiles_fine!(FALSE);
    emit!(FALSE);
    println!("{}", MISTYPED);
}