]> git.lizzy.rs Git - rust.git/blob - src/test/ui/proc-macro/proc-macro-gates.rs
async/await: improve obligation errors
[rust.git] / src / test / ui / proc-macro / proc-macro-gates.rs
1 // aux-build:test-macros.rs
2 // gate-test-proc_macro_hygiene
3
4 #![feature(stmt_expr_attributes)]
5
6 #[macro_use]
7 extern crate test_macros;
8
9 fn _test_inner() {
10     #![empty_attr] //~ ERROR: non-builtin inner attributes are unstable
11 }
12
13 #[empty_attr] //~ ERROR: custom attributes cannot be applied to modules
14 mod _test2 {}
15
16 mod _test2_inner {
17     #![empty_attr] //~ ERROR: custom attributes cannot be applied to modules
18           //~| ERROR: non-builtin inner attributes are unstable
19 }
20
21 #[empty_attr = "y"] //~ ERROR: must only be followed by a delimiter token
22 fn _test3() {}
23
24 fn attrs() {
25     // Statement, item
26     #[empty_attr] // OK
27     struct S;
28
29     // Statement, macro
30     #[empty_attr] //~ ERROR: custom attributes cannot be applied to statements
31     println!();
32
33     // Statement, semi
34     #[empty_attr] //~ ERROR: custom attributes cannot be applied to statements
35     S;
36
37     // Statement, local
38     #[empty_attr] //~ ERROR: custom attributes cannot be applied to statements
39     let _x = 2;
40
41     // Expr
42     let _x = #[identity_attr] 2; //~ ERROR: custom attributes cannot be applied to expressions
43
44     // Opt expr
45     let _x = [#[identity_attr] 2]; //~ ERROR: custom attributes cannot be applied to expressions
46
47     // Expr macro
48     let _x = #[identity_attr] println!();
49     //~^ ERROR: custom attributes cannot be applied to expressions
50 }
51
52 fn main() {
53     let _x: identity!(u32) = 3; //~ ERROR: procedural macros cannot be expanded to types
54     if let identity!(Some(_x)) = Some(3) {}
55     //~^ ERROR: procedural macros cannot be expanded to patterns
56
57     empty!(struct S;); //~ ERROR: procedural macros cannot be expanded to statements
58     empty!(let _x = 3;); //~ ERROR: procedural macros cannot be expanded to statements
59
60     let _x = identity!(3); //~ ERROR: procedural macros cannot be expanded to expressions
61     let _x = [empty!(3)]; //~ ERROR: procedural macros cannot be expanded to expressions
62 }