From 090b2f0e50b48cd22ac48399bd3c4d17c3e92765 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 28 Jan 2021 19:33:00 +0100 Subject: Fix incorrect `FileId` and remove broken shortcut Apparently we were using the crate's root file instead of the file containing the block. --- crates/hir_def/src/nameres.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'crates/hir_def/src/nameres.rs') diff --git a/crates/hir_def/src/nameres.rs b/crates/hir_def/src/nameres.rs index 005b36e02..6169b3bbc 100644 --- a/crates/hir_def/src/nameres.rs +++ b/crates/hir_def/src/nameres.rs @@ -199,16 +199,10 @@ impl DefMap { pub(crate) fn block_def_map_query(db: &dyn DefDatabase, block_id: BlockId) -> Arc { let block: BlockLoc = db.lookup_intern_block(block_id); - let item_tree = db.item_tree(block.ast_id.file_id); - let block_items = item_tree.inner_items_of_block(block.ast_id.value); - let parent = block.module.def_map(db); - if block_items.is_empty() { - // If there are no inner items, nothing new is brought into scope, so we can just return - // the parent DefMap. This keeps DefMap parent chains short. - return parent; - } + // FIXME: It would be good to just return the parent map when the block has no items, but + // we rely on `def_map.block` in a few places, which is `Some` for the inner `DefMap`. let block_info = BlockInfo { block: block_id, parent, parent_module: block.module.local_id }; @@ -216,7 +210,7 @@ impl DefMap { let mut def_map = DefMap::empty(block.module.krate, block_info.parent.edition); def_map.block = Some(block_info); - let def_map = collector::collect_defs(db, def_map, Some(block.ast_id.value)); + let def_map = collector::collect_defs(db, def_map, Some(block.ast_id)); Arc::new(def_map) } -- cgit v1.2.3