aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def/src')
-rw-r--r--crates/hir_def/src/body.rs4
-rw-r--r--crates/hir_def/src/body/lower.rs3
2 files changed, 6 insertions, 1 deletions
diff --git a/crates/hir_def/src/body.rs b/crates/hir_def/src/body.rs
index b1a3fe1cb..9dbe717e5 100644
--- a/crates/hir_def/src/body.rs
+++ b/crates/hir_def/src/body.rs
@@ -32,7 +32,7 @@ use crate::{
32 nameres::DefMap, 32 nameres::DefMap,
33 path::{ModPath, Path}, 33 path::{ModPath, Path},
34 src::HasSource, 34 src::HasSource,
35 AsMacroCall, DefWithBodyId, HasModule, LocalModuleId, Lookup, ModuleId, 35 AsMacroCall, BlockId, DefWithBodyId, HasModule, LocalModuleId, Lookup, ModuleId,
36}; 36};
37 37
38/// A subset of Expander that only deals with cfg attributes. We only need it to 38/// A subset of Expander that only deals with cfg attributes. We only need it to
@@ -226,6 +226,8 @@ pub struct Body {
226 pub params: Vec<PatId>, 226 pub params: Vec<PatId>,
227 /// The `ExprId` of the actual body expression. 227 /// The `ExprId` of the actual body expression.
228 pub body_expr: ExprId, 228 pub body_expr: ExprId,
229 /// Block expressions in this body that may contain inner items.
230 pub block_scopes: Vec<BlockId>,
229 pub item_scope: ItemScope, 231 pub item_scope: ItemScope,
230 _c: Count<Self>, 232 _c: Count<Self>,
231} 233}
diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs
index d4abe819d..c3aa1dc37 100644
--- a/crates/hir_def/src/body/lower.rs
+++ b/crates/hir_def/src/body/lower.rs
@@ -76,6 +76,7 @@ pub(super) fn lower(
76 labels: Arena::default(), 76 labels: Arena::default(),
77 params: Vec::new(), 77 params: Vec::new(),
78 body_expr: dummy_expr_id(), 78 body_expr: dummy_expr_id(),
79 block_scopes: Vec::new(),
79 item_scope: Default::default(), 80 item_scope: Default::default(),
80 _c: Count::new(), 81 _c: Count::new(),
81 }, 82 },
@@ -700,6 +701,8 @@ impl ExprCollector<'_> {
700 let block_loc = 701 let block_loc =
701 BlockLoc { ast_id, module: self.expander.def_map.module_id(self.expander.module) }; 702 BlockLoc { ast_id, module: self.expander.def_map.module_id(self.expander.module) };
702 let block_id = self.db.intern_block(block_loc); 703 let block_id = self.db.intern_block(block_loc);
704 self.body.block_scopes.push(block_id);
705
703 let opt_def_map = self.db.block_def_map(block_id); 706 let opt_def_map = self.db.block_def_map(block_id);
704 let has_def_map = opt_def_map.is_some(); 707 let has_def_map = opt_def_map.is_some();
705 let def_map = opt_def_map.unwrap_or_else(|| self.expander.def_map.clone()); 708 let def_map = opt_def_map.unwrap_or_else(|| self.expander.def_map.clone());