Skip to content

Commit cd83ded

Browse files
bors[bot]Veykril
andauthored
Merge #6774
6774: Increment recursion count in Expander only on success r=lnicola a=Veykril Fixes #6764 Co-authored-by: Lukas Wirth <[email protected]>
2 parents e4c6c70 + ec41561 commit cd83ded

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/hir_def/src/body.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ impl Expander {
103103
local_scope: Option<&ItemScope>,
104104
macro_call: ast::MacroCall,
105105
) -> ExpandResult<Option<(Mark, T)>> {
106-
self.recursion_limit += 1;
107-
if self.recursion_limit > EXPANSION_RECURSION_LIMIT {
106+
if self.recursion_limit + 1 > EXPANSION_RECURSION_LIMIT {
108107
mark::hit!(your_stack_belongs_to_me);
109108
return ExpandResult::str_err("reached recursion limit during macro expansion".into());
110109
}
@@ -165,6 +164,7 @@ impl Expander {
165164

166165
log::debug!("macro expansion {:#?}", node.syntax());
167166

167+
self.recursion_limit += 1;
168168
let mark = Mark {
169169
file_id: self.current_file_id,
170170
ast_id_map: mem::take(&mut self.ast_id_map),

0 commit comments

Comments
 (0)