From a6a623dfbb40b79cac7857165114fa11a25e4e1f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 29 Feb 2020 16:57:56 +0100 Subject: Small cleanup --- crates/ra_hir/src/source_binder.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 4353e25ac..439a4d5db 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs @@ -101,15 +101,7 @@ impl SourceBinder { } fn child_by_source(&mut self, db: &impl HirDatabase, container: ChildContainer) -> &DynMap { - self.child_by_source_cache.entry(container).or_insert_with(|| match container { - ChildContainer::DefWithBodyId(it) => it.child_by_source(db), - ChildContainer::ModuleId(it) => it.child_by_source(db), - ChildContainer::TraitId(it) => it.child_by_source(db), - ChildContainer::ImplId(it) => it.child_by_source(db), - ChildContainer::EnumId(it) => it.child_by_source(db), - ChildContainer::VariantId(it) => it.child_by_source(db), - ChildContainer::GenericDefId(it) => it.child_by_source(db), - }) + self.child_by_source_cache.entry(container).or_insert_with(|| container.child_by_source(db)) } } @@ -145,6 +137,20 @@ impl_froms! { GenericDefId } +impl ChildContainer { + fn child_by_source(self, db: &impl HirDatabase) -> DynMap { + match self { + ChildContainer::DefWithBodyId(it) => it.child_by_source(db), + ChildContainer::ModuleId(it) => it.child_by_source(db), + ChildContainer::TraitId(it) => it.child_by_source(db), + ChildContainer::ImplId(it) => it.child_by_source(db), + ChildContainer::EnumId(it) => it.child_by_source(db), + ChildContainer::VariantId(it) => it.child_by_source(db), + ChildContainer::GenericDefId(it) => it.child_by_source(db), + } + } +} + pub(crate) trait ToIdByKey: Sized + AstNode + 'static { type ID: Sized + Copy + 'static; const KEY: Key; -- cgit v1.2.3