From a1e18695548b5cd6661f26a985b34c8b105e1896 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 29 Feb 2020 21:24:40 +0100 Subject: Rename ast::ImplBlock -> ast::ImplDef --- crates/ra_hir/src/code_model.rs | 36 ++++++++++++++-------------- crates/ra_hir/src/from_id.rs | 4 ++-- crates/ra_hir/src/has_source.rs | 8 +++---- crates/ra_hir/src/lib.rs | 2 +- crates/ra_hir/src/semantics.rs | 2 +- crates/ra_hir/src/semantics/source_to_def.rs | 6 ++--- crates/ra_hir/src/source_analyzer.rs | 2 +- 7 files changed, 30 insertions(+), 30 deletions(-) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 034fb7cfa..b71ee764a 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -229,8 +229,8 @@ impl Module { } } - for impl_block in self.impl_blocks(db) { - for item in impl_block.items(db) { + for impl_def in self.impl_defs(db) { + for item in impl_def.items(db) { if let AssocItem::Function(f) = item { f.diagnostics(db, sink); } @@ -243,9 +243,9 @@ impl Module { def_map[self.id.local_id].scope.declarations().map(ModuleDef::from).collect() } - pub fn impl_blocks(self, db: &impl DefDatabase) -> Vec { + pub fn impl_defs(self, db: &impl DefDatabase) -> Vec { let def_map = db.crate_def_map(self.id.krate); - def_map[self.id.local_id].scope.impls().map(ImplBlock::from).collect() + def_map[self.id.local_id].scope.impls().map(ImplDef::from).collect() } pub(crate) fn with_module_id(self, module_id: LocalModuleId) -> Module { @@ -686,7 +686,7 @@ pub enum AssocItem { } pub enum AssocItemContainer { Trait(Trait), - ImplBlock(ImplBlock), + ImplDef(ImplDef), } pub trait AsAssocItem { fn as_assoc_item(self, db: &impl DefDatabase) -> Option; @@ -736,7 +736,7 @@ impl AssocItem { }; match container { AssocContainerId::TraitId(id) => AssocItemContainer::Trait(id.into()), - AssocContainerId::ImplId(id) => AssocItemContainer::ImplBlock(id.into()), + AssocContainerId::ImplId(id) => AssocItemContainer::ImplDef(id.into()), AssocContainerId::ContainerId(_) => panic!("invalid AssocItem"), } } @@ -748,7 +748,7 @@ pub enum GenericDef { Adt(Adt), Trait(Trait), TypeAlias(TypeAlias), - ImplBlock(ImplBlock), + ImplDef(ImplDef), // enum variants cannot have generics themselves, but their parent enums // can, and this makes some code easier to write EnumVariant(EnumVariant), @@ -760,7 +760,7 @@ impl_froms!( Adt(Struct, Enum, Union), Trait, TypeAlias, - ImplBlock, + ImplDef, EnumVariant, Const ); @@ -850,20 +850,20 @@ impl TypeParam { } } -// FIXME: rename from `ImplBlock` to `Impl` +// FIXME: rename from `ImplDef` to `Impl` #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -pub struct ImplBlock { +pub struct ImplDef { pub(crate) id: ImplId, } -impl ImplBlock { - pub fn all_in_crate(db: &impl HirDatabase, krate: Crate) -> Vec { +impl ImplDef { + pub fn all_in_crate(db: &impl HirDatabase, krate: Crate) -> Vec { let impls = db.impls_in_crate(krate.id); impls.all_impls().map(Self::from).collect() } - pub fn for_trait(db: &impl HirDatabase, krate: Crate, trait_: Trait) -> Vec { + pub fn for_trait(db: &impl HirDatabase, krate: Crate, trait_: Trait) -> Vec { let impls = db.impls_in_crate(krate.id); - impls.lookup_impl_blocks_for_trait(trait_.id).map(Self::from).collect() + impls.lookup_impl_defs_for_trait(trait_.id).map(Self::from).collect() } pub fn target_trait(&self, db: &impl DefDatabase) -> Option { @@ -1077,7 +1077,7 @@ impl Type { } // This would be nicer if it just returned an iterator, but that runs into - // lifetime problems, because we need to borrow temp `CrateImplBlocks`. + // lifetime problems, because we need to borrow temp `CrateImplDefs`. pub fn iterate_impl_items( self, db: &impl HirDatabase, @@ -1087,8 +1087,8 @@ impl Type { for krate in self.ty.value.def_crates(db, krate.id)? { let impls = db.impls_in_crate(krate); - for impl_block in impls.lookup_impl_blocks(&self.ty.value) { - for &item in db.impl_data(impl_block).items.iter() { + for impl_def in impls.lookup_impl_defs(&self.ty.value) { + for &item in db.impl_data(impl_def).items.iter() { if let Some(result) = callback(item.into()) { return Some(result); } @@ -1196,7 +1196,7 @@ pub enum ScopeDef { ModuleDef(ModuleDef), MacroDef(MacroDef), GenericParam(TypeParam), - ImplSelfType(ImplBlock), + ImplSelfType(ImplDef), AdtSelfType(Adt), Local(Local), Unknown, diff --git a/crates/ra_hir/src/from_id.rs b/crates/ra_hir/src/from_id.rs index cbfa91d6c..c179b13c6 100644 --- a/crates/ra_hir/src/from_id.rs +++ b/crates/ra_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::ImplBlock), + (hir_def::ImplId, crate::ImplDef), (hir_def::TypeParamId, crate::TypeParam), (hir_expand::MacroDefId, crate::MacroDef) ]; @@ -145,7 +145,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::ImplBlock(it) => GenericDefId::ImplId(it.id), + GenericDef::ImplDef(it) => GenericDefId::ImplId(it.id), GenericDef::EnumVariant(it) => { GenericDefId::EnumVariantId(EnumVariantId { parent: it.parent.id, local_id: it.id }) } diff --git a/crates/ra_hir/src/has_source.rs b/crates/ra_hir/src/has_source.rs index 5541266e2..f121e1eff 100644 --- a/crates/ra_hir/src/has_source.rs +++ b/crates/ra_hir/src/has_source.rs @@ -9,7 +9,7 @@ use hir_def::{ use ra_syntax::ast; use crate::{ - db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, ImplBlock, MacroDef, Module, + db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, ImplDef, MacroDef, Module, Static, Struct, StructField, Trait, TypeAlias, TypeParam, Union, }; @@ -111,9 +111,9 @@ impl HasSource for MacroDef { } } } -impl HasSource for ImplBlock { - type Ast = ast::ImplBlock; - fn source(self, db: &impl DefDatabase) -> InFile { +impl HasSource for ImplDef { + type Ast = ast::ImplDef; + fn source(self, db: &impl DefDatabase) -> InFile { self.id.lookup(db).source(db) } } diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index cefbd80e6..e1cb12cca 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs @@ -41,7 +41,7 @@ pub use crate::{ code_model::{ Adt, AsAssocItem, AssocItem, AssocItemContainer, AttrDef, Const, Crate, CrateDependency, DefWithBody, Docs, Enum, EnumVariant, FieldSource, Function, GenericDef, HasAttrs, - HasVisibility, ImplBlock, Local, MacroDef, Module, ModuleDef, ScopeDef, Static, Struct, + HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, ScopeDef, Static, Struct, StructField, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, }, has_source::HasSource, diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 74901e318..a0853957c 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -262,7 +262,7 @@ to_def_impls![ (crate::Enum, ast::EnumDef, enum_to_def), (crate::Union, ast::UnionDef, union_to_def), (crate::Trait, ast::TraitDef, trait_to_def), - (crate::ImplBlock, ast::ImplBlock, impl_to_def), + (crate::ImplDef, ast::ImplDef, impl_to_def), (crate::TypeAlias, ast::TypeAliasDef, type_alias_to_def), (crate::Const, ast::ConstDef, const_to_def), (crate::Static, ast::StaticDef, static_to_def), diff --git a/crates/ra_hir/src/semantics/source_to_def.rs b/crates/ra_hir/src/semantics/source_to_def.rs index 884b535b2..67b243222 100644 --- a/crates/ra_hir/src/semantics/source_to_def.rs +++ b/crates/ra_hir/src/semantics/source_to_def.rs @@ -67,7 +67,7 @@ impl SourceToDefCtx<'_, &'_ DB> { pub(super) fn trait_to_def(&mut self, src: InFile) -> Option { self.to_def(src, keys::TRAIT) } - pub(super) fn impl_to_def(&mut self, src: InFile) -> Option { + pub(super) fn impl_to_def(&mut self, src: InFile) -> Option { self.to_def(src, keys::IMPL) } pub(super) fn fn_to_def(&mut self, src: InFile) -> Option { @@ -166,7 +166,7 @@ impl SourceToDefCtx<'_, &'_ DB> { let def = self.trait_to_def(container.with_value(it))?; def.into() }, - ast::ImplBlock(it) => { + ast::ImplDef(it) => { let def = self.impl_to_def(container.with_value(it))?; def.into() }, @@ -213,7 +213,7 @@ impl SourceToDefCtx<'_, &'_ DB> { ast::EnumDef(it) => { self.enum_to_def(container.with_value(it))?.into() }, ast::TraitDef(it) => { self.trait_to_def(container.with_value(it))?.into() }, ast::TypeAliasDef(it) => { self.type_alias_to_def(container.with_value(it))?.into() }, - ast::ImplBlock(it) => { self.impl_to_def(container.with_value(it))?.into() }, + ast::ImplDef(it) => { self.impl_to_def(container.with_value(it))?.into() }, _ => continue, } }; diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs index c650a9e08..4c121eb73 100644 --- a/crates/ra_hir/src/source_analyzer.rs +++ b/crates/ra_hir/src/source_analyzer.rs @@ -49,7 +49,7 @@ pub enum PathResolution { Local(Local), /// A generic parameter TypeParam(TypeParam), - SelfType(crate::ImplBlock), + SelfType(crate::ImplDef), Macro(MacroDef), AssocItem(crate::AssocItem), } -- cgit v1.2.3