]>
Commit | Line | Data |
---|---|---|
83c7162d XL |
1 | // Copyright 2018 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 | // aux-build:proc-macro-gates.rs | |
0bf4aa26 | 12 | // gate-test-proc_macro_hygiene |
83c7162d | 13 | |
b7449926 | 14 | #![feature(stmt_expr_attributes)] |
83c7162d XL |
15 | |
16 | extern crate proc_macro_gates as foo; | |
17 | ||
18 | use foo::*; | |
19 | ||
83c7162d | 20 | fn _test_inner() { |
b7449926 | 21 | #![a] //~ ERROR: non-builtin inner attributes are unstable |
83c7162d XL |
22 | } |
23 | ||
24 | #[a] //~ ERROR: custom attributes cannot be applied to modules | |
25 | mod _test2 {} | |
26 | ||
27 | mod _test2_inner { | |
28 | #![a] //~ ERROR: custom attributes cannot be applied to modules | |
b7449926 | 29 | //~| ERROR: non-builtin inner attributes are unstable |
83c7162d XL |
30 | } |
31 | ||
32 | #[a = y] //~ ERROR: must only be followed by a delimiter token | |
33 | fn _test3() {} | |
34 | ||
83c7162d XL |
35 | fn attrs() { |
36 | // Statement, item | |
37 | #[a] // OK | |
38 | struct S; | |
39 | ||
40 | // Statement, macro | |
41 | #[a] //~ ERROR: custom attributes cannot be applied to statements | |
42 | println!(); | |
43 | ||
44 | // Statement, semi | |
45 | #[a] //~ ERROR: custom attributes cannot be applied to statements | |
46 | S; | |
47 | ||
48 | // Statement, local | |
49 | #[a] //~ ERROR: custom attributes cannot be applied to statements | |
50 | let _x = 2; | |
51 | ||
52 | // Expr | |
53 | let _x = #[a] 2; //~ ERROR: custom attributes cannot be applied to expressions | |
54 | ||
55 | // Opt expr | |
56 | let _x = [#[a] 2]; //~ ERROR: custom attributes cannot be applied to expressions | |
57 | ||
58 | // Expr macro | |
59 | let _x = #[a] println!(); //~ ERROR: custom attributes cannot be applied to expressions | |
60 | } | |
61 | ||
62 | fn main() { | |
63 | let _x: m!(u32) = 3; //~ ERROR: procedural macros cannot be expanded to types | |
64 | if let m!(Some(_x)) = Some(3) {} //~ ERROR: procedural macros cannot be expanded to patterns | |
65 | ||
66 | m!(struct S;); //~ ERROR: procedural macros cannot be expanded to statements | |
67 | m!(let _x = 3;); //~ ERROR: procedural macros cannot be expanded to statements | |
68 | ||
69 | let _x = m!(3); //~ ERROR: procedural macros cannot be expanded to expressions | |
70 | let _x = [m!(3)]; //~ ERROR: procedural macros cannot be expanded to expressions | |
71 | } |