aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-02-01 12:32:43 +0000
committerJonas Schievink <[email protected]>2021-02-01 12:33:18 +0000
commitb4aa860cac98d69fe4e38602904a6e9e6569e5a6 (patch)
tree2d6a120c6bf8219f801c305dfd0b5ef4d19039a1 /crates/hir_def/src
parent80ae583dc02967f329254ed0949f1158c5304d83 (diff)
Shortcut `block_def_map` if there's no inner items
This previously didn't work, but apparently only because of the wonky test setup
Diffstat (limited to 'crates/hir_def/src')
-rw-r--r--crates/hir_def/src/nameres.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/crates/hir_def/src/nameres.rs b/crates/hir_def/src/nameres.rs
index 6169b3bbc..9839761d1 100644
--- a/crates/hir_def/src/nameres.rs
+++ b/crates/hir_def/src/nameres.rs
@@ -201,8 +201,10 @@ impl DefMap {
201 let block: BlockLoc = db.lookup_intern_block(block_id); 201 let block: BlockLoc = db.lookup_intern_block(block_id);
202 let parent = block.module.def_map(db); 202 let parent = block.module.def_map(db);
203 203
204 // FIXME: It would be good to just return the parent map when the block has no items, but 204 let item_tree = db.item_tree(block.ast_id.file_id);
205 // we rely on `def_map.block` in a few places, which is `Some` for the inner `DefMap`. 205 if item_tree.inner_items_of_block(block.ast_id.value).is_empty() {
206 return parent.clone();
207 }
206 208
207 let block_info = 209 let block_info =
208 BlockInfo { block: block_id, parent, parent_module: block.module.local_id }; 210 BlockInfo { block: block_id, parent, parent_module: block.module.local_id };