diff options
Diffstat (limited to 'tests/ui/macros/macro-meta-items.rs')
-rw-r--r-- | tests/ui/macros/macro-meta-items.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/ui/macros/macro-meta-items.rs b/tests/ui/macros/macro-meta-items.rs new file mode 100644 index 000000000..4cbc252ae --- /dev/null +++ b/tests/ui/macros/macro-meta-items.rs @@ -0,0 +1,31 @@ +// 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); +} |