Skip to content

Commit 13f4356

Browse files
jonas-schievinkJonas Schievink
authored andcommitted
Store inner BlockIds in Body
1 parent 8da50c9 commit 13f4356

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

crates/hir_def/src/body.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use crate::{
3232
nameres::DefMap,
3333
path::{ModPath, Path},
3434
src::HasSource,
35-
AsMacroCall, DefWithBodyId, HasModule, LocalModuleId, Lookup, ModuleId,
35+
AsMacroCall, BlockId, DefWithBodyId, HasModule, LocalModuleId, Lookup, ModuleId,
3636
};
3737

3838
/// A subset of Expander that only deals with cfg attributes. We only need it to
@@ -226,6 +226,8 @@ pub struct Body {
226226
pub params: Vec<PatId>,
227227
/// The `ExprId` of the actual body expression.
228228
pub body_expr: ExprId,
229+
/// Block expressions in this body that may contain inner items.
230+
pub block_scopes: Vec<BlockId>,
229231
pub item_scope: ItemScope,
230232
_c: Count<Self>,
231233
}

crates/hir_def/src/body/lower.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ pub(super) fn lower(
7676
labels: Arena::default(),
7777
params: Vec::new(),
7878
body_expr: dummy_expr_id(),
79+
block_scopes: Vec::new(),
7980
item_scope: Default::default(),
8081
_c: Count::new(),
8182
},
@@ -700,6 +701,8 @@ impl ExprCollector<'_> {
700701
let block_loc =
701702
BlockLoc { ast_id, module: self.expander.def_map.module_id(self.expander.module) };
702703
let block_id = self.db.intern_block(block_loc);
704+
self.body.block_scopes.push(block_id);
705+
703706
let opt_def_map = self.db.block_def_map(block_id);
704707
let has_def_map = opt_def_map.is_some();
705708
let def_map = opt_def_map.unwrap_or_else(|| self.expander.def_map.clone());

0 commit comments

Comments
 (0)