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/code_model_impl/konst.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/crates/ra_hir/src/code_model_impl/konst.rs b/crates/ra_hir/src/code_model_impl/konst.rs
index ecf4c8122..8b861a81f 100644
--- a/crates/ra_hir/src/code_model_impl/konst.rs
+++ b/crates/ra_hir/src/code_model_impl/konst.rs
@@ -1,6 +1,6 @@
1use std::sync::Arc; 1use std::sync::Arc;
2 2
3use ra_syntax::ast::{self, NameOwner}; 3use ra_syntax::ast::{NameOwner, TypeAscriptionOwner};
4 4
5use crate::{ 5use crate::{
6 Name, AsName, Const, ConstSignature, Static, 6 Name, AsName, Const, ConstSignature, Static,
@@ -8,12 +8,9 @@ use crate::{
8 PersistentHirDatabase, 8 PersistentHirDatabase,
9}; 9};
10 10
11fn const_signature_for<N: NameOwner>( 11fn const_signature_for<N: NameOwner + TypeAscriptionOwner>(node: &N) -> Arc<ConstSignature> {
12 node: &N,
13 type_ref: Option<&ast::TypeRef>,
14) -> Arc<ConstSignature> {
15 let name = node.name().map(|n| n.as_name()).unwrap_or_else(Name::missing); 12 let name = node.name().map(|n| n.as_name()).unwrap_or_else(Name::missing);
16 let type_ref = TypeRef::from_ast_opt(type_ref); 13 let type_ref = TypeRef::from_ast_opt(node.ascribed_type());
17 let sig = ConstSignature { name, type_ref }; 14 let sig = ConstSignature { name, type_ref };
18 Arc::new(sig) 15 Arc::new(sig)
19} 16}
@@ -24,7 +21,7 @@ impl ConstSignature {
24 konst: Const, 21 konst: Const,
25 ) -> Arc<ConstSignature> { 22 ) -> Arc<ConstSignature> {
26 let (_, node) = konst.source(db); 23 let (_, node) = konst.source(db);
27 const_signature_for(&*node, node.type_ref()) 24 const_signature_for(&*node)
28 } 25 }
29 26
30 pub(crate) fn static_signature_query( 27 pub(crate) fn static_signature_query(
@@ -32,6 +29,6 @@ impl ConstSignature {
32 konst: Static, 29 konst: Static,
33 ) -> Arc<ConstSignature> { 30 ) -> Arc<ConstSignature> {
34 let (_, node) = konst.source(db); 31 let (_, node) = konst.source(db);
35 const_signature_for(&*node, node.type_ref()) 32 const_signature_for(&*node)
36 } 33 }
37} 34}