aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-04-04 02:18:13 +0100
committerGitHub <[email protected]>2021-04-04 02:18:13 +0100
commit3ea5ea1324310af07a8bb04fb3314b087d7153c9 (patch)
tree5f51be034c65e10f109957cc9ae48f8685ee63a6 /crates
parent4c8ee9a53190917f9171a3272c8061d926c2fcbe (diff)
parent9b13e1bb918888af0c456c554235e9a981d2ba0c (diff)
Merge #8323
8323: Only remember blocks that have a DefMap r=jonas-schievink a=jonas-schievink bors r+ Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_def/src/body.rs2
-rw-r--r--crates/hir_def/src/body/lower.rs12
2 files changed, 8 insertions, 6 deletions
diff --git a/crates/hir_def/src/body.rs b/crates/hir_def/src/body.rs
index ad3d5afbe..99d98b17e 100644
--- a/crates/hir_def/src/body.rs
+++ b/crates/hir_def/src/body.rs
@@ -317,7 +317,7 @@ impl Body {
317 ) -> impl Iterator<Item = (BlockId, Arc<DefMap>)> + '_ { 317 ) -> impl Iterator<Item = (BlockId, Arc<DefMap>)> + '_ {
318 self.block_scopes 318 self.block_scopes
319 .iter() 319 .iter()
320 .filter_map(move |block| db.block_def_map(*block).map(|map| (*block, map))) 320 .map(move |block| (*block, db.block_def_map(*block).expect("block ID without DefMap")))
321 } 321 }
322 322
323 fn new( 323 fn new(
diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs
index 229e81dd4..63e89a1f4 100644
--- a/crates/hir_def/src/body/lower.rs
+++ b/crates/hir_def/src/body/lower.rs
@@ -673,12 +673,14 @@ impl ExprCollector<'_> {
673 let block_loc = 673 let block_loc =
674 BlockLoc { ast_id, module: self.expander.def_map.module_id(self.expander.module) }; 674 BlockLoc { ast_id, module: self.expander.def_map.module_id(self.expander.module) };
675 let block_id = self.db.intern_block(block_loc); 675 let block_id = self.db.intern_block(block_loc);
676 self.body.block_scopes.push(block_id);
677 676
678 let opt_def_map = self.db.block_def_map(block_id); 677 let (module, def_map) = match self.db.block_def_map(block_id) {
679 let has_def_map = opt_def_map.is_some(); 678 Some(def_map) => {
680 let def_map = opt_def_map.unwrap_or_else(|| self.expander.def_map.clone()); 679 self.body.block_scopes.push(block_id);
681 let module = if has_def_map { def_map.root() } else { self.expander.module }; 680 (def_map.root(), def_map)
681 }
682 None => (self.expander.module, self.expander.def_map.clone()),
683 };
682 let prev_def_map = mem::replace(&mut self.expander.def_map, def_map); 684 let prev_def_map = mem::replace(&mut self.expander.def_map, def_map);
683 let prev_local_module = mem::replace(&mut self.expander.module, module); 685 let prev_local_module = mem::replace(&mut self.expander.module, module);
684 let prev_statements = std::mem::take(&mut self.statements_in_scope); 686 let prev_statements = std::mem::take(&mut self.statements_in_scope);