Skip to content

Commit c2a63b9

Browse files
committed
Rename target_ty to self_ty
1 parent bb6e1bf commit c2a63b9

File tree

16 files changed

+27
-27
lines changed

16 files changed

+27
-27
lines changed

crates/hir/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,9 +1574,9 @@ impl Impl {
15741574
};
15751575

15761576
let filter = |impl_def: &Impl| {
1577-
let target_ty = impl_def.target_ty(db);
1578-
let rref = target_ty.remove_ref();
1579-
ty.equals_ctor(rref.as_ref().map_or(&target_ty.ty, |it| &it.ty))
1577+
let self_ty = impl_def.self_ty(db);
1578+
let rref = self_ty.remove_ref();
1579+
ty.equals_ctor(rref.as_ref().map_or(&self_ty.ty, |it| &it.ty))
15801580
};
15811581

15821582
let mut all = Vec::new();
@@ -1614,16 +1614,16 @@ impl Impl {
16141614

16151615
// FIXME: the return type is wrong. This should be a hir version of
16161616
// `TraitRef` (ie, resolved `TypeRef`).
1617-
pub fn target_trait(self, db: &dyn HirDatabase) -> Option<TraitRef> {
1617+
pub fn trait_(self, db: &dyn HirDatabase) -> Option<TraitRef> {
16181618
db.impl_data(self.id).target_trait.clone()
16191619
}
16201620

1621-
pub fn target_ty(self, db: &dyn HirDatabase) -> Type {
1621+
pub fn self_ty(self, db: &dyn HirDatabase) -> Type {
16221622
let impl_data = db.impl_data(self.id);
16231623
let resolver = self.id.resolver(db.upcast());
16241624
let krate = self.id.lookup(db.upcast()).container.krate();
16251625
let ctx = hir_ty::TyLoweringContext::new(db, &resolver);
1626-
let ty = ctx.lower_ty(&impl_data.target_type);
1626+
let ty = ctx.lower_ty(&impl_data.self_ty);
16271627
Type::new_with_resolver_inner(db, krate, &resolver, ty)
16281628
}
16291629

crates/hir_def/src/data.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl TraitData {
157157
#[derive(Debug, Clone, PartialEq, Eq)]
158158
pub struct ImplData {
159159
pub target_trait: Option<TraitRef>,
160-
pub target_type: TypeRef,
160+
pub self_ty: TypeRef,
161161
pub items: Vec<AssocItemId>,
162162
pub is_negative: bool,
163163
}
@@ -170,7 +170,7 @@ impl ImplData {
170170
let item_tree = impl_loc.id.item_tree(db);
171171
let impl_def = &item_tree[impl_loc.id.value];
172172
let target_trait = impl_def.target_trait.map(|id| item_tree[id].clone());
173-
let target_type = item_tree[impl_def.target_type].clone();
173+
let self_ty = item_tree[impl_def.self_ty].clone();
174174
let is_negative = impl_def.is_negative;
175175
let module_id = impl_loc.container;
176176
let container = AssocContainerId::ImplId(id);
@@ -187,7 +187,7 @@ impl ImplData {
187187
);
188188
let items = items.into_iter().map(|(_, item)| item).collect();
189189

190-
Arc::new(ImplData { target_trait, target_type, items, is_negative })
190+
Arc::new(ImplData { target_trait, self_ty, items, is_negative })
191191
}
192192
}
193193

crates/hir_def/src/item_tree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ pub struct Trait {
730730
pub struct Impl {
731731
pub generic_params: GenericParamsId,
732732
pub target_trait: Option<Idx<TraitRef>>,
733-
pub target_type: Idx<TypeRef>,
733+
pub self_ty: Idx<TypeRef>,
734734
pub is_negative: bool,
735735
pub items: Box<[AssocItem]>,
736736
pub ast_id: FileAstId<ast::Impl>,

crates/hir_def/src/item_tree/lower.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ impl Ctx {
537537
let generic_params =
538538
self.lower_generic_params_and_inner_items(GenericsOwner::Impl, impl_def);
539539
let target_trait = impl_def.trait_().map(|tr| self.lower_trait_ref(&tr));
540-
let target_type = self.lower_type_ref(&impl_def.self_ty()?);
540+
let self_ty = self.lower_type_ref(&impl_def.self_ty()?);
541541
let is_negative = impl_def.excl_token().is_some();
542542

543543
// We cannot use `assoc_items()` here as that does not include macro calls.
@@ -554,7 +554,7 @@ impl Ctx {
554554
})
555555
.collect();
556556
let ast_id = self.source_ast_id_map.ast_id(impl_def);
557-
let res = Impl { generic_params, target_trait, target_type, is_negative, items, ast_id };
557+
let res = Impl { generic_params, target_trait, self_ty, is_negative, items, ast_id };
558558
Some(id(self.data().impls.alloc(res)))
559559
}
560560

crates/hir_ty/src/lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ pub(crate) fn impl_self_ty_query(db: &dyn HirDatabase, impl_id: ImplId) -> Binde
12521252
let generics = generics(db.upcast(), impl_id.into());
12531253
let ctx =
12541254
TyLoweringContext::new(db, &resolver).with_type_param_mode(TypeParamLoweringMode::Variable);
1255-
Binders::new(generics.len(), ctx.lower_ty(&impl_data.target_type))
1255+
Binders::new(generics.len(), ctx.lower_ty(&impl_data.self_ty))
12561256
}
12571257

12581258
pub(crate) fn const_param_ty_query(db: &dyn HirDatabase, def: ConstParamId) -> Ty {

crates/ide/src/doc_links.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ fn get_doc_link(db: &RootDatabase, definition: Definition) -> Option<String> {
214214
.and_then(|assoc| match assoc.container(db) {
215215
AssocItemContainer::Trait(t) => Some(t.into()),
216216
AssocItemContainer::Impl(impld) => {
217-
impld.target_ty(db).as_adt().map(|adt| adt.into())
217+
impld.self_ty(db).as_adt().map(|adt| adt.into())
218218
}
219219
})
220220
.unwrap_or_else(|| f.clone().into()),

crates/ide/src/hover.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ fn show_implementations_action(db: &RootDatabase, def: Definition) -> Option<Hov
195195
let adt = match def {
196196
Definition::ModuleDef(ModuleDef::Trait(it)) => return it.try_to_nav(db).map(to_action),
197197
Definition::ModuleDef(ModuleDef::Adt(it)) => Some(it),
198-
Definition::SelfType(it) => it.target_ty(db).as_adt(),
198+
Definition::SelfType(it) => it.self_ty(db).as_adt(),
199199
_ => None,
200200
}?;
201201
adt.try_to_nav(db).map(to_action)
@@ -318,7 +318,7 @@ fn definition_owner_name(db: &RootDatabase, def: &Definition) -> Option<String>
318318
Definition::ModuleDef(md) => match md {
319319
ModuleDef::Function(f) => match f.as_assoc_item(db)?.container(db) {
320320
AssocItemContainer::Trait(t) => Some(t.name(db)),
321-
AssocItemContainer::Impl(i) => i.target_ty(db).as_adt().map(|adt| adt.name(db)),
321+
AssocItemContainer::Impl(i) => i.self_ty(db).as_adt().map(|adt| adt.name(db)),
322322
},
323323
ModuleDef::Variant(e) => Some(e.parent_enum(db).name(db)),
324324
_ => None,
@@ -376,7 +376,7 @@ fn hover_for_definition(
376376
},
377377
Definition::Local(it) => hover_for_local(it, db),
378378
Definition::SelfType(impl_def) => {
379-
impl_def.target_ty(db).as_adt().and_then(|adt| from_hir_fmt(db, adt, mod_path))
379+
impl_def.self_ty(db).as_adt().and_then(|adt| from_hir_fmt(db, adt, mod_path))
380380
}
381381
Definition::GenericParam(it) => from_hir_fmt(db, it, None),
382382
Definition::Label(it) => Some(Markup::fenced_block(&it.name(db))),

crates/ide/src/references/rename.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ fn rename_to_self(sema: &Semantics<RootDatabase>, local: hir::Local) -> RenameRe
307307
hir::AssocItemContainer::Impl(impl_) => impl_,
308308
};
309309
let first_param_ty = first_param.ty();
310-
let impl_ty = impl_.target_ty(sema.db);
310+
let impl_ty = impl_.self_ty(sema.db);
311311
let (ty, self_param) = if impl_ty.remove_ref().is_some() {
312312
// if the impl is a ref to the type we can just match the `&T` with self directly
313313
(first_param_ty.clone(), "self")

crates/ide/src/runnables.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ fn module_def_doctest(sema: &Semantics<RootDatabase>, def: hir::ModuleDef) -> Op
298298
// FIXME: this also looks very wrong
299299
if let Some(assoc_def) = assoc_def {
300300
if let hir::AssocItemContainer::Impl(imp) = assoc_def.container(sema.db) {
301-
let ty = imp.target_ty(sema.db);
301+
let ty = imp.self_ty(sema.db);
302302
if let Some(adt) = ty.as_adt() {
303303
let name = adt.name(sema.db);
304304
let idx = path.rfind(':').map_or(0, |idx| idx + 1);

crates/ide_assists/src/handlers/generate_default_from_new.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ fn is_default_implemented(ctx: &AssistContext, impl_: &Impl) -> bool {
9292
None => return false,
9393
};
9494

95-
let ty = impl_def.target_ty(db);
95+
let ty = impl_def.self_ty(db);
9696
let krate = impl_def.module(db).krate();
9797
let default = FamousDefs(&ctx.sema, Some(krate)).core_default_Default();
9898
let default_trait = match default {

0 commit comments

Comments
 (0)