Small cleanup

This commit is contained in:
Aleksey Kladov 2020-02-29 16:57:56 +01:00
parent 099a8f37f5
commit a6a623dfbb

View File

@ -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<Self, Self::ID>;