mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 02:03:53 +00:00
Small cleanup
This commit is contained in:
parent
099a8f37f5
commit
a6a623dfbb
@ -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>;
|
||||
|
Loading…
Reference in New Issue
Block a user