about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2023-04-06 20:19:59 +0200
committerLukas Wirth <lukastw97@gmail.com>2023-04-06 20:19:59 +0200
commitb7c443569a53e624c250058c2181d2c1d299c46f (patch)
tree8beaac6eb56550c047357b716bcca566f9e1c8e4
parenta1b96b1e00a777df9c32efa4d78cbfc64854dbeb (diff)
downloadrust-b7c443569a53e624c250058c2181d2c1d299c46f.tar.gz
rust-b7c443569a53e624c250058c2181d2c1d299c46f.zip
Don't unnecessarily query the ast_id_map for blocks if they aren't interned
-rw-r--r--crates/hir-def/src/body/lower.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/hir-def/src/body/lower.rs b/crates/hir-def/src/body/lower.rs
index 8d12d728f7c..8a773899cfc 100644
--- a/crates/hir-def/src/body/lower.rs
+++ b/crates/hir-def/src/body/lower.rs
@@ -973,10 +973,10 @@ impl ExprCollector<'_> {
         block: ast::BlockExpr,
         mk_block: impl FnOnce(Option<BlockId>, Box<[Statement]>, Option<ExprId>) -> Expr,
     ) -> ExprId {
-        let file_local_id = self.ast_id_map.ast_id(&block);
-        let ast_id = AstId::new(self.expander.current_file_id, file_local_id);
-
-        let block_id = if ItemTree::block_has_items(self.db, ast_id.file_id, &block) {
+        let block_id = if ItemTree::block_has_items(self.db, self.expander.current_file_id, &block)
+        {
+            let file_local_id = self.ast_id_map.ast_id(&block);
+            let ast_id = AstId::new(self.expander.current_file_id, file_local_id);
             Some(self.db.intern_block(BlockLoc {
                 ast_id,
                 module: self.expander.def_map.module_id(self.expander.module),