mbe: Add test for attribute expansion with compile_error!

This commit is contained in:
Josh Triplett 2025-08-08 10:31:37 -07:00
parent 4f999f72de
commit bd5206ee18
2 changed files with 26 additions and 0 deletions

View file

@ -0,0 +1,13 @@
#![feature(macro_attr)]
macro_rules! local_attr {
attr() { $($body:tt)* } => {
compile_error!(concat!("local_attr: ", stringify!($($body)*)));
};
//~^^ ERROR: local_attr
}
fn main() {
#[local_attr]
struct S;
}

View file

@ -0,0 +1,13 @@
error: local_attr: struct S;
--> $DIR/macro-rules-attr-error.rs:5:9
|
LL | compile_error!(concat!("local_attr: ", stringify!($($body)*)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | #[local_attr]
| ------------- in this attribute macro expansion
|
= note: this error originates in the attribute macro `local_attr` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 1 previous error