Don't unnecessarily query the ast_id_map for blocks if they aren't interned

This commit is contained in:
Lukas Wirth 2023-04-06 20:19:59 +02:00
parent a1b96b1e00
commit b7c443569a

View File

@ -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),