From c12f7be8d33f9ddfd69f72fb75acc5b12d149527 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Fri, 5 Mar 2021 14:08:36 +0100 Subject: Use `body.block_scopes` in `ChildBySource` --- crates/hir_def/src/child_by_source.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/hir_def/src/child_by_source.rs b/crates/hir_def/src/child_by_source.rs index 6dde74138..2a331dcaf 100644 --- a/crates/hir_def/src/child_by_source.rs +++ b/crates/hir_def/src/child_by_source.rs @@ -160,6 +160,10 @@ impl ChildBySource for EnumId { impl ChildBySource for DefWithBodyId { fn child_by_source_to(&self, db: &dyn DefDatabase, res: &mut DynMap) { let body = db.body(*self); - body.item_scope.child_by_source_to(db, res); + for def_map in body.block_scopes.iter().filter_map(|block| db.block_def_map(*block)) { + // All block expressions are merged into the same map, because they logically all add + // inner items to the containing `DefWithBodyId`. + def_map[def_map.root()].scope.child_by_source_to(db, res); + } } } -- cgit v1.2.3