Properly decrement recursion count in Expander

This commit is contained in:
Lukas Wirth 2020-12-09 12:26:33 +01:00
parent e2e6b709e6
commit ec415618df

View file

@ -103,8 +103,7 @@ impl Expander {
local_scope: Option<&ItemScope>,
macro_call: ast::MacroCall,
) -> ExpandResult<Option<(Mark, T)>> {
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),