diff options
author | Aleksey Kladov <[email protected]> | 2019-11-22 14:33:53 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-22 14:42:56 +0000 |
commit | 64df759418a83fd05fab850b8351fcddbdd3ef63 (patch) | |
tree | 2b1d06598328b9d1922e83c791f181b5789eb789 | |
parent | b315f05cf160a11b9012fcde2a9aefc240e39135 (diff) |
Make ImplData's fields public
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/impl_block.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/infer.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/data.rs | 30 |
4 files changed, 14 insertions, 28 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index f426f8c9f..3daf7488e 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -10,9 +10,9 @@ use hir_def::{ | |||
10 | adt::VariantData, | 10 | adt::VariantData, |
11 | body::scope::ExprScopes, | 11 | body::scope::ExprScopes, |
12 | builtin_type::BuiltinType, | 12 | builtin_type::BuiltinType, |
13 | data::TraitData, | ||
13 | nameres::per_ns::PerNs, | 14 | nameres::per_ns::PerNs, |
14 | resolver::{HasResolver, TypeNs}, | 15 | resolver::{HasResolver, TypeNs}, |
15 | traits::TraitData, | ||
16 | type_ref::TypeRef, | 16 | type_ref::TypeRef, |
17 | ContainerId, CrateModuleId, HasModule, ImplId, LocalEnumVariantId, LocalStructFieldId, Lookup, | 17 | ContainerId, CrateModuleId, HasModule, ImplId, LocalEnumVariantId, LocalStructFieldId, Lookup, |
18 | ModuleId, UnionId, | 18 | ModuleId, UnionId, |
diff --git a/crates/ra_hir/src/impl_block.rs b/crates/ra_hir/src/impl_block.rs index 774fa1d96..334eeebac 100644 --- a/crates/ra_hir/src/impl_block.rs +++ b/crates/ra_hir/src/impl_block.rs | |||
@@ -18,11 +18,11 @@ impl HasSource for ImplBlock { | |||
18 | 18 | ||
19 | impl ImplBlock { | 19 | impl ImplBlock { |
20 | pub fn target_trait(&self, db: &impl DefDatabase) -> Option<TypeRef> { | 20 | pub fn target_trait(&self, db: &impl DefDatabase) -> Option<TypeRef> { |
21 | db.impl_data(self.id).target_trait().cloned() | 21 | db.impl_data(self.id).target_trait.clone() |
22 | } | 22 | } |
23 | 23 | ||
24 | pub fn target_type(&self, db: &impl DefDatabase) -> TypeRef { | 24 | pub fn target_type(&self, db: &impl DefDatabase) -> TypeRef { |
25 | db.impl_data(self.id).target_type().clone() | 25 | db.impl_data(self.id).target_type.clone() |
26 | } | 26 | } |
27 | 27 | ||
28 | pub fn target_ty(&self, db: &impl HirDatabase) -> Ty { | 28 | pub fn target_ty(&self, db: &impl HirDatabase) -> Ty { |
@@ -35,11 +35,11 @@ impl ImplBlock { | |||
35 | } | 35 | } |
36 | 36 | ||
37 | pub fn items(&self, db: &impl DefDatabase) -> Vec<AssocItem> { | 37 | pub fn items(&self, db: &impl DefDatabase) -> Vec<AssocItem> { |
38 | db.impl_data(self.id).items().iter().map(|it| (*it).into()).collect() | 38 | db.impl_data(self.id).items.iter().map(|it| (*it).into()).collect() |
39 | } | 39 | } |
40 | 40 | ||
41 | pub fn is_negative(&self, db: &impl DefDatabase) -> bool { | 41 | pub fn is_negative(&self, db: &impl DefDatabase) -> bool { |
42 | db.impl_data(self.id).is_negative() | 42 | db.impl_data(self.id).is_negative |
43 | } | 43 | } |
44 | 44 | ||
45 | pub fn module(&self, db: &impl DefDatabase) -> Module { | 45 | pub fn module(&self, db: &impl DefDatabase) -> Module { |
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index 41a51283d..6e07ab86e 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs | |||
@@ -22,7 +22,7 @@ use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue}; | |||
22 | use rustc_hash::FxHashMap; | 22 | use rustc_hash::FxHashMap; |
23 | 23 | ||
24 | use hir_def::{ | 24 | use hir_def::{ |
25 | function::FunctionData, | 25 | data::FunctionData, |
26 | path::known, | 26 | path::known, |
27 | resolver::{HasResolver, Resolver, TypeNs}, | 27 | resolver::{HasResolver, Resolver, TypeNs}, |
28 | type_ref::{Mutability, TypeRef}, | 28 | type_ref::{Mutability, TypeRef}, |
diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs index b73e0d0a7..ba47629db 100644 --- a/crates/ra_hir_def/src/data.rs +++ b/crates/ra_hir_def/src/data.rs | |||
@@ -1,3 +1,5 @@ | |||
1 | //! Contains basic data about various HIR declarations. | ||
2 | |||
1 | use std::sync::Arc; | 3 | use std::sync::Arc; |
2 | 4 | ||
3 | use hir_expand::{ | 5 | use hir_expand::{ |
@@ -135,10 +137,10 @@ impl TraitData { | |||
135 | 137 | ||
136 | #[derive(Debug, Clone, PartialEq, Eq)] | 138 | #[derive(Debug, Clone, PartialEq, Eq)] |
137 | pub struct ImplData { | 139 | pub struct ImplData { |
138 | target_trait: Option<TypeRef>, | 140 | pub target_trait: Option<TypeRef>, |
139 | target_type: TypeRef, | 141 | pub target_type: TypeRef, |
140 | items: Vec<AssocItemId>, | 142 | pub items: Vec<AssocItemId>, |
141 | negative: bool, | 143 | pub is_negative: bool, |
142 | } | 144 | } |
143 | 145 | ||
144 | impl ImplData { | 146 | impl ImplData { |
@@ -148,7 +150,7 @@ impl ImplData { | |||
148 | 150 | ||
149 | let target_trait = src.value.target_trait().map(TypeRef::from_ast); | 151 | let target_trait = src.value.target_trait().map(TypeRef::from_ast); |
150 | let target_type = TypeRef::from_ast_opt(src.value.target_type()); | 152 | let target_type = TypeRef::from_ast_opt(src.value.target_type()); |
151 | let negative = src.value.is_negative(); | 153 | let is_negative = src.value.is_negative(); |
152 | 154 | ||
153 | let items = if let Some(item_list) = src.value.item_list() { | 155 | let items = if let Some(item_list) = src.value.item_list() { |
154 | item_list | 156 | item_list |
@@ -184,23 +186,7 @@ impl ImplData { | |||
184 | Vec::new() | 186 | Vec::new() |
185 | }; | 187 | }; |
186 | 188 | ||
187 | let res = ImplData { target_trait, target_type, items, negative }; | 189 | let res = ImplData { target_trait, target_type, items, is_negative }; |
188 | Arc::new(res) | 190 | Arc::new(res) |
189 | } | 191 | } |
190 | |||
191 | pub fn target_trait(&self) -> Option<&TypeRef> { | ||
192 | self.target_trait.as_ref() | ||
193 | } | ||
194 | |||
195 | pub fn target_type(&self) -> &TypeRef { | ||
196 | &self.target_type | ||
197 | } | ||
198 | |||
199 | pub fn items(&self) -> &[AssocItemId] { | ||
200 | &self.items | ||
201 | } | ||
202 | |||
203 | pub fn is_negative(&self) -> bool { | ||
204 | self.negative | ||
205 | } | ||
206 | } | 192 | } |