aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-12-17 11:37:34 +0000
committerGitHub <[email protected]>2020-12-17 11:37:34 +0000
commitce8ec2863887618dc40c47c075a83d7704452b0b (patch)
treeb8849bc4765766dc43e92a12f52ab287680528f5 /crates
parentd641bccb0ffec543fa444ba523e8d4b63078fa53 (diff)
parent2ae31e34b1a345ceea23198a7e9e32e557cdbb4d (diff)
Merge #6914
6914: Rename ImplDef -> Impl r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/hir/src/code_model.rs22
-rw-r--r--crates/hir/src/from_id.rs6
-rw-r--r--crates/hir/src/has_source.rs6
-rw-r--r--crates/hir/src/lib.rs2
-rw-r--r--crates/hir/src/semantics.rs6
-rw-r--r--crates/ide/src/display/navigation_target.rs2
-rw-r--r--crates/ide/src/doc_links.rs2
-rw-r--r--crates/ide/src/goto_implementation.rs6
-rw-r--r--crates/ide/src/hover.rs2
-rw-r--r--crates/ide/src/runnables.rs2
-rw-r--r--crates/ide_db/src/defs.rs4
-rw-r--r--crates/ide_db/src/search.rs2
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 {
402 def_map[self.id.local_id].scope.declarations().map(ModuleDef::from).collect() 402 def_map[self.id.local_id].scope.declarations().map(ModuleDef::from).collect()
403 } 403 }
404 404
405 pub fn impl_defs(self, db: &dyn HirDatabase) -> Vec<ImplDef> { 405 pub fn impl_defs(self, db: &dyn HirDatabase) -> Vec<Impl> {
406 let def_map = db.crate_def_map(self.id.krate); 406 let def_map = db.crate_def_map(self.id.krate);
407 def_map[self.id.local_id].scope.impls().map(ImplDef::from).collect() 407 def_map[self.id.local_id].scope.impls().map(Impl::from).collect()
408 } 408 }
409 409
410 pub(crate) fn with_module_id(self, module_id: LocalModuleId) -> Module { 410 pub(crate) fn with_module_id(self, module_id: LocalModuleId) -> Module {
@@ -1007,7 +1007,7 @@ pub enum AssocItem {
1007} 1007}
1008pub enum AssocItemContainer { 1008pub enum AssocItemContainer {
1009 Trait(Trait), 1009 Trait(Trait),
1010 ImplDef(ImplDef), 1010 Impl(Impl),
1011} 1011}
1012pub trait AsAssocItem { 1012pub trait AsAssocItem {
1013 fn as_assoc_item(self, db: &dyn HirDatabase) -> Option<AssocItem>; 1013 fn as_assoc_item(self, db: &dyn HirDatabase) -> Option<AssocItem>;
@@ -1064,7 +1064,7 @@ impl AssocItem {
1064 }; 1064 };
1065 match container { 1065 match container {
1066 AssocContainerId::TraitId(id) => AssocItemContainer::Trait(id.into()), 1066 AssocContainerId::TraitId(id) => AssocItemContainer::Trait(id.into()),
1067 AssocContainerId::ImplId(id) => AssocItemContainer::ImplDef(id.into()), 1067 AssocContainerId::ImplId(id) => AssocItemContainer::Impl(id.into()),
1068 AssocContainerId::ContainerId(_) => panic!("invalid AssocItem"), 1068 AssocContainerId::ContainerId(_) => panic!("invalid AssocItem"),
1069 } 1069 }
1070 } 1070 }
@@ -1086,7 +1086,7 @@ pub enum GenericDef {
1086 Adt(Adt), 1086 Adt(Adt),
1087 Trait(Trait), 1087 Trait(Trait),
1088 TypeAlias(TypeAlias), 1088 TypeAlias(TypeAlias),
1089 ImplDef(ImplDef), 1089 Impl(Impl),
1090 // enum variants cannot have generics themselves, but their parent enums 1090 // enum variants cannot have generics themselves, but their parent enums
1091 // can, and this makes some code easier to write 1091 // can, and this makes some code easier to write
1092 EnumVariant(EnumVariant), 1092 EnumVariant(EnumVariant),
@@ -1098,7 +1098,7 @@ impl_from!(
1098 Adt(Struct, Enum, Union), 1098 Adt(Struct, Enum, Union),
1099 Trait, 1099 Trait,
1100 TypeAlias, 1100 TypeAlias,
1101 ImplDef, 1101 Impl,
1102 EnumVariant, 1102 EnumVariant,
1103 Const 1103 Const
1104 for GenericDef 1104 for GenericDef
@@ -1268,18 +1268,18 @@ impl LifetimeParam {
1268 1268
1269// FIXME: rename from `ImplDef` to `Impl` 1269// FIXME: rename from `ImplDef` to `Impl`
1270#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 1270#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1271pub struct ImplDef { 1271pub struct Impl {
1272 pub(crate) id: ImplId, 1272 pub(crate) id: ImplId,
1273} 1273}
1274 1274
1275impl ImplDef { 1275impl Impl {
1276 pub fn all_in_crate(db: &dyn HirDatabase, krate: Crate) -> Vec<ImplDef> { 1276 pub fn all_in_crate(db: &dyn HirDatabase, krate: Crate) -> Vec<Impl> {
1277 let inherent = db.inherent_impls_in_crate(krate.id); 1277 let inherent = db.inherent_impls_in_crate(krate.id);
1278 let trait_ = db.trait_impls_in_crate(krate.id); 1278 let trait_ = db.trait_impls_in_crate(krate.id);
1279 1279
1280 inherent.all_impls().chain(trait_.all_impls()).map(Self::from).collect() 1280 inherent.all_impls().chain(trait_.all_impls()).map(Self::from).collect()
1281 } 1281 }
1282 pub fn for_trait(db: &dyn HirDatabase, krate: Crate, trait_: Trait) -> Vec<ImplDef> { 1282 pub fn for_trait(db: &dyn HirDatabase, krate: Crate, trait_: Trait) -> Vec<Impl> {
1283 let impls = db.trait_impls_in_crate(krate.id); 1283 let impls = db.trait_impls_in_crate(krate.id);
1284 impls.for_trait(trait_.id).map(Self::from).collect() 1284 impls.for_trait(trait_.id).map(Self::from).collect()
1285 } 1285 }
@@ -1904,7 +1904,7 @@ pub enum ScopeDef {
1904 ModuleDef(ModuleDef), 1904 ModuleDef(ModuleDef),
1905 MacroDef(MacroDef), 1905 MacroDef(MacroDef),
1906 GenericParam(TypeParam), 1906 GenericParam(TypeParam),
1907 ImplSelfType(ImplDef), 1907 ImplSelfType(Impl),
1908 AdtSelfType(Adt), 1908 AdtSelfType(Adt),
1909 Local(Local), 1909 Local(Local),
1910 Unknown, 1910 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![
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::ImplDef), 42 (hir_def::ImplId, crate::Impl),
43 (hir_def::TypeParamId, crate::TypeParam), 43 (hir_def::TypeParamId, crate::TypeParam),
44 (hir_def::LifetimeParamId, crate::LifetimeParam), 44 (hir_def::LifetimeParamId, crate::LifetimeParam),
45 (hir_expand::MacroDefId, crate::MacroDef) 45 (hir_expand::MacroDefId, crate::MacroDef)
@@ -146,7 +146,7 @@ impl From<GenericDef> for GenericDefId {
146 GenericDef::Adt(it) => GenericDefId::AdtId(it.into()), 146 GenericDef::Adt(it) => GenericDefId::AdtId(it.into()),
147 GenericDef::Trait(it) => GenericDefId::TraitId(it.id), 147 GenericDef::Trait(it) => GenericDefId::TraitId(it.id),
148 GenericDef::TypeAlias(it) => GenericDefId::TypeAliasId(it.id), 148 GenericDef::TypeAlias(it) => GenericDefId::TypeAliasId(it.id),
149 GenericDef::ImplDef(it) => GenericDefId::ImplId(it.id), 149 GenericDef::Impl(it) => GenericDefId::ImplId(it.id),
150 GenericDef::EnumVariant(it) => { 150 GenericDef::EnumVariant(it) => {
151 GenericDefId::EnumVariantId(EnumVariantId { parent: it.parent.id, local_id: it.id }) 151 GenericDefId::EnumVariantId(EnumVariantId { parent: it.parent.id, local_id: it.id })
152 } 152 }
@@ -162,7 +162,7 @@ impl From<GenericDefId> for GenericDef {
162 GenericDefId::AdtId(it) => GenericDef::Adt(it.into()), 162 GenericDefId::AdtId(it) => GenericDef::Adt(it.into()),
163 GenericDefId::TraitId(it) => GenericDef::Trait(it.into()), 163 GenericDefId::TraitId(it) => GenericDef::Trait(it.into()),
164 GenericDefId::TypeAliasId(it) => GenericDef::TypeAlias(it.into()), 164 GenericDefId::TypeAliasId(it) => GenericDef::TypeAlias(it.into()),
165 GenericDefId::ImplId(it) => GenericDef::ImplDef(it.into()), 165 GenericDefId::ImplId(it) => GenericDef::Impl(it.into()),
166 GenericDefId::EnumVariantId(it) => { 166 GenericDefId::EnumVariantId(it) => {
167 GenericDef::EnumVariant(EnumVariant { parent: it.parent.into(), id: it.local_id }) 167 GenericDef::EnumVariant(EnumVariant { parent: it.parent.into(), id: it.local_id })
168 } 168 }
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;
10use syntax::ast; 10use syntax::ast;
11 11
12use crate::{ 12use crate::{
13 db::HirDatabase, Const, Enum, EnumVariant, Field, FieldSource, Function, ImplDef, 13 db::HirDatabase, Const, Enum, EnumVariant, Field, FieldSource, Function, Impl, LifetimeParam,
14 LifetimeParam, MacroDef, Module, Static, Struct, Trait, TypeAlias, TypeParam, Union, 14 MacroDef, Module, Static, Struct, Trait, TypeAlias, TypeParam, Union,
15}; 15};
16 16
17pub trait HasSource { 17pub trait HasSource {
@@ -118,7 +118,7 @@ impl HasSource for MacroDef {
118 } 118 }
119 } 119 }
120} 120}
121impl HasSource for ImplDef { 121impl HasSource for Impl {
122 type Ast = ast::Impl; 122 type Ast = ast::Impl;
123 fn source(self, db: &dyn HirDatabase) -> InFile<ast::Impl> { 123 fn source(self, db: &dyn HirDatabase) -> InFile<ast::Impl> {
124 self.id.lookup(db.upcast()).source(db.upcast()) 124 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::{
35 code_model::{ 35 code_model::{
36 Access, Adt, AsAssocItem, AssocItem, AssocItemContainer, Callable, CallableKind, Const, 36 Access, Adt, AsAssocItem, AssocItem, AssocItemContainer, Callable, CallableKind, Const,
37 Crate, CrateDependency, DefWithBody, Enum, EnumVariant, Field, FieldSource, Function, 37 Crate, CrateDependency, DefWithBody, Enum, EnumVariant, Field, FieldSource, Function,
38 GenericDef, HasVisibility, ImplDef, LifetimeParam, Local, MacroDef, Module, ModuleDef, 38 GenericDef, HasVisibility, Impl, LifetimeParam, Local, MacroDef, Module, ModuleDef,
39 ScopeDef, Static, Struct, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, 39 ScopeDef, Static, Struct, Trait, Type, TypeAlias, TypeParam, Union, VariantDef,
40 }, 40 },
41 has_source::HasSource, 41 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::{
25 diagnostics::Diagnostic, 25 diagnostics::Diagnostic,
26 semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx}, 26 semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx},
27 source_analyzer::{resolve_hir_path, SourceAnalyzer}, 27 source_analyzer::{resolve_hir_path, SourceAnalyzer},
28 AssocItem, Callable, Crate, Field, Function, HirFileId, ImplDef, InFile, LifetimeParam, Local, 28 AssocItem, Callable, Crate, Field, Function, HirFileId, Impl, InFile, LifetimeParam, Local,
29 MacroDef, Module, ModuleDef, Name, Path, ScopeDef, Trait, Type, TypeAlias, TypeParam, 29 MacroDef, Module, ModuleDef, Name, Path, ScopeDef, Trait, Type, TypeAlias, TypeParam,
30 VariantDef, 30 VariantDef,
31}; 31};
@@ -38,7 +38,7 @@ pub enum PathResolution {
38 Local(Local), 38 Local(Local),
39 /// A generic parameter 39 /// A generic parameter
40 TypeParam(TypeParam), 40 TypeParam(TypeParam),
41 SelfType(ImplDef), 41 SelfType(Impl),
42 Macro(MacroDef), 42 Macro(MacroDef),
43 AssocItem(AssocItem), 43 AssocItem(AssocItem),
44} 44}
@@ -708,7 +708,7 @@ to_def_impls![
708 (crate::Enum, ast::Enum, enum_to_def), 708 (crate::Enum, ast::Enum, enum_to_def),
709 (crate::Union, ast::Union, union_to_def), 709 (crate::Union, ast::Union, union_to_def),
710 (crate::Trait, ast::Trait, trait_to_def), 710 (crate::Trait, ast::Trait, trait_to_def),
711 (crate::ImplDef, ast::Impl, impl_to_def), 711 (crate::Impl, ast::Impl, impl_to_def),
712 (crate::TypeAlias, ast::TypeAlias, type_alias_to_def), 712 (crate::TypeAlias, ast::TypeAlias, type_alias_to_def),
713 (crate::Const, ast::Const, const_to_def), 713 (crate::Const, ast::Const, const_to_def),
714 (crate::Static, ast::Static, static_to_def), 714 (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 {
245 } 245 }
246} 246}
247 247
248impl ToNav for hir::ImplDef { 248impl ToNav for hir::Impl {
249 fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { 249 fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
250 let src = self.source(db); 250 let src = self.source(db);
251 let derive_attr = self.is_builtin_derive(db); 251 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<String> {
112 .as_assoc_item(db) 112 .as_assoc_item(db)
113 .and_then(|assoc| match assoc.container(db) { 113 .and_then(|assoc| match assoc.container(db) {
114 AssocItemContainer::Trait(t) => Some(t.into()), 114 AssocItemContainer::Trait(t) => Some(t.into()),
115 AssocItemContainer::ImplDef(impld) => { 115 AssocItemContainer::Impl(impld) => {
116 impld.target_ty(db).as_adt().map(|adt| adt.into()) 116 impld.target_ty(db).as_adt().map(|adt| adt.into())
117 } 117 }
118 }) 118 })
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 @@
1use hir::{Crate, ImplDef, Semantics}; 1use hir::{Crate, Impl, Semantics};
2use ide_db::RootDatabase; 2use ide_db::RootDatabase;
3use syntax::{algo::find_node_at_offset, ast, AstNode}; 3use syntax::{algo::find_node_at_offset, ast, AstNode};
4 4
@@ -49,7 +49,7 @@ fn impls_for_def(
49 ast::AdtDef::Union(def) => sema.to_def(def)?.ty(sema.db), 49 ast::AdtDef::Union(def) => sema.to_def(def)?.ty(sema.db),
50 }; 50 };
51 51
52 let impls = ImplDef::all_in_crate(sema.db, krate); 52 let impls = Impl::all_in_crate(sema.db, krate);
53 53
54 Some( 54 Some(
55 impls 55 impls
@@ -67,7 +67,7 @@ fn impls_for_trait(
67) -> Option<Vec<NavigationTarget>> { 67) -> Option<Vec<NavigationTarget>> {
68 let tr = sema.to_def(node)?; 68 let tr = sema.to_def(node)?;
69 69
70 let impls = ImplDef::for_trait(sema.db, krate, tr); 70 let impls = Impl::for_trait(sema.db, krate, tr);
71 71
72 Some(impls.into_iter().map(|imp| imp.to_nav(sema.db)).collect()) 72 Some(impls.into_iter().map(|imp| imp.to_nav(sema.db)).collect())
73} 73}
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<String>
295 Definition::ModuleDef(md) => match md { 295 Definition::ModuleDef(md) => match md {
296 ModuleDef::Function(f) => match f.as_assoc_item(db)?.container(db) { 296 ModuleDef::Function(f) => match f.as_assoc_item(db)?.container(db) {
297 AssocItemContainer::Trait(t) => Some(t.name(db)), 297 AssocItemContainer::Trait(t) => Some(t.name(db)),
298 AssocItemContainer::ImplDef(i) => i.target_ty(db).as_adt().map(|adt| adt.name(db)), 298 AssocItemContainer::Impl(i) => i.target_ty(db).as_adt().map(|adt| adt.name(db)),
299 }, 299 },
300 ModuleDef::EnumVariant(e) => Some(e.parent_enum(db).name(db)), 300 ModuleDef::EnumVariant(e) => Some(e.parent_enum(db).name(db)),
301 _ => None, 301 _ => 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(
130 hir::AssocItemContainer::Trait(trait_item) => { 130 hir::AssocItemContainer::Trait(trait_item) => {
131 Some(trait_item.name(sema.db).to_string()) 131 Some(trait_item.name(sema.db).to_string())
132 } 132 }
133 hir::AssocItemContainer::ImplDef(impl_def) => impl_def 133 hir::AssocItemContainer::Impl(impl_def) => impl_def
134 .target_ty(sema.db) 134 .target_ty(sema.db)
135 .as_adt() 135 .as_adt()
136 .map(|adt| adt.name(sema.db).to_string()), 136 .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 @@
6// FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). 6// FIXME: this badly needs rename/rewrite (matklad, 2020-02-06).
7 7
8use hir::{ 8use hir::{
9 db::HirDatabase, Crate, Field, HasVisibility, ImplDef, LifetimeParam, Local, MacroDef, Module, 9 db::HirDatabase, Crate, Field, HasVisibility, Impl, LifetimeParam, Local, MacroDef, Module,
10 ModuleDef, Name, PathResolution, Semantics, TypeParam, Visibility, 10 ModuleDef, Name, PathResolution, Semantics, TypeParam, Visibility,
11}; 11};
12use syntax::{ 12use syntax::{
@@ -22,7 +22,7 @@ pub enum Definition {
22 Macro(MacroDef), 22 Macro(MacroDef),
23 Field(Field), 23 Field(Field),
24 ModuleDef(ModuleDef), 24 ModuleDef(ModuleDef),
25 SelfType(ImplDef), 25 SelfType(Impl),
26 Local(Local), 26 Local(Local),
27 TypeParam(TypeParam), 27 TypeParam(TypeParam),
28 LifetimeParam(LifetimeParam), 28 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 {
140 }, 140 },
141 hir::GenericDef::Trait(it) => it.source(db).value.syntax().text_range(), 141 hir::GenericDef::Trait(it) => it.source(db).value.syntax().text_range(),
142 hir::GenericDef::TypeAlias(it) => it.source(db).value.syntax().text_range(), 142 hir::GenericDef::TypeAlias(it) => it.source(db).value.syntax().text_range(),
143 hir::GenericDef::ImplDef(it) => it.source(db).value.syntax().text_range(), 143 hir::GenericDef::Impl(it) => it.source(db).value.syntax().text_range(),
144 hir::GenericDef::EnumVariant(it) => it.source(db).value.syntax().text_range(), 144 hir::GenericDef::EnumVariant(it) => it.source(db).value.syntax().text_range(),
145 hir::GenericDef::Const(it) => it.source(db).value.syntax().text_range(), 145 hir::GenericDef::Const(it) => it.source(db).value.syntax().text_range(),
146 }; 146 };