mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Save a bit on empty item trees by deduplicating them
This commit is contained in:
parent
3168ab5b99
commit
5548aecdca
8 changed files with 76 additions and 43 deletions
|
@ -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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue