aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/lib.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-02-03 14:41:13 +0000
committerGitHub <[email protected]>2021-02-03 14:41:13 +0000
commitfd84df9e1bb231f7aa4bcf760e0aff0a6bd10e9f (patch)
tree57fbfe241dcd571b9376b23260299160e0312246 /crates/hir_def/src/lib.rs
parent93ecef53a370703a67f87b90c4640d3e8bf73934 (diff)
parent63744fe128193464eb0ce63fbe6c30c4f98b6135 (diff)
Merge #7541
7541: Use block_def_map in body lowering (third time's the charm) r=jonas-schievink a=jonas-schievink After https://github.com/rust-analyzer/rust-analyzer/pull/7380 and https://github.com/rust-analyzer/rust-analyzer/pull/7506 both had to be reverted, this should have finally resolved all remaining bugs. Most importantly, the optimization to skip `block_def_map` computation when the block contains no inner items was fixed (which fortunately was simpler than expected). I've ran `analysis-stats` on libstd locally, which works fine, and also ran this PR locally for a short while without issues. Note that this *still* has no (or almost no) user-facing impact, because the rest of r-a still relies on some local item support hacks. bors r+ Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir_def/src/lib.rs')
-rw-r--r--crates/hir_def/src/lib.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/crates/hir_def/src/lib.rs b/crates/hir_def/src/lib.rs
index 42b50b5b7..5dd3705b0 100644
--- a/crates/hir_def/src/lib.rs
+++ b/crates/hir_def/src/lib.rs
@@ -81,7 +81,13 @@ pub struct ModuleId {
81impl ModuleId { 81impl ModuleId {
82 pub fn def_map(&self, db: &dyn db::DefDatabase) -> Arc<DefMap> { 82 pub fn def_map(&self, db: &dyn db::DefDatabase) -> Arc<DefMap> {
83 match self.block { 83 match self.block {
84 Some(block) => db.block_def_map(block), 84 Some(block) => {
85 db.block_def_map(block).unwrap_or_else(|| {
86 // NOTE: This should be unreachable - all `ModuleId`s come from their `DefMap`s,
87 // so the `DefMap` here must exist.
88 panic!("no `block_def_map` for `ModuleId` {:?}", self);
89 })
90 }
85 None => db.crate_def_map(self.krate), 91 None => db.crate_def_map(self.krate),
86 } 92 }
87 } 93 }
@@ -239,6 +245,7 @@ pub struct BlockId(salsa::InternId);
239#[derive(Debug, Hash, PartialEq, Eq, Clone)] 245#[derive(Debug, Hash, PartialEq, Eq, Clone)]
240pub struct BlockLoc { 246pub struct BlockLoc {
241 ast_id: AstId<ast::BlockExpr>, 247 ast_id: AstId<ast::BlockExpr>,
248 /// The containing module.
242 module: ModuleId, 249 module: ModuleId,
243} 250}
244impl_intern!(BlockId, BlockLoc, intern_block, lookup_intern_block); 251impl_intern!(BlockId, BlockLoc, intern_block, lookup_intern_block);