aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/impl_block.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/impl_block.rs')
-rw-r--r--crates/ra_hir/src/impl_block.rs20
1 files changed, 15 insertions, 5 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