Show deprecated completions for deprecated traits

This commit is contained in:
Kirill Bulatov 2021-01-19 01:08:59 +02:00
parent cc663a7b0c
commit ca65488276
8 changed files with 69 additions and 28 deletions

View file

@ -272,15 +272,6 @@ impl ModuleDef {
hir_ty::diagnostics::validate_module_item(db, module.id.krate, id, sink)
}
pub fn as_assoc_item(self, db: &dyn HirDatabase) -> Option<AssocItem> {
match self {
ModuleDef::Function(f) => f.as_assoc_item(db),
ModuleDef::Const(c) => c.as_assoc_item(db),
ModuleDef::TypeAlias(t) => t.as_assoc_item(db),
_ => None,
}
}
}
impl Module {
@ -1060,6 +1051,16 @@ impl AsAssocItem for TypeAlias {
as_assoc_item(db, AssocItem::TypeAlias, self.id)
}
}
impl AsAssocItem for ModuleDef {
fn as_assoc_item(self, db: &dyn HirDatabase) -> Option<AssocItem> {
match self {
ModuleDef::Function(it) => it.as_assoc_item(db),
ModuleDef::Const(it) => it.as_assoc_item(db),
ModuleDef::TypeAlias(it) => it.as_assoc_item(db),
_ => None,
}
}
}
fn as_assoc_item<ID, DEF, CTOR, AST>(db: &dyn HirDatabase, ctor: CTOR, id: ID) -> Option<AssocItem>
where
ID: Lookup<Data = AssocItemLoc<AST>>,