mbe: Add a test checking for infinite recursion in macro attributes

This commit is contained in:
Josh Triplett 2025-07-28 15:33:09 -07:00
parent 489734cd08
commit f88839d2ab
2 changed files with 26 additions and 0 deletions

View file

@ -0,0 +1,12 @@
#![crate_type = "lib"]
#![feature(macro_attr)]
macro_rules! attr {
attr() { $($body:tt)* } => {
#[attr] $($body)*
};
//~^^ ERROR: recursion limit reached
}
#[attr]
struct S;

View file

@ -0,0 +1,14 @@
error: recursion limit reached while expanding `#[attr]`
--> $DIR/macro-rules-attr-infinite-recursion.rs:6:9
|
LL | #[attr] $($body)*
| ^^^^^^^
...
LL | #[attr]
| ------- in this attribute macro expansion
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`macro_rules_attr_infinite_recursion`)
= note: this error originates in the attribute macro `attr` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 1 previous error