Shortcut block_def_map if there's no inner items

This previously didn't work, but apparently only because of the wonky
test setup
This commit is contained in:
Jonas Schievink 2021-02-01 13:32:43 +01:00
parent 80ae583dc0
commit b4aa860cac

View File

@ -201,8 +201,10 @@ impl DefMap {
let block: BlockLoc = db.lookup_intern_block(block_id);
let parent = block.module.def_map(db);
// 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 item_tree = db.item_tree(block.ast_id.file_id);
if item_tree.inner_items_of_block(block.ast_id.value).is_empty() {
return parent.clone();
}
let block_info =
BlockInfo { block: block_id, parent, parent_module: block.module.local_id };