]> git.lizzy.rs Git - rust.git/blob - src/test/ui/proc-macro/inner-attrs.rs
Merge commit 'a98e7ab8b94485be6bd03e0c6b8682ecab5b52e6' into clippyup
[rust.git] / src / test / ui / proc-macro / inner-attrs.rs
1 // compile-flags: -Z span-debug --error-format human
2 // aux-build:test-macros.rs
3 // edition:2018
4
5 #![feature(custom_inner_attributes)]
6 #![feature(proc_macro_hygiene)]
7 #![feature(stmt_expr_attributes)]
8 #![feature(rustc_attrs)]
9
10 #![no_std] // Don't load unnecessary hygiene information from std
11 extern crate std;
12
13 #[macro_use]
14 extern crate test_macros;
15
16 #[print_target_and_args(first)]
17 #[print_target_and_args(second)]
18 fn foo() {
19     #![print_target_and_args(third)]
20     #![print_target_and_args(fourth)]
21 }
22
23 #[print_target_and_args(mod_first)]
24 #[print_target_and_args(mod_second)]
25 mod inline_mod {
26     #![print_target_and_args(mod_third)]
27     #![print_target_and_args(mod_fourth)]
28 }
29
30 struct MyStruct {
31     field: bool
32 }
33
34 #[derive(Print)]
35 struct MyDerivePrint {
36     field: [u8; {
37         match true {
38             _ => {
39                 #![cfg_attr(not(FALSE), rustc_dummy(third))]
40                 true
41             }
42         };
43         0
44     }]
45 }
46
47 fn bar() {
48     #[print_target_and_args(tuple_attrs)] (
49         3, 4, {
50             #![cfg_attr(not(FALSE), rustc_dummy(innermost))]
51             5
52         }
53     );
54
55     #[print_target_and_args(tuple_attrs)] (
56         3, 4, {
57             #![cfg_attr(not(FALSE), rustc_dummy(innermost))]
58             5
59         }
60     );
61
62     for _ in &[true] {
63         #![print_attr] //~ ERROR expected non-macro inner attribute
64     }
65
66     let _ = {
67         #![print_attr] //~ ERROR expected non-macro inner attribute
68     };
69
70     let _ = async {
71         #![print_attr] //~ ERROR expected non-macro inner attribute
72     };
73
74     {
75         #![print_attr] //~ ERROR expected non-macro inner attribute
76     };
77 }
78
79
80 extern {
81     fn weird_extern() {
82         #![print_target_and_args_consume(tenth)]
83     }
84 }
85
86 fn main() {}