]> git.lizzy.rs Git - rust.git/blob - tests/ui/proc-macro/proc-macro-gates.rs
Rollup merge of #107576 - P1n3appl3:master, r=tmandry
[rust.git] / tests / 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: inner macro attributes are unstable
11 }
12
13 mod _test2_inner {
14     #![empty_attr] //~ ERROR: inner macro attributes are unstable
15 }
16
17 #[empty_attr = "y"] //~ ERROR: key-value macro attributes are not supported
18 fn _test3() {}
19
20 fn attrs() {
21     // Statement, item
22     #[empty_attr] // OK
23     struct S;
24
25     // Statement, macro
26     #[empty_attr] //~ ERROR: custom attributes cannot be applied to statements
27     println!();
28
29     // Statement, semi
30     #[empty_attr] //~ ERROR: custom attributes cannot be applied to statements
31     S;
32
33     // Statement, local
34     #[empty_attr] //~ ERROR: custom attributes cannot be applied to statements
35     let _x = 2;
36
37     // Expr
38     let _x = #[identity_attr] 2; //~ ERROR: custom attributes cannot be applied to expressions
39
40     // Opt expr
41     let _x = [#[identity_attr] 2]; //~ ERROR: custom attributes cannot be applied to expressions
42
43     // Expr macro
44     let _x = #[identity_attr] println!();
45     //~^ ERROR: custom attributes cannot be applied to expressions
46 }
47
48 fn test_case() {
49     #![test] //~ ERROR inner macro attributes are unstable
50              //~| WARN this was previously accepted
51 }
52
53 fn main() {}