diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir_def/src/nameres.rs | 6 |
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 }; |