aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/impl_block.rs20
-rw-r--r--crates/ra_hir/src/ty.rs4
2 files changed, 17 insertions, 7 deletions
diff --git a/crates/ra_hir/src/impl_block.rs b/crates/ra_hir/src/impl_block.rs
index 22f0a4461..77fab24d0 100644
--- a/crates/ra_hir/src/impl_block.rs
+++ b/crates/ra_hir/src/impl_block.rs
@@ -35,8 +35,12 @@ impl ImplBlock {
35 &self.crate_impl_blocks.impls[self.impl_id] 35 &self.crate_impl_blocks.impls[self.impl_id]
36 } 36 }
37 37
38 pub fn target(&self) -> &TypeRef { 38 pub fn target_trait(&self) -> Option<&TypeRef> {
39 &self.impl_data().impl_for 39 self.impl_data().target_trait.as_ref()
40 }
41
42 pub fn target_type(&self) -> &TypeRef {
43 &self.impl_data().target_type
40 } 44 }
41 45
42 pub fn items(&self) -> &[ImplItem] { 46 pub fn items(&self) -> &[ImplItem] {
@@ -46,7 +50,8 @@ impl ImplBlock {
46 50
47#[derive(Debug, Clone, PartialEq, Eq)] 51#[derive(Debug, Clone, PartialEq, Eq)]
48pub struct ImplData { 52pub struct ImplData {
49 impl_for: TypeRef, 53 target_trait: Option<TypeRef>,
54 target_type: TypeRef,
50 items: Vec<ImplItem>, 55 items: Vec<ImplItem>,
51} 56}
52 57
@@ -57,7 +62,8 @@ impl ImplData {
57 module: &Module, 62 module: &Module,
58 node: ast::ImplBlock, 63 node: ast::ImplBlock,
59 ) -> Self { 64 ) -> Self {
60 let impl_for = TypeRef::from_ast_opt(node.target_type()); 65 let target_trait = node.target_type().map(TypeRef::from_ast);
66 let target_type = TypeRef::from_ast_opt(node.target_type());
61 let file_id = module.source().file_id(); 67 let file_id = module.source().file_id();
62 let items = if let Some(item_list) = node.item_list() { 68 let items = if let Some(item_list) = node.item_list() {
63 item_list 69 item_list
@@ -89,7 +95,11 @@ impl ImplData {
89 } else { 95 } else {
90 Vec::new() 96 Vec::new()
91 }; 97 };
92 ImplData { impl_for, items } 98 ImplData {
99 target_trait,
100 target_type,
101 items,
102 }
93 } 103 }
94} 104}
95 105
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index 45a01679c..e33762e0d 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -306,7 +306,7 @@ impl Ty {
306 } else if let Some(float_ty) = primitive::FloatTy::from_name(name) { 306 } else if let Some(float_ty) = primitive::FloatTy::from_name(name) {
307 return Ok(Ty::Float(float_ty)); 307 return Ok(Ty::Float(float_ty));
308 } else if name.as_known_name() == Some(KnownName::Self_) { 308 } else if name.as_known_name() == Some(KnownName::Self_) {
309 return Ty::from_hir_opt(db, module, None, impl_block.map(|i| i.target())); 309 return Ty::from_hir_opt(db, module, None, impl_block.map(|i| i.target_type()));
310 } 310 }
311 } 311 }
312 312
@@ -972,7 +972,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
972 self.insert_type_vars(ty) 972 self.insert_type_vars(ty)
973 } else { 973 } else {
974 // TODO this should be handled by desugaring during HIR conversion 974 // TODO this should be handled by desugaring during HIR conversion
975 let ty = self.make_ty_opt(self.impl_block.as_ref().map(|i| i.target()))?; 975 let ty = self.make_ty_opt(self.impl_block.as_ref().map(|i| i.target_type()))?;
976 let ty = match self_param.flavor() { 976 let ty = match self_param.flavor() {
977 ast::SelfParamFlavor::Owned => ty, 977 ast::SelfParamFlavor::Owned => ty,
978 ast::SelfParamFlavor::Ref => Ty::Ref(Arc::new(ty), Mutability::Shared), 978 ast::SelfParamFlavor::Ref => Ty::Ref(Arc::new(ty), Mutability::Shared),