Unnamed repository; edit this file 'description' to name the repository.
Remove recursion_limit special casing in tests
Lukas Wirth 2024-12-31
parent 2e13684 · commit d30bd5f
-rw-r--r--crates/hir-def/src/body/tests.rs4
-rw-r--r--crates/hir-def/src/nameres/collector.rs8
2 files changed, 3 insertions, 9 deletions
diff --git a/crates/hir-def/src/body/tests.rs b/crates/hir-def/src/body/tests.rs
index 13ba4db606..7e15a9f2d6 100644
--- a/crates/hir-def/src/body/tests.rs
+++ b/crates/hir-def/src/body/tests.rs
@@ -52,6 +52,7 @@ fn your_stack_belongs_to_me() {
cov_mark::check!(your_stack_belongs_to_me);
lower(
r#"
+#![recursion_limit = "32"]
macro_rules! n_nuple {
($e:tt) => ();
($($rest:tt)*) => {{
@@ -68,6 +69,7 @@ fn your_stack_belongs_to_me2() {
cov_mark::check!(overflow_but_not_me);
lower(
r#"
+#![recursion_limit = "32"]
macro_rules! foo {
() => {{ foo!(); foo!(); }}
}
@@ -78,8 +80,6 @@ fn main() { foo!(); }
#[test]
fn recursion_limit() {
- cov_mark::check!(your_stack_belongs_to_me);
-
lower(
r#"
#![recursion_limit = "2"]
diff --git a/crates/hir-def/src/nameres/collector.rs b/crates/hir-def/src/nameres/collector.rs
index 5d19b849a7..6474bb7e5e 100644
--- a/crates/hir-def/src/nameres/collector.rs
+++ b/crates/hir-def/src/nameres/collector.rs
@@ -1451,13 +1451,7 @@ impl DefCollector<'_> {
depth: usize,
container: ItemContainerId,
) {
- let recursion_limit = 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
- });
+ let recursion_limit = Limit::new(self.def_map.recursion_limit() as usize);
if recursion_limit.check(depth).is_err() {
cov_mark::hit!(macro_expansion_overflow);
tracing::warn!("macro expansion is too deep");