diff --git a/crates/hir/src/semantics/source_to_def.rs b/crates/hir/src/semantics/source_to_def.rs index 4d4b26b8d8..773eab7931 100644 --- a/crates/hir/src/semantics/source_to_def.rs +++ b/crates/hir/src/semantics/source_to_def.rs @@ -106,7 +106,7 @@ use syntax::{ use crate::{db::HirDatabase, InFile}; -pub(super) type SourceToDefCache = FxHashMap>; +pub(super) type SourceToDefCache = FxHashMap<(ChildContainer, HirFileId), DynMap>; pub(super) struct SourceToDefCtx<'a, 'b> { pub(super) db: &'b dyn HirDatabase, @@ -257,8 +257,9 @@ impl SourceToDefCtx<'_, '_> { fn cache_for(&mut self, container: ChildContainer, file_id: HirFileId) -> &DynMap { let db = self.db; - let dyn_maps = self.cache.entry(container).or_default(); - dyn_maps.entry(file_id).or_insert_with(|| container.child_by_source(db, file_id)) + self.cache + .entry((container, file_id)) + .or_insert_with(|| container.child_by_source(db, file_id)) } pub(super) fn type_param_to_def(&mut self, src: InFile) -> Option {