diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-02-29 20:40:29 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-02-29 20:40:29 +0000 |
commit | 5e78036e6c8752fda350818afdd411ab25f405ce (patch) | |
tree | e099bb9e9c04392dcb7fed54200a989f663f3659 /crates/ra_hir | |
parent | e91320632a9dfee937c3c2ba3ffafd3f5ffb22dc (diff) | |
parent | a1e18695548b5cd6661f26a985b34c8b105e1896 (diff) |
Merge #3379
3379: Rename ast::ImplBlock -> ast::ImplDef r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 36 | ||||
-rw-r--r-- | crates/ra_hir/src/from_id.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/has_source.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/semantics.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/semantics/source_to_def.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/source_analyzer.rs | 2 |
7 files changed, 30 insertions, 30 deletions
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 { | |||
229 | } | 229 | } |
230 | } | 230 | } |
231 | 231 | ||
232 | for impl_block in self.impl_blocks(db) { | 232 | for impl_def in self.impl_defs(db) { |
233 | for item in impl_block.items(db) { | 233 | for item in impl_def.items(db) { |
234 | if let AssocItem::Function(f) = item { | 234 | if let AssocItem::Function(f) = item { |
235 | f.diagnostics(db, sink); | 235 | f.diagnostics(db, sink); |
236 | } | 236 | } |
@@ -243,9 +243,9 @@ impl Module { | |||
243 | def_map[self.id.local_id].scope.declarations().map(ModuleDef::from).collect() | 243 | def_map[self.id.local_id].scope.declarations().map(ModuleDef::from).collect() |
244 | } | 244 | } |
245 | 245 | ||
246 | pub fn impl_blocks(self, db: &impl DefDatabase) -> Vec<ImplBlock> { | 246 | pub fn impl_defs(self, db: &impl DefDatabase) -> Vec<ImplDef> { |
247 | let def_map = db.crate_def_map(self.id.krate); | 247 | let def_map = db.crate_def_map(self.id.krate); |
248 | def_map[self.id.local_id].scope.impls().map(ImplBlock::from).collect() | 248 | def_map[self.id.local_id].scope.impls().map(ImplDef::from).collect() |
249 | } | 249 | } |
250 | 250 | ||
251 | pub(crate) fn with_module_id(self, module_id: LocalModuleId) -> Module { | 251 | pub(crate) fn with_module_id(self, module_id: LocalModuleId) -> Module { |
@@ -686,7 +686,7 @@ pub enum AssocItem { | |||
686 | } | 686 | } |
687 | pub enum AssocItemContainer { | 687 | pub enum AssocItemContainer { |
688 | Trait(Trait), | 688 | Trait(Trait), |
689 | ImplBlock(ImplBlock), | 689 | ImplDef(ImplDef), |
690 | } | 690 | } |
691 | pub trait AsAssocItem { | 691 | pub trait AsAssocItem { |
692 | fn as_assoc_item(self, db: &impl DefDatabase) -> Option<AssocItem>; | 692 | fn as_assoc_item(self, db: &impl DefDatabase) -> Option<AssocItem>; |
@@ -736,7 +736,7 @@ impl AssocItem { | |||
736 | }; | 736 | }; |
737 | match container { | 737 | match container { |
738 | AssocContainerId::TraitId(id) => AssocItemContainer::Trait(id.into()), | 738 | AssocContainerId::TraitId(id) => AssocItemContainer::Trait(id.into()), |
739 | AssocContainerId::ImplId(id) => AssocItemContainer::ImplBlock(id.into()), | 739 | AssocContainerId::ImplId(id) => AssocItemContainer::ImplDef(id.into()), |
740 | AssocContainerId::ContainerId(_) => panic!("invalid AssocItem"), | 740 | AssocContainerId::ContainerId(_) => panic!("invalid AssocItem"), |
741 | } | 741 | } |
742 | } | 742 | } |
@@ -748,7 +748,7 @@ pub enum GenericDef { | |||
748 | Adt(Adt), | 748 | Adt(Adt), |
749 | Trait(Trait), | 749 | Trait(Trait), |
750 | TypeAlias(TypeAlias), | 750 | TypeAlias(TypeAlias), |
751 | ImplBlock(ImplBlock), | 751 | ImplDef(ImplDef), |
752 | // enum variants cannot have generics themselves, but their parent enums | 752 | // enum variants cannot have generics themselves, but their parent enums |
753 | // can, and this makes some code easier to write | 753 | // can, and this makes some code easier to write |
754 | EnumVariant(EnumVariant), | 754 | EnumVariant(EnumVariant), |
@@ -760,7 +760,7 @@ impl_froms!( | |||
760 | Adt(Struct, Enum, Union), | 760 | Adt(Struct, Enum, Union), |
761 | Trait, | 761 | Trait, |
762 | TypeAlias, | 762 | TypeAlias, |
763 | ImplBlock, | 763 | ImplDef, |
764 | EnumVariant, | 764 | EnumVariant, |
765 | Const | 765 | Const |
766 | ); | 766 | ); |
@@ -850,20 +850,20 @@ impl TypeParam { | |||
850 | } | 850 | } |
851 | } | 851 | } |
852 | 852 | ||
853 | // FIXME: rename from `ImplBlock` to `Impl` | 853 | // FIXME: rename from `ImplDef` to `Impl` |
854 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 854 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
855 | pub struct ImplBlock { | 855 | pub struct ImplDef { |
856 | pub(crate) id: ImplId, | 856 | pub(crate) id: ImplId, |
857 | } | 857 | } |
858 | 858 | ||
859 | impl ImplBlock { | 859 | impl ImplDef { |
860 | pub fn all_in_crate(db: &impl HirDatabase, krate: Crate) -> Vec<ImplBlock> { | 860 | pub fn all_in_crate(db: &impl HirDatabase, krate: Crate) -> Vec<ImplDef> { |
861 | let impls = db.impls_in_crate(krate.id); | 861 | let impls = db.impls_in_crate(krate.id); |
862 | impls.all_impls().map(Self::from).collect() | 862 | impls.all_impls().map(Self::from).collect() |
863 | } | 863 | } |
864 | pub fn for_trait(db: &impl HirDatabase, krate: Crate, trait_: Trait) -> Vec<ImplBlock> { | 864 | pub fn for_trait(db: &impl HirDatabase, krate: Crate, trait_: Trait) -> Vec<ImplDef> { |
865 | let impls = db.impls_in_crate(krate.id); | 865 | let impls = db.impls_in_crate(krate.id); |
866 | impls.lookup_impl_blocks_for_trait(trait_.id).map(Self::from).collect() | 866 | impls.lookup_impl_defs_for_trait(trait_.id).map(Self::from).collect() |
867 | } | 867 | } |
868 | 868 | ||
869 | pub fn target_trait(&self, db: &impl DefDatabase) -> Option<TypeRef> { | 869 | pub fn target_trait(&self, db: &impl DefDatabase) -> Option<TypeRef> { |
@@ -1077,7 +1077,7 @@ impl Type { | |||
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | // This would be nicer if it just returned an iterator, but that runs into | 1079 | // This would be nicer if it just returned an iterator, but that runs into |
1080 | // lifetime problems, because we need to borrow temp `CrateImplBlocks`. | 1080 | // lifetime problems, because we need to borrow temp `CrateImplDefs`. |
1081 | pub fn iterate_impl_items<T>( | 1081 | pub fn iterate_impl_items<T>( |
1082 | self, | 1082 | self, |
1083 | db: &impl HirDatabase, | 1083 | db: &impl HirDatabase, |
@@ -1087,8 +1087,8 @@ impl Type { | |||
1087 | for krate in self.ty.value.def_crates(db, krate.id)? { | 1087 | for krate in self.ty.value.def_crates(db, krate.id)? { |
1088 | let impls = db.impls_in_crate(krate); | 1088 | let impls = db.impls_in_crate(krate); |
1089 | 1089 | ||
1090 | for impl_block in impls.lookup_impl_blocks(&self.ty.value) { | 1090 | for impl_def in impls.lookup_impl_defs(&self.ty.value) { |
1091 | for &item in db.impl_data(impl_block).items.iter() { | 1091 | for &item in db.impl_data(impl_def).items.iter() { |
1092 | if let Some(result) = callback(item.into()) { | 1092 | if let Some(result) = callback(item.into()) { |
1093 | return Some(result); | 1093 | return Some(result); |
1094 | } | 1094 | } |
@@ -1196,7 +1196,7 @@ pub enum ScopeDef { | |||
1196 | ModuleDef(ModuleDef), | 1196 | ModuleDef(ModuleDef), |
1197 | MacroDef(MacroDef), | 1197 | MacroDef(MacroDef), |
1198 | GenericParam(TypeParam), | 1198 | GenericParam(TypeParam), |
1199 | ImplSelfType(ImplBlock), | 1199 | ImplSelfType(ImplDef), |
1200 | AdtSelfType(Adt), | 1200 | AdtSelfType(Adt), |
1201 | Local(Local), | 1201 | Local(Local), |
1202 | Unknown, | 1202 | 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![ | |||
39 | (hir_def::StaticId, crate::Static), | 39 | (hir_def::StaticId, crate::Static), |
40 | (hir_def::ConstId, crate::Const), | 40 | (hir_def::ConstId, crate::Const), |
41 | (hir_def::FunctionId, crate::Function), | 41 | (hir_def::FunctionId, crate::Function), |
42 | (hir_def::ImplId, crate::ImplBlock), | 42 | (hir_def::ImplId, crate::ImplDef), |
43 | (hir_def::TypeParamId, crate::TypeParam), | 43 | (hir_def::TypeParamId, crate::TypeParam), |
44 | (hir_expand::MacroDefId, crate::MacroDef) | 44 | (hir_expand::MacroDefId, crate::MacroDef) |
45 | ]; | 45 | ]; |
@@ -145,7 +145,7 @@ impl From<GenericDef> for GenericDefId { | |||
145 | GenericDef::Adt(it) => GenericDefId::AdtId(it.into()), | 145 | GenericDef::Adt(it) => GenericDefId::AdtId(it.into()), |
146 | GenericDef::Trait(it) => GenericDefId::TraitId(it.id), | 146 | GenericDef::Trait(it) => GenericDefId::TraitId(it.id), |
147 | GenericDef::TypeAlias(it) => GenericDefId::TypeAliasId(it.id), | 147 | GenericDef::TypeAlias(it) => GenericDefId::TypeAliasId(it.id), |
148 | GenericDef::ImplBlock(it) => GenericDefId::ImplId(it.id), | 148 | GenericDef::ImplDef(it) => GenericDefId::ImplId(it.id), |
149 | GenericDef::EnumVariant(it) => { | 149 | GenericDef::EnumVariant(it) => { |
150 | GenericDefId::EnumVariantId(EnumVariantId { parent: it.parent.id, local_id: it.id }) | 150 | GenericDefId::EnumVariantId(EnumVariantId { parent: it.parent.id, local_id: it.id }) |
151 | } | 151 | } |
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::{ | |||
9 | use ra_syntax::ast; | 9 | use ra_syntax::ast; |
10 | 10 | ||
11 | use crate::{ | 11 | use crate::{ |
12 | db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, ImplBlock, MacroDef, Module, | 12 | db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, ImplDef, MacroDef, Module, |
13 | Static, Struct, StructField, Trait, TypeAlias, TypeParam, Union, | 13 | Static, Struct, StructField, Trait, TypeAlias, TypeParam, Union, |
14 | }; | 14 | }; |
15 | 15 | ||
@@ -111,9 +111,9 @@ impl HasSource for MacroDef { | |||
111 | } | 111 | } |
112 | } | 112 | } |
113 | } | 113 | } |
114 | impl HasSource for ImplBlock { | 114 | impl HasSource for ImplDef { |
115 | type Ast = ast::ImplBlock; | 115 | type Ast = ast::ImplDef; |
116 | fn source(self, db: &impl DefDatabase) -> InFile<ast::ImplBlock> { | 116 | fn source(self, db: &impl DefDatabase) -> InFile<ast::ImplDef> { |
117 | self.id.lookup(db).source(db) | 117 | self.id.lookup(db).source(db) |
118 | } | 118 | } |
119 | } | 119 | } |
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::{ | |||
41 | code_model::{ | 41 | code_model::{ |
42 | Adt, AsAssocItem, AssocItem, AssocItemContainer, AttrDef, Const, Crate, CrateDependency, | 42 | Adt, AsAssocItem, AssocItem, AssocItemContainer, AttrDef, Const, Crate, CrateDependency, |
43 | DefWithBody, Docs, Enum, EnumVariant, FieldSource, Function, GenericDef, HasAttrs, | 43 | DefWithBody, Docs, Enum, EnumVariant, FieldSource, Function, GenericDef, HasAttrs, |
44 | HasVisibility, ImplBlock, Local, MacroDef, Module, ModuleDef, ScopeDef, Static, Struct, | 44 | HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, ScopeDef, Static, Struct, |
45 | StructField, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, | 45 | StructField, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, |
46 | }, | 46 | }, |
47 | has_source::HasSource, | 47 | 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![ | |||
262 | (crate::Enum, ast::EnumDef, enum_to_def), | 262 | (crate::Enum, ast::EnumDef, enum_to_def), |
263 | (crate::Union, ast::UnionDef, union_to_def), | 263 | (crate::Union, ast::UnionDef, union_to_def), |
264 | (crate::Trait, ast::TraitDef, trait_to_def), | 264 | (crate::Trait, ast::TraitDef, trait_to_def), |
265 | (crate::ImplBlock, ast::ImplBlock, impl_to_def), | 265 | (crate::ImplDef, ast::ImplDef, impl_to_def), |
266 | (crate::TypeAlias, ast::TypeAliasDef, type_alias_to_def), | 266 | (crate::TypeAlias, ast::TypeAliasDef, type_alias_to_def), |
267 | (crate::Const, ast::ConstDef, const_to_def), | 267 | (crate::Const, ast::ConstDef, const_to_def), |
268 | (crate::Static, ast::StaticDef, static_to_def), | 268 | (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<DB: HirDatabase> SourceToDefCtx<'_, &'_ DB> { | |||
67 | pub(super) fn trait_to_def(&mut self, src: InFile<ast::TraitDef>) -> Option<TraitId> { | 67 | pub(super) fn trait_to_def(&mut self, src: InFile<ast::TraitDef>) -> Option<TraitId> { |
68 | self.to_def(src, keys::TRAIT) | 68 | self.to_def(src, keys::TRAIT) |
69 | } | 69 | } |
70 | pub(super) fn impl_to_def(&mut self, src: InFile<ast::ImplBlock>) -> Option<ImplId> { | 70 | pub(super) fn impl_to_def(&mut self, src: InFile<ast::ImplDef>) -> Option<ImplId> { |
71 | self.to_def(src, keys::IMPL) | 71 | self.to_def(src, keys::IMPL) |
72 | } | 72 | } |
73 | pub(super) fn fn_to_def(&mut self, src: InFile<ast::FnDef>) -> Option<FunctionId> { | 73 | pub(super) fn fn_to_def(&mut self, src: InFile<ast::FnDef>) -> Option<FunctionId> { |
@@ -166,7 +166,7 @@ impl<DB: HirDatabase> SourceToDefCtx<'_, &'_ DB> { | |||
166 | let def = self.trait_to_def(container.with_value(it))?; | 166 | let def = self.trait_to_def(container.with_value(it))?; |
167 | def.into() | 167 | def.into() |
168 | }, | 168 | }, |
169 | ast::ImplBlock(it) => { | 169 | ast::ImplDef(it) => { |
170 | let def = self.impl_to_def(container.with_value(it))?; | 170 | let def = self.impl_to_def(container.with_value(it))?; |
171 | def.into() | 171 | def.into() |
172 | }, | 172 | }, |
@@ -213,7 +213,7 @@ impl<DB: HirDatabase> SourceToDefCtx<'_, &'_ DB> { | |||
213 | ast::EnumDef(it) => { self.enum_to_def(container.with_value(it))?.into() }, | 213 | ast::EnumDef(it) => { self.enum_to_def(container.with_value(it))?.into() }, |
214 | ast::TraitDef(it) => { self.trait_to_def(container.with_value(it))?.into() }, | 214 | ast::TraitDef(it) => { self.trait_to_def(container.with_value(it))?.into() }, |
215 | ast::TypeAliasDef(it) => { self.type_alias_to_def(container.with_value(it))?.into() }, | 215 | ast::TypeAliasDef(it) => { self.type_alias_to_def(container.with_value(it))?.into() }, |
216 | ast::ImplBlock(it) => { self.impl_to_def(container.with_value(it))?.into() }, | 216 | ast::ImplDef(it) => { self.impl_to_def(container.with_value(it))?.into() }, |
217 | _ => continue, | 217 | _ => continue, |
218 | } | 218 | } |
219 | }; | 219 | }; |
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 { | |||
49 | Local(Local), | 49 | Local(Local), |
50 | /// A generic parameter | 50 | /// A generic parameter |
51 | TypeParam(TypeParam), | 51 | TypeParam(TypeParam), |
52 | SelfType(crate::ImplBlock), | 52 | SelfType(crate::ImplDef), |
53 | Macro(MacroDef), | 53 | Macro(MacroDef), |
54 | AssocItem(crate::AssocItem), | 54 | AssocItem(crate::AssocItem), |
55 | } | 55 | } |