mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
Refactor a bit to prepare for resolving trait assoc items
This commit is contained in:
parent
913ab1ec0a
commit
828d60574f
10 changed files with 85 additions and 54 deletions
|
@ -749,6 +749,10 @@ impl Const {
|
|||
db.const_data(self)
|
||||
}
|
||||
|
||||
pub fn name(&self, db: &impl HirDatabase) -> Option<Name> {
|
||||
self.data(db).name().cloned()
|
||||
}
|
||||
|
||||
pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> {
|
||||
db.infer(self.into())
|
||||
}
|
||||
|
@ -1019,3 +1023,30 @@ impl Container {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum AssocItem {
|
||||
Function(Function),
|
||||
Const(Const),
|
||||
TypeAlias(TypeAlias),
|
||||
}
|
||||
|
||||
impl From<TraitItem> for AssocItem {
|
||||
fn from(t: TraitItem) -> Self {
|
||||
match t {
|
||||
TraitItem::Function(f) => AssocItem::Function(f),
|
||||
TraitItem::Const(c) => AssocItem::Const(c),
|
||||
TraitItem::TypeAlias(t) => AssocItem::TypeAlias(t),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::ImplItem> for AssocItem {
|
||||
fn from(i: crate::ImplItem) -> Self {
|
||||
match i {
|
||||
crate::ImplItem::Method(f) => AssocItem::Function(f),
|
||||
crate::ImplItem::Const(c) => AssocItem::Const(c),
|
||||
crate::ImplItem::TypeAlias(t) => AssocItem::TypeAlias(t),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue