Save a bit on empty item trees by deduplicating them

This commit is contained in:
Lukas Wirth 2024-06-23 16:13:01 +02:00
parent 3168ab5b99
commit 5548aecdca
8 changed files with 76 additions and 43 deletions

View file

@ -977,6 +977,14 @@ impl GenericDefId {
_ => None,
}
}
pub fn from_callable(db: &dyn DefDatabase, def: CallableDefId) -> GenericDefId {
match def {
CallableDefId::FunctionId(f) => f.into(),
CallableDefId::StructId(s) => s.into(),
CallableDefId::EnumVariantId(e) => e.lookup(db).parent.into(),
}
}
}
impl From<AssocItemId> for GenericDefId {
@ -1019,16 +1027,6 @@ impl CallableDefId {
}
}
impl GenericDefId {
pub fn from(db: &dyn DefDatabase, def: CallableDefId) -> GenericDefId {
match def {
CallableDefId::FunctionId(f) => f.into(),
CallableDefId::StructId(s) => s.into(),
CallableDefId::EnumVariantId(e) => e.lookup(db).parent.into(),
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum AttrDefId {
ModuleId(ModuleId),