Rename target_ty to self_ty
This commit is contained in:
@@ -214,7 +214,7 @@ fn get_doc_link(db: &RootDatabase, definition: Definition) -> Option<String> {
|
||||
.and_then(|assoc| match assoc.container(db) {
|
||||
AssocItemContainer::Trait(t) => Some(t.into()),
|
||||
AssocItemContainer::Impl(impld) => {
|
||||
impld.target_ty(db).as_adt().map(|adt| adt.into())
|
||||
impld.self_ty(db).as_adt().map(|adt| adt.into())
|
||||
}
|
||||
})
|
||||
.unwrap_or_else(|| f.clone().into()),
|
||||
|
||||
@@ -195,7 +195,7 @@ fn show_implementations_action(db: &RootDatabase, def: Definition) -> Option<Hov
|
||||
let adt = match def {
|
||||
Definition::ModuleDef(ModuleDef::Trait(it)) => return it.try_to_nav(db).map(to_action),
|
||||
Definition::ModuleDef(ModuleDef::Adt(it)) => Some(it),
|
||||
Definition::SelfType(it) => it.target_ty(db).as_adt(),
|
||||
Definition::SelfType(it) => it.self_ty(db).as_adt(),
|
||||
_ => None,
|
||||
}?;
|
||||
adt.try_to_nav(db).map(to_action)
|
||||
@@ -318,7 +318,7 @@ fn definition_owner_name(db: &RootDatabase, def: &Definition) -> Option<String>
|
||||
Definition::ModuleDef(md) => match md {
|
||||
ModuleDef::Function(f) => match f.as_assoc_item(db)?.container(db) {
|
||||
AssocItemContainer::Trait(t) => Some(t.name(db)),
|
||||
AssocItemContainer::Impl(i) => i.target_ty(db).as_adt().map(|adt| adt.name(db)),
|
||||
AssocItemContainer::Impl(i) => i.self_ty(db).as_adt().map(|adt| adt.name(db)),
|
||||
},
|
||||
ModuleDef::Variant(e) => Some(e.parent_enum(db).name(db)),
|
||||
_ => None,
|
||||
@@ -376,7 +376,7 @@ fn hover_for_definition(
|
||||
},
|
||||
Definition::Local(it) => hover_for_local(it, db),
|
||||
Definition::SelfType(impl_def) => {
|
||||
impl_def.target_ty(db).as_adt().and_then(|adt| from_hir_fmt(db, adt, mod_path))
|
||||
impl_def.self_ty(db).as_adt().and_then(|adt| from_hir_fmt(db, adt, mod_path))
|
||||
}
|
||||
Definition::GenericParam(it) => from_hir_fmt(db, it, None),
|
||||
Definition::Label(it) => Some(Markup::fenced_block(&it.name(db))),
|
||||
|
||||
@@ -307,7 +307,7 @@ fn rename_to_self(sema: &Semantics<RootDatabase>, local: hir::Local) -> RenameRe
|
||||
hir::AssocItemContainer::Impl(impl_) => impl_,
|
||||
};
|
||||
let first_param_ty = first_param.ty();
|
||||
let impl_ty = impl_.target_ty(sema.db);
|
||||
let impl_ty = impl_.self_ty(sema.db);
|
||||
let (ty, self_param) = if impl_ty.remove_ref().is_some() {
|
||||
// if the impl is a ref to the type we can just match the `&T` with self directly
|
||||
(first_param_ty.clone(), "self")
|
||||
|
||||
@@ -298,7 +298,7 @@ fn module_def_doctest(sema: &Semantics<RootDatabase>, def: hir::ModuleDef) -> Op
|
||||
// FIXME: this also looks very wrong
|
||||
if let Some(assoc_def) = assoc_def {
|
||||
if let hir::AssocItemContainer::Impl(imp) = assoc_def.container(sema.db) {
|
||||
let ty = imp.target_ty(sema.db);
|
||||
let ty = imp.self_ty(sema.db);
|
||||
if let Some(adt) = ty.as_adt() {
|
||||
let name = adt.name(sema.db);
|
||||
let idx = path.rfind(':').map_or(0, |idx| idx + 1);
|
||||
|
||||
Reference in New Issue
Block a user