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