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!
This commit is contained in:
parent
d641bccb0f
commit
2ae31e34b1
@ -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<ImplDef> {
|
||||
pub fn impl_defs(self, db: &dyn HirDatabase) -> Vec<Impl> {
|
||||
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<AssocItem>;
|
||||
@ -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<ImplDef> {
|
||||
impl Impl {
|
||||
pub fn all_in_crate(db: &dyn HirDatabase, krate: Crate) -> Vec<Impl> {
|
||||
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<ImplDef> {
|
||||
pub fn for_trait(db: &dyn HirDatabase, krate: Crate, trait_: Trait) -> Vec<Impl> {
|
||||
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,
|
||||
|
@ -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<GenericDef> 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<GenericDefId> 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 })
|
||||
}
|
||||
|
@ -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<ast::Impl> {
|
||||
self.id.lookup(db.upcast()).source(db.upcast())
|
||||
|
@ -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,
|
||||
|
@ -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),
|
||||
|
@ -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);
|
||||
|
@ -112,7 +112,7 @@ fn get_doc_link(db: &RootDatabase, definition: Definition) -> Option<String> {
|
||||
.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())
|
||||
}
|
||||
})
|
||||
|
@ -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<Vec<NavigationTarget>> {
|
||||
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())
|
||||
}
|
||||
|
@ -295,7 +295,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::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,
|
||||
|
@ -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()),
|
||||
|
@ -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),
|
||||
|
@ -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(),
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user