Skip to content

Commit 14918a3

Browse files
committed
hir_def: ignore ast::Type in file_item_tree query
1 parent 28ef7c2 commit 14918a3

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

crates/hir_def/src/item_tree.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ impl ItemTree {
104104
// items and expanded during block DefMap computation
105105
return Default::default();
106106
},
107+
ast::Type(_ty) => {
108+
// FIXME: This occurs because macros in type position are treated as inner
109+
// items and expanded during block DefMap computation
110+
return Default::default();
111+
},
107112
ast::Expr(e) => {
108113
// Macros can expand to expressions. We return an empty item tree in this case, but
109114
// still need to collect inner items.

crates/hir_def/src/item_tree/lower.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,12 @@ impl Ctx {
189189
block_stack.push(self.source_ast_id_map.ast_id(&block));
190190
},
191191
ast::Item(item) => {
192-
// FIXME: This triggers for macro calls in expression/pattern
193-
if let Some(SyntaxKind::MACRO_TYPE) = node.parent().map(|p| p.kind()) {
194-
// Ignore macros at type position
195-
} else {
196-
let mod_items = self.lower_mod_item(&item, true);
197-
let current_block = block_stack.last();
198-
if let (Some(mod_items), Some(block)) = (mod_items, current_block) {
199-
if !mod_items.0.is_empty() {
200-
self.data().inner_items.entry(*block).or_default().extend(mod_items.0.iter().copied());
201-
}
192+
// FIXME: This triggers for macro calls in expression/pattern/type position
193+
let mod_items = self.lower_mod_item(&item, true);
194+
let current_block = block_stack.last();
195+
if let (Some(mod_items), Some(block)) = (mod_items, current_block) {
196+
if !mod_items.0.is_empty() {
197+
self.data().inner_items.entry(*block).or_default().extend(mod_items.0.iter().copied());
202198
}
203199
}
204200
},

0 commit comments

Comments
 (0)