diff options
author | Lukas Wirth <[email protected]> | 2020-12-09 11:26:33 +0000 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2020-12-09 11:26:33 +0000 |
commit | ec415618dfcac04890c23ff3639bbd13f535c7b6 (patch) | |
tree | 2d205ef51b38dbfc8b07a414e10d0bd62fc0e13f /crates/hir_def | |
parent | e2e6b709e60f22279b755ceae74e579520c9ae3b (diff) |
Properly decrement recursion count in Expander
Diffstat (limited to 'crates/hir_def')
-rw-r--r-- | crates/hir_def/src/body.rs | 4 |
1 files 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 { | |||
103 | local_scope: Option<&ItemScope>, | 103 | local_scope: Option<&ItemScope>, |
104 | macro_call: ast::MacroCall, | 104 | macro_call: ast::MacroCall, |
105 | ) -> ExpandResult<Option<(Mark, T)>> { | 105 | ) -> ExpandResult<Option<(Mark, T)>> { |
106 | self.recursion_limit += 1; | 106 | if self.recursion_limit + 1 > EXPANSION_RECURSION_LIMIT { |
107 | if self.recursion_limit > EXPANSION_RECURSION_LIMIT { | ||
108 | mark::hit!(your_stack_belongs_to_me); | 107 | mark::hit!(your_stack_belongs_to_me); |
109 | return ExpandResult::str_err("reached recursion limit during macro expansion".into()); | 108 | return ExpandResult::str_err("reached recursion limit during macro expansion".into()); |
110 | } | 109 | } |
@@ -165,6 +164,7 @@ impl Expander { | |||
165 | 164 | ||
166 | log::debug!("macro expansion {:#?}", node.syntax()); | 165 | log::debug!("macro expansion {:#?}", node.syntax()); |
167 | 166 | ||
167 | self.recursion_limit += 1; | ||
168 | let mark = Mark { | 168 | let mark = Mark { |
169 | file_id: self.current_file_id, | 169 | file_id: self.current_file_id, |
170 | ast_id_map: mem::take(&mut self.ast_id_map), | 170 | ast_id_map: mem::take(&mut self.ast_id_map), |