From 2ae31e34b1a345ceea23198a7e9e32e557cdbb4d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 17 Dec 2020 14:36:15 +0300 Subject: Rename ImplDef -> Impl We used to have `Def` suffix for all symbols, but we moved off from that. `FunctionDef` isn't better than `Function`. Looks like we've forgot to change `Impl` though! --- crates/hir/src/code_model.rs | 22 +++++++++++----------- crates/hir/src/from_id.rs | 6 +++--- crates/hir/src/has_source.rs | 6 +++--- crates/hir/src/lib.rs | 2 +- crates/hir/src/semantics.rs | 6 +++--- crates/ide/src/display/navigation_target.rs | 2 +- crates/ide/src/doc_links.rs | 2 +- crates/ide/src/goto_implementation.rs | 6 +++--- crates/ide/src/hover.rs | 2 +- crates/ide/src/runnables.rs | 2 +- crates/ide_db/src/defs.rs | 4 ++-- crates/ide_db/src/search.rs | 2 +- 12 files changed, 31 insertions(+), 31 deletions(-) diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index b1a1bc337..84e8c8047 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs @@ -402,9 +402,9 @@ impl Module { def_map[self.id.local_id].scope.declarations().map(ModuleDef::from).collect() } - pub fn impl_defs(self, db: &dyn HirDatabase) -> Vec { + pub fn impl_defs(self, db: &dyn HirDatabase) -> Vec { let def_map = db.crate_def_map(self.id.krate); - def_map[self.id.local_id].scope.impls().map(ImplDef::from).collect() + def_map[self.id.local_id].scope.impls().map(Impl::from).collect() } pub(crate) fn with_module_id(self, module_id: LocalModuleId) -> Module { @@ -1007,7 +1007,7 @@ pub enum AssocItem { } pub enum AssocItemContainer { Trait(Trait), - ImplDef(ImplDef), + Impl(Impl), } pub trait AsAssocItem { fn as_assoc_item(self, db: &dyn HirDatabase) -> Option; @@ -1064,7 +1064,7 @@ impl AssocItem { }; match container { AssocContainerId::TraitId(id) => AssocItemContainer::Trait(id.into()), - AssocContainerId::ImplId(id) => AssocItemContainer::ImplDef(id.into()), + AssocContainerId::ImplId(id) => AssocItemContainer::Impl(id.into()), AssocContainerId::ContainerId(_) => panic!("invalid AssocItem"), } } @@ -1086,7 +1086,7 @@ pub enum GenericDef { Adt(Adt), Trait(Trait), TypeAlias(TypeAlias), - ImplDef(ImplDef), + Impl(Impl), // enum variants cannot have generics themselves, but their parent enums // can, and this makes some code easier to write EnumVariant(EnumVariant), @@ -1098,7 +1098,7 @@ impl_from!( Adt(Struct, Enum, Union), Trait, TypeAlias, - ImplDef, + Impl, EnumVariant, Const for GenericDef @@ -1268,18 +1268,18 @@ impl LifetimeParam { // FIXME: rename from `ImplDef` to `Impl` #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -pub struct ImplDef { +pub struct Impl { pub(crate) id: ImplId, } -impl ImplDef { - pub fn all_in_crate(db: &dyn HirDatabase, krate: Crate) -> Vec { +impl Impl { + pub fn all_in_crate(db: &dyn HirDatabase, krate: Crate) -> Vec { let inherent = db.inherent_impls_in_crate(krate.id); let trait_ = db.trait_impls_in_crate(krate.id); inherent.all_impls().chain(trait_.all_impls()).map(Self::from).collect() } - pub fn for_trait(db: &dyn HirDatabase, krate: Crate, trait_: Trait) -> Vec { + pub fn for_trait(db: &dyn HirDatabase, krate: Crate, trait_: Trait) -> Vec { let impls = db.trait_impls_in_crate(krate.id); impls.for_trait(trait_.id).map(Self::from).collect() } @@ -1904,7 +1904,7 @@ pub enum ScopeDef { ModuleDef(ModuleDef), MacroDef(MacroDef), GenericParam(TypeParam), - ImplSelfType(ImplDef), + ImplSelfType(Impl), AdtSelfType(Adt), Local(Local), Unknown, diff --git a/crates/hir/src/from_id.rs b/crates/hir/src/from_id.rs index dd3fcfe4a..8d0f84508 100644 --- a/crates/hir/src/from_id.rs +++ b/crates/hir/src/from_id.rs @@ -39,7 +39,7 @@ from_id![ (hir_def::StaticId, crate::Static), (hir_def::ConstId, crate::Const), (hir_def::FunctionId, crate::Function), - (hir_def::ImplId, crate::ImplDef), + (hir_def::ImplId, crate::Impl), (hir_def::TypeParamId, crate::TypeParam), (hir_def::LifetimeParamId, crate::LifetimeParam), (hir_expand::MacroDefId, crate::MacroDef) @@ -146,7 +146,7 @@ impl From for GenericDefId { GenericDef::Adt(it) => GenericDefId::AdtId(it.into()), GenericDef::Trait(it) => GenericDefId::TraitId(it.id), GenericDef::TypeAlias(it) => GenericDefId::TypeAliasId(it.id), - GenericDef::ImplDef(it) => GenericDefId::ImplId(it.id), + GenericDef::Impl(it) => GenericDefId::ImplId(it.id), GenericDef::EnumVariant(it) => { GenericDefId::EnumVariantId(EnumVariantId { parent: it.parent.id, local_id: it.id }) } @@ -162,7 +162,7 @@ impl From for GenericDef { GenericDefId::AdtId(it) => GenericDef::Adt(it.into()), GenericDefId::TraitId(it) => GenericDef::Trait(it.into()), GenericDefId::TypeAliasId(it) => GenericDef::TypeAlias(it.into()), - GenericDefId::ImplId(it) => GenericDef::ImplDef(it.into()), + GenericDefId::ImplId(it) => GenericDef::Impl(it.into()), GenericDefId::EnumVariantId(it) => { GenericDef::EnumVariant(EnumVariant { parent: it.parent.into(), id: it.local_id }) } diff --git a/crates/hir/src/has_source.rs b/crates/hir/src/has_source.rs index 11ae63c31..c5b81b252 100644 --- a/crates/hir/src/has_source.rs +++ b/crates/hir/src/has_source.rs @@ -10,8 +10,8 @@ use hir_expand::InFile; use syntax::ast; use crate::{ - db::HirDatabase, Const, Enum, EnumVariant, Field, FieldSource, Function, ImplDef, - LifetimeParam, MacroDef, Module, Static, Struct, Trait, TypeAlias, TypeParam, Union, + db::HirDatabase, Const, Enum, EnumVariant, Field, FieldSource, Function, Impl, LifetimeParam, + MacroDef, Module, Static, Struct, Trait, TypeAlias, TypeParam, Union, }; pub trait HasSource { @@ -118,7 +118,7 @@ impl HasSource for MacroDef { } } } -impl HasSource for ImplDef { +impl HasSource for Impl { type Ast = ast::Impl; fn source(self, db: &dyn HirDatabase) -> InFile { self.id.lookup(db.upcast()).source(db.upcast()) diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 0f399a2c6..3f4f8d8e4 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -35,7 +35,7 @@ pub use crate::{ code_model::{ Access, Adt, AsAssocItem, AssocItem, AssocItemContainer, Callable, CallableKind, Const, Crate, CrateDependency, DefWithBody, Enum, EnumVariant, Field, FieldSource, Function, - GenericDef, HasVisibility, ImplDef, LifetimeParam, Local, MacroDef, Module, ModuleDef, + GenericDef, HasVisibility, Impl, LifetimeParam, Local, MacroDef, Module, ModuleDef, ScopeDef, Static, Struct, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, }, has_source::HasSource, diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index ee2074602..83ec91f58 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs @@ -25,7 +25,7 @@ use crate::{ diagnostics::Diagnostic, semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx}, source_analyzer::{resolve_hir_path, SourceAnalyzer}, - AssocItem, Callable, Crate, Field, Function, HirFileId, ImplDef, InFile, LifetimeParam, Local, + AssocItem, Callable, Crate, Field, Function, HirFileId, Impl, InFile, LifetimeParam, Local, MacroDef, Module, ModuleDef, Name, Path, ScopeDef, Trait, Type, TypeAlias, TypeParam, VariantDef, }; @@ -38,7 +38,7 @@ pub enum PathResolution { Local(Local), /// A generic parameter TypeParam(TypeParam), - SelfType(ImplDef), + SelfType(Impl), Macro(MacroDef), AssocItem(AssocItem), } @@ -708,7 +708,7 @@ to_def_impls![ (crate::Enum, ast::Enum, enum_to_def), (crate::Union, ast::Union, union_to_def), (crate::Trait, ast::Trait, trait_to_def), - (crate::ImplDef, ast::Impl, impl_to_def), + (crate::Impl, ast::Impl, impl_to_def), (crate::TypeAlias, ast::TypeAlias, type_alias_to_def), (crate::Const, ast::Const, const_to_def), (crate::Static, ast::Static, static_to_def), diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs index ce0f4214c..54b33a98e 100644 --- a/crates/ide/src/display/navigation_target.rs +++ b/crates/ide/src/display/navigation_target.rs @@ -245,7 +245,7 @@ impl ToNav for hir::Module { } } -impl ToNav for hir::ImplDef { +impl ToNav for hir::Impl { fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { let src = self.source(db); let derive_attr = self.is_builtin_derive(db); diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs index 2b5794a31..79c081cac 100644 --- a/crates/ide/src/doc_links.rs +++ b/crates/ide/src/doc_links.rs @@ -112,7 +112,7 @@ fn get_doc_link(db: &RootDatabase, definition: Definition) -> Option { .as_assoc_item(db) .and_then(|assoc| match assoc.container(db) { AssocItemContainer::Trait(t) => Some(t.into()), - AssocItemContainer::ImplDef(impld) => { + AssocItemContainer::Impl(impld) => { impld.target_ty(db).as_adt().map(|adt| adt.into()) } }) diff --git a/crates/ide/src/goto_implementation.rs b/crates/ide/src/goto_implementation.rs index 68c628d31..6eac39639 100644 --- a/crates/ide/src/goto_implementation.rs +++ b/crates/ide/src/goto_implementation.rs @@ -1,4 +1,4 @@ -use hir::{Crate, ImplDef, Semantics}; +use hir::{Crate, Impl, Semantics}; use ide_db::RootDatabase; use syntax::{algo::find_node_at_offset, ast, AstNode}; @@ -49,7 +49,7 @@ fn impls_for_def( ast::AdtDef::Union(def) => sema.to_def(def)?.ty(sema.db), }; - let impls = ImplDef::all_in_crate(sema.db, krate); + let impls = Impl::all_in_crate(sema.db, krate); Some( impls @@ -67,7 +67,7 @@ fn impls_for_trait( ) -> Option> { let tr = sema.to_def(node)?; - let impls = ImplDef::for_trait(sema.db, krate, tr); + let impls = Impl::for_trait(sema.db, krate, tr); Some(impls.into_iter().map(|imp| imp.to_nav(sema.db)).collect()) } diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index a01b0c894..e82aad6d5 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -295,7 +295,7 @@ fn definition_owner_name(db: &RootDatabase, def: &Definition) -> Option Definition::ModuleDef(md) => match md { ModuleDef::Function(f) => match f.as_assoc_item(db)?.container(db) { AssocItemContainer::Trait(t) => Some(t.name(db)), - AssocItemContainer::ImplDef(i) => i.target_ty(db).as_adt().map(|adt| adt.name(db)), + AssocItemContainer::Impl(i) => i.target_ty(db).as_adt().map(|adt| adt.name(db)), }, ModuleDef::EnumVariant(e) => Some(e.parent_enum(db).name(db)), _ => None, diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs index 646f63704..96462a7b0 100644 --- a/crates/ide/src/runnables.rs +++ b/crates/ide/src/runnables.rs @@ -130,7 +130,7 @@ fn runnable_fn( hir::AssocItemContainer::Trait(trait_item) => { Some(trait_item.name(sema.db).to_string()) } - hir::AssocItemContainer::ImplDef(impl_def) => impl_def + hir::AssocItemContainer::Impl(impl_def) => impl_def .target_ty(sema.db) .as_adt() .map(|adt| adt.name(sema.db).to_string()), diff --git a/crates/ide_db/src/defs.rs b/crates/ide_db/src/defs.rs index f2d1e4c39..bd2afc887 100644 --- a/crates/ide_db/src/defs.rs +++ b/crates/ide_db/src/defs.rs @@ -6,7 +6,7 @@ // FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). use hir::{ - db::HirDatabase, Crate, Field, HasVisibility, ImplDef, LifetimeParam, Local, MacroDef, Module, + db::HirDatabase, Crate, Field, HasVisibility, Impl, LifetimeParam, Local, MacroDef, Module, ModuleDef, Name, PathResolution, Semantics, TypeParam, Visibility, }; use syntax::{ @@ -22,7 +22,7 @@ pub enum Definition { Macro(MacroDef), Field(Field), ModuleDef(ModuleDef), - SelfType(ImplDef), + SelfType(Impl), Local(Local), TypeParam(TypeParam), LifetimeParam(LifetimeParam), diff --git a/crates/ide_db/src/search.rs b/crates/ide_db/src/search.rs index 5b3997bcf..525c8a41f 100644 --- a/crates/ide_db/src/search.rs +++ b/crates/ide_db/src/search.rs @@ -140,7 +140,7 @@ impl Definition { }, hir::GenericDef::Trait(it) => it.source(db).value.syntax().text_range(), hir::GenericDef::TypeAlias(it) => it.source(db).value.syntax().text_range(), - hir::GenericDef::ImplDef(it) => it.source(db).value.syntax().text_range(), + hir::GenericDef::Impl(it) => it.source(db).value.syntax().text_range(), hir::GenericDef::EnumVariant(it) => it.source(db).value.syntax().text_range(), hir::GenericDef::Const(it) => it.source(db).value.syntax().text_range(), }; -- cgit v1.2.3