From ec415618dfcac04890c23ff3639bbd13f535c7b6 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 9 Dec 2020 12:26:33 +0100 Subject: Properly decrement recursion count in Expander --- crates/hir_def/src/body.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/hir_def/src/body.rs b/crates/hir_def/src/body.rs index 92bcc1705..c5d6f5fb0 100644 --- a/crates/hir_def/src/body.rs +++ b/crates/hir_def/src/body.rs @@ -103,8 +103,7 @@ impl Expander { local_scope: Option<&ItemScope>, macro_call: ast::MacroCall, ) -> ExpandResult> { - self.recursion_limit += 1; - if self.recursion_limit > EXPANSION_RECURSION_LIMIT { + if self.recursion_limit + 1 > EXPANSION_RECURSION_LIMIT { mark::hit!(your_stack_belongs_to_me); return ExpandResult::str_err("reached recursion limit during macro expansion".into()); } @@ -165,6 +164,7 @@ impl Expander { log::debug!("macro expansion {:#?}", node.syntax()); + self.recursion_limit += 1; let mark = Mark { file_id: self.current_file_id, ast_id_map: mem::take(&mut self.ast_id_map), -- cgit v1.2.3