Remove recursion_limit special casing in tests

This commit is contained in:
Lukas Wirth 2024-12-31 12:59:20 +01:00
parent 2e13684be1
commit d30bd5fbb5
2 changed files with 3 additions and 9 deletions

View file

@ -52,6 +52,7 @@ fn your_stack_belongs_to_me() {
cov_mark::check!(your_stack_belongs_to_me); cov_mark::check!(your_stack_belongs_to_me);
lower( lower(
r#" r#"
#![recursion_limit = "32"]
macro_rules! n_nuple { macro_rules! n_nuple {
($e:tt) => (); ($e:tt) => ();
($($rest:tt)*) => {{ ($($rest:tt)*) => {{
@ -68,6 +69,7 @@ fn your_stack_belongs_to_me2() {
cov_mark::check!(overflow_but_not_me); cov_mark::check!(overflow_but_not_me);
lower( lower(
r#" r#"
#![recursion_limit = "32"]
macro_rules! foo { macro_rules! foo {
() => {{ foo!(); foo!(); }} () => {{ foo!(); foo!(); }}
} }
@ -78,8 +80,6 @@ fn main() { foo!(); }
#[test] #[test]
fn recursion_limit() { fn recursion_limit() {
cov_mark::check!(your_stack_belongs_to_me);
lower( lower(
r#" r#"
#![recursion_limit = "2"] #![recursion_limit = "2"]

View file

@ -1451,13 +1451,7 @@ impl DefCollector<'_> {
depth: usize, depth: usize,
container: ItemContainerId, container: ItemContainerId,
) { ) {
let recursion_limit = self.def_map.recursion_limit() as usize; let recursion_limit = Limit::new(self.def_map.recursion_limit() as usize);
let recursion_limit = Limit::new(if cfg!(test) {
// Without this, `body::tests::your_stack_belongs_to_me` stack-overflows in debug
std::cmp::min(32, recursion_limit)
} else {
recursion_limit
});
if recursion_limit.check(depth).is_err() { if recursion_limit.check(depth).is_err() {
cov_mark::hit!(macro_expansion_overflow); cov_mark::hit!(macro_expansion_overflow);
tracing::warn!("macro expansion is too deep"); tracing::warn!("macro expansion is too deep");