]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/macro-context.rs
f6b979395d5dc65c04f79246e150b3cc807b43a8
[rust.git] / src / test / compile-fail / macro-context.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![feature(type_macros)]
12
13 // (typeof used because it's surprisingly hard to find an unparsed token after a stmt)
14 macro_rules! m {
15     () => ( i ; typeof );   //~ ERROR `typeof` is a reserved keyword
16                             //~| ERROR macro expansion ignores token `typeof`
17                             //~| ERROR macro expansion ignores token `typeof`
18                             //~| ERROR macro expansion ignores token `;`
19                             //~| ERROR macro expansion ignores token `;`
20                             //~| ERROR macro expansion ignores token `i`
21 }
22
23 m!();               //~ NOTE the usage of `m!` is likely invalid in this item context
24
25 fn main() {
26     let a: m!();    //~ NOTE the usage of `m!` is likely invalid in this type context
27     let i = m!();   //~ NOTE the usage of `m!` is likely invalid in this expression context
28     match 0 {
29         m!() => {}  //~ NOTE the usage of `m!` is likely invalid in this pattern context
30     }
31
32     m!();           //~ NOTE the usage of `m!` is likely invalid in this statement context
33 }