From b7c443569a53e624c250058c2181d2c1d299c46f Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 6 Apr 2023 20:19:59 +0200 Subject: [PATCH] Don't unnecessarily query the ast_id_map for blocks if they aren't interned --- crates/hir-def/src/body/lower.rs | 8 ++++---- 1 file 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, Box<[Statement]>, Option) -> 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),