From 14918a3870d568778473f0a5697a547b85acf20a Mon Sep 17 00:00:00 2001 From: cynecx Date: Wed, 14 Apr 2021 02:36:05 +0200 Subject: hir_def: ignore ast::Type in file_item_tree query --- crates/hir_def/src/item_tree.rs | 5 +++++ crates/hir_def/src/item_tree/lower.rs | 16 ++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'crates') diff --git a/crates/hir_def/src/item_tree.rs b/crates/hir_def/src/item_tree.rs index 94e08f835..fed285505 100644 --- a/crates/hir_def/src/item_tree.rs +++ b/crates/hir_def/src/item_tree.rs @@ -104,6 +104,11 @@ impl ItemTree { // items and expanded during block DefMap computation return Default::default(); }, + ast::Type(_ty) => { + // FIXME: This occurs because macros in type position are treated as inner + // items and expanded during block DefMap computation + return Default::default(); + }, ast::Expr(e) => { // Macros can expand to expressions. We return an empty item tree in this case, but // still need to collect inner items. diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs index 2975786dd..45b099cf3 100644 --- a/crates/hir_def/src/item_tree/lower.rs +++ b/crates/hir_def/src/item_tree/lower.rs @@ -189,16 +189,12 @@ impl Ctx { block_stack.push(self.source_ast_id_map.ast_id(&block)); }, ast::Item(item) => { - // FIXME: This triggers for macro calls in expression/pattern - if let Some(SyntaxKind::MACRO_TYPE) = node.parent().map(|p| p.kind()) { - // Ignore macros at type position - } else { - let mod_items = self.lower_mod_item(&item, true); - let current_block = block_stack.last(); - if let (Some(mod_items), Some(block)) = (mod_items, current_block) { - if !mod_items.0.is_empty() { - self.data().inner_items.entry(*block).or_default().extend(mod_items.0.iter().copied()); - } + // FIXME: This triggers for macro calls in expression/pattern/type position + let mod_items = self.lower_mod_item(&item, true); + let current_block = block_stack.last(); + if let (Some(mod_items), Some(block)) = (mod_items, current_block) { + if !mod_items.0.is_empty() { + self.data().inner_items.entry(*block).or_default().extend(mod_items.0.iter().copied()); } } }, -- cgit v1.2.3