diff options
| author | Josh Triplett <josh@joshtriplett.org> | 2025-08-08 10:31:37 -0700 | 
|---|---|---|
| committer | Josh Triplett <josh@joshtriplett.org> | 2025-08-08 11:01:12 -0700 | 
| commit | bd5206ee1846f90579e644ebc7874a7300fc6171 (patch) | |
| tree | 7610069a6d0b39260f4dd92ab99df031ffb85de9 | |
| parent | 4f999f72dee5e7085a2a5ed11cd917dcad5143be (diff) | |
| download | rust-bd5206ee1846f90579e644ebc7874a7300fc6171.tar.gz rust-bd5206ee1846f90579e644ebc7874a7300fc6171.zip | |
mbe: Add test for attribute expansion with `compile_error!`
| -rw-r--r-- | tests/ui/macros/macro-rules-attr-error.rs | 13 | ||||
| -rw-r--r-- | tests/ui/macros/macro-rules-attr-error.stderr | 13 | 
2 files changed, 26 insertions, 0 deletions
| diff --git a/tests/ui/macros/macro-rules-attr-error.rs b/tests/ui/macros/macro-rules-attr-error.rs new file mode 100644 index 00000000000..59fb32a5bfc --- /dev/null +++ b/tests/ui/macros/macro-rules-attr-error.rs @@ -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; +} diff --git a/tests/ui/macros/macro-rules-attr-error.stderr b/tests/ui/macros/macro-rules-attr-error.stderr new file mode 100644 index 00000000000..7d033ae3f03 --- /dev/null +++ b/tests/ui/macros/macro-rules-attr-error.stderr @@ -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 + | 
