Skip to content

Commit 9317dbc

Browse files
committed
mbe: Add a test checking for infinite recursion in macro attributes
1 parent abf7f7b commit 9317dbc

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![crate_type = "lib"]
2+
#![feature(macro_attr)]
3+
4+
macro_rules! attr {
5+
attr() { $($body:tt)* } => {
6+
#[attr] $($body)*
7+
};
8+
//~^^ ERROR: recursion limit reached
9+
}
10+
11+
#[attr]
12+
struct S;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: recursion limit reached while expanding `#[attr]`
2+
--> $DIR/macro-rules-attr-infinite-recursion.rs:6:9
3+
|
4+
LL | #[attr] $($body)*
5+
| ^^^^^^^
6+
...
7+
LL | #[attr]
8+
| ------- in this attribute macro expansion
9+
|
10+
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`macro_rules_attr_infinite_recursion`)
11+
= note: this error originates in the attribute macro `attr` (in Nightly builds, run with -Z macro-backtrace for more info)
12+
13+
error: aborting due to 1 previous error
14+

0 commit comments

Comments
 (0)