Skip to content

Commit bd5206e

Browse files
committed
mbe: Add test for attribute expansion with compile_error!
1 parent 4f999f7 commit bd5206e

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![feature(macro_attr)]
2+
3+
macro_rules! local_attr {
4+
attr() { $($body:tt)* } => {
5+
compile_error!(concat!("local_attr: ", stringify!($($body)*)));
6+
};
7+
//~^^ ERROR: local_attr
8+
}
9+
10+
fn main() {
11+
#[local_attr]
12+
struct S;
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error: local_attr: struct S;
2+
--> $DIR/macro-rules-attr-error.rs:5:9
3+
|
4+
LL | compile_error!(concat!("local_attr: ", stringify!($($body)*)));
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
...
7+
LL | #[local_attr]
8+
| ------------- in this attribute macro expansion
9+
|
10+
= note: this error originates in the attribute macro `local_attr` (in Nightly builds, run with -Z macro-backtrace for more info)
11+
12+
error: aborting due to 1 previous error
13+

0 commit comments

Comments
 (0)