diff options
Diffstat (limited to 'crates/ra_hir/src/impl_block.rs')
-rw-r--r-- | crates/ra_hir/src/impl_block.rs | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/crates/ra_hir/src/impl_block.rs b/crates/ra_hir/src/impl_block.rs index b306874cc..822a1a0db 100644 --- a/crates/ra_hir/src/impl_block.rs +++ b/crates/ra_hir/src/impl_block.rs | |||
@@ -10,15 +10,13 @@ use ra_syntax::{ | |||
10 | use crate::{ | 10 | use crate::{ |
11 | Const, TypeAlias, Function, HirFileId, | 11 | Const, TypeAlias, Function, HirFileId, |
12 | HirDatabase, DefDatabase, | 12 | HirDatabase, DefDatabase, |
13 | ModuleDef, Trait, Resolution, | ||
14 | type_ref::TypeRef, | 13 | type_ref::TypeRef, |
15 | ids::LocationCtx, | 14 | ids::LocationCtx, |
16 | resolve::Resolver, | 15 | resolve::Resolver, |
17 | ty::Ty, generics::GenericParams, | 16 | ty::Ty, generics::GenericParams, |
17 | TraitRef, code_model_api::{Module, ModuleSource} | ||
18 | }; | 18 | }; |
19 | 19 | ||
20 | use crate::code_model_api::{Module, ModuleSource}; | ||
21 | |||
22 | #[derive(Debug, Default, PartialEq, Eq)] | 20 | #[derive(Debug, Default, PartialEq, Eq)] |
23 | pub struct ImplSourceMap { | 21 | pub struct ImplSourceMap { |
24 | map: ArenaMap<ImplId, AstPtr<ast::ImplBlock>>, | 22 | map: ArenaMap<ImplId, AstPtr<ast::ImplBlock>>, |
@@ -73,7 +71,7 @@ impl ImplBlock { | |||
73 | self.module | 71 | self.module |
74 | } | 72 | } |
75 | 73 | ||
76 | pub fn target_trait_ref(&self, db: &impl DefDatabase) -> Option<TypeRef> { | 74 | pub fn target_trait(&self, db: &impl DefDatabase) -> Option<TypeRef> { |
77 | db.impls_in_module(self.module).impls[self.impl_id].target_trait().cloned() | 75 | db.impls_in_module(self.module).impls[self.impl_id].target_trait().cloned() |
78 | } | 76 | } |
79 | 77 | ||
@@ -85,16 +83,8 @@ impl ImplBlock { | |||
85 | Ty::from_hir(db, &self.resolver(db), &self.target_type(db)) | 83 | Ty::from_hir(db, &self.resolver(db), &self.target_type(db)) |
86 | } | 84 | } |
87 | 85 | ||
88 | pub fn target_trait(&self, db: &impl HirDatabase) -> Option<Trait> { | 86 | pub fn target_trait_ref(&self, db: &impl HirDatabase) -> Option<TraitRef> { |
89 | if let Some(TypeRef::Path(path)) = self.target_trait_ref(db) { | 87 | TraitRef::from_hir(db, &self.resolver(db), &self.target_trait(db)?) |
90 | let resolver = self.resolver(db); | ||
91 | if let Some(Resolution::Def(ModuleDef::Trait(tr))) = | ||
92 | resolver.resolve_path(db, &path).take_types() | ||
93 | { | ||
94 | return Some(tr); | ||
95 | } | ||
96 | } | ||
97 | None | ||
98 | } | 88 | } |
99 | 89 | ||
100 | pub fn items(&self, db: &impl DefDatabase) -> Vec<ImplItem> { | 90 | pub fn items(&self, db: &impl DefDatabase) -> Vec<ImplItem> { |