Stop fetching ItemTrees for no reason

This commit is contained in:
Jonas Schievink 2021-03-10 02:32:16 +01:00
parent 654313dbc7
commit 7beec8fda1

View File

@ -1,7 +1,7 @@
//! Transforms `ast::Expr` into an equivalent `hir_def::expr::Expr` //! Transforms `ast::Expr` into an equivalent `hir_def::expr::Expr`
//! representation. //! representation.
use std::{mem, sync::Arc}; use std::mem;
use either::Either; use either::Either;
use hir_expand::{ use hir_expand::{
@ -11,7 +11,6 @@
}; };
use la_arena::Arena; use la_arena::Arena;
use profile::Count; use profile::Count;
use rustc_hash::FxHashMap;
use syntax::{ use syntax::{
ast::{ ast::{
self, ArgListOwner, ArrayExprKind, AstChildren, LiteralKind, LoopBodyOwner, NameOwner, self, ArgListOwner, ArrayExprKind, AstChildren, LiteralKind, LoopBodyOwner, NameOwner,
@ -32,7 +31,6 @@
Statement, Statement,
}, },
item_scope::BuiltinShadowMode, item_scope::BuiltinShadowMode,
item_tree::ItemTree,
path::{GenericArgs, Path}, path::{GenericArgs, Path},
type_ref::{Mutability, Rawness, TypeRef}, type_ref::{Mutability, Rawness, TypeRef},
AdtId, BlockLoc, ModuleDefId, AdtId, BlockLoc, ModuleDefId,
@ -63,7 +61,6 @@ pub(super) fn lower(
params: Option<ast::ParamList>, params: Option<ast::ParamList>,
body: Option<ast::Expr>, body: Option<ast::Expr>,
) -> (Body, BodySourceMap) { ) -> (Body, BodySourceMap) {
let item_tree = db.item_tree(expander.current_file_id);
ExprCollector { ExprCollector {
db, db,
source_map: BodySourceMap::default(), source_map: BodySourceMap::default(),
@ -76,11 +73,6 @@ pub(super) fn lower(
block_scopes: Vec::new(), block_scopes: Vec::new(),
_c: Count::new(), _c: Count::new(),
}, },
item_trees: {
let mut map = FxHashMap::default();
map.insert(expander.current_file_id, item_tree);
map
},
expander, expander,
} }
.collect(params, body) .collect(params, body)
@ -91,8 +83,6 @@ struct ExprCollector<'a> {
expander: Expander, expander: Expander,
body: Body, body: Body,
source_map: BodySourceMap, source_map: BodySourceMap,
item_trees: FxHashMap<HirFileId, Arc<ItemTree>>,
} }
impl ExprCollector<'_> { impl ExprCollector<'_> {
@ -589,9 +579,6 @@ fn collect_macro_call<F: FnMut(&mut Self, Option<T>), T: ast::AstNode>(
} else { } else {
self.source_map.expansions.insert(macro_call, self.expander.current_file_id); self.source_map.expansions.insert(macro_call, self.expander.current_file_id);
let item_tree = self.db.item_tree(self.expander.current_file_id);
self.item_trees.insert(self.expander.current_file_id, item_tree);
let id = collector(self, Some(expansion)); let id = collector(self, Some(expansion));
self.expander.exit(self.db, mark); self.expander.exit(self.db, mark);
id id