aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/data.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/data.rs')
-rw-r--r--crates/ra_hir_def/src/data.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs
index 81a8ec18d..68bea34df 100644
--- a/crates/ra_hir_def/src/data.rs
+++ b/crates/ra_hir_def/src/data.rs
@@ -200,18 +200,17 @@ pub struct ConstData {
200impl ConstData { 200impl ConstData {
201 pub(crate) fn const_data_query(db: &impl DefDatabase, konst: ConstId) -> Arc<ConstData> { 201 pub(crate) fn const_data_query(db: &impl DefDatabase, konst: ConstId) -> Arc<ConstData> {
202 let node = konst.lookup(db).source(db).value; 202 let node = konst.lookup(db).source(db).value;
203 const_data_for(&node) 203 Arc::new(ConstData::new(&node))
204 } 204 }
205 205
206 pub(crate) fn static_data_query(db: &impl DefDatabase, konst: StaticId) -> Arc<ConstData> { 206 pub(crate) fn static_data_query(db: &impl DefDatabase, konst: StaticId) -> Arc<ConstData> {
207 let node = konst.lookup(db).source(db).value; 207 let node = konst.lookup(db).source(db).value;
208 const_data_for(&node) 208 Arc::new(ConstData::new(&node))
209 } 209 }
210}
211 210
212fn const_data_for<N: NameOwner + TypeAscriptionOwner>(node: &N) -> Arc<ConstData> { 211 fn new<N: NameOwner + TypeAscriptionOwner>(node: &N) -> ConstData {
213 let name = node.name().map(|n| n.as_name()); 212 let name = node.name().map(|n| n.as_name());
214 let type_ref = TypeRef::from_ast_opt(node.ascribed_type()); 213 let type_ref = TypeRef::from_ast_opt(node.ascribed_type());
215 let sig = ConstData { name, type_ref }; 214 ConstData { name, type_ref }
216 Arc::new(sig) 215 }
217} 216}