mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
32 lines
486 B
Rust
32 lines
486 B
Rust
//@ run-pass
|
|
#![allow(dead_code)]
|
|
//@ compile-flags: --cfg foo
|
|
|
|
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!(bar);
|
|
emit!(foo);
|
|
|
|
fn foo() {
|
|
println!("{}", MISTYPED);
|
|
}
|
|
|
|
pub fn main() {
|
|
// statement
|
|
compiles_fine!(baz);
|
|
emit!(baz);
|
|
println!("{}", MISTYPED);
|
|
}
|