hir_def: ignore ast::Type in file_item_tree query

This commit is contained in:
cynecx 2021-04-14 02:36:05 +02:00
parent 28ef7c20d7
commit 14918a3870
2 changed files with 11 additions and 10 deletions

View File

@ -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.

View File

@ -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());
}
}
},