Skip to content

Commit

Permalink
Remove recursion_limit special casing in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Veykril committed Dec 31, 2024
1 parent 20a7bf1 commit b8fdfcc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/tools/rust-analyzer/crates/hir-def/src/body/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)*) => {{
Expand All @@ -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!(); }}
}
Expand All @@ -78,8 +80,6 @@ fn main() { foo!(); }

#[test]
fn recursion_limit() {
cov_mark::check!(your_stack_belongs_to_me);

lower(
r#"
#![recursion_limit = "2"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit b8fdfcc

Please sign in to comment.