diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-14 17:32:43 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-14 17:32:43 +0100 |
commit | a50c64a4f13b47de7fa08eb3e6ff222a96389b28 (patch) | |
tree | 30e2cf89854d4f522896bdd7aaedb141f169ef83 /crates/ra_hir_def/src/nameres/collector.rs | |
parent | ff6cf4f84914529f112b5bbefbefb2fb33c7f67a (diff) | |
parent | d47834ee1b8fce7956272e27c9403021940fec8e (diff) |
Merge #5379
5379: Guard against infinite macro expansions r=matklad a=matklad
closes #4463
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/nameres/collector.rs')
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index a35ac1024..e55cc1e55 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -717,6 +717,11 @@ impl DefCollector<'_> { | |||
717 | macro_call_id: MacroCallId, | 717 | macro_call_id: MacroCallId, |
718 | depth: usize, | 718 | depth: usize, |
719 | ) { | 719 | ) { |
720 | if depth > 100 { | ||
721 | mark::hit!(macro_expansion_overflow); | ||
722 | log::warn!("macro expansion is too deep"); | ||
723 | return; | ||
724 | } | ||
720 | let file_id: HirFileId = macro_call_id.as_file(); | 725 | let file_id: HirFileId = macro_call_id.as_file(); |
721 | let item_tree = self.db.item_tree(file_id); | 726 | let item_tree = self.db.item_tree(file_id); |
722 | let mod_dir = self.mod_dirs[&module_id].clone(); | 727 | let mod_dir = self.mod_dirs[&module_id].clone(); |