aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-12-09 11:35:18 +0000
committerGitHub <[email protected]>2020-12-09 11:35:18 +0000
commitcd83ded8ee89e79d6b446518c3d74f6c18f8f5d9 (patch)
tree9d7f1c13172bb32cecc5f64583a369eeb3280a26 /crates
parente4c6c70d5de153c8fb272a83d1e4dab98658022b (diff)
parentec415618dfcac04890c23ff3639bbd13f535c7b6 (diff)
Merge #6774
6774: Increment recursion count in Expander only on success r=lnicola a=Veykril Fixes #6764 Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_def/src/body.rs4
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),