1 // aux-build:attr-stmt-expr.rs
2 // aux-build:test-macros.rs
3 // compile-flags: -Z span-debug
5 #![feature(proc_macro_hygiene)]
6 #![feature(rustc_attrs)]
8 #![no_std] // Don't load unnecessary hygiene information from std
10 extern crate test_macros;
11 extern crate attr_stmt_expr;
13 use test_macros::print_attr;
14 use attr_stmt_expr::{expect_let, expect_my_macro_stmt, expect_expr, expect_my_macro_expr};
16 // We don't use `std::println` so that we avoid loading hygiene
17 // information from libstd, which would affect the SyntaxContext ids
18 macro_rules! my_macro {
19 ($($tt:tt)*) => { () }
22 fn print_str(string: &'static str) {
23 // macros are handled a bit differently
24 #[expect_my_macro_expr]
25 //~^ ERROR attributes on expressions are experimental
26 //~| HELP add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
27 my_macro!("{}", string)
30 macro_rules! make_stmt {
38 macro_rules! second_make_stmt {
45 make_stmt!(struct Foo {});
49 let string = "Hello, world!";
52 #[expect_my_macro_stmt]
53 my_macro!("{}", string);
56 second_make_stmt!(#[allow(dead_code)] struct Bar {});
63 //~^ ERROR attributes on expressions are experimental
64 //~| HELP add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable