diff options
Diffstat (limited to 'crates/ra_hir/src/code_model_impl')
-rw-r--r-- | crates/ra_hir/src/code_model_impl/function.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model_impl/konst.rs | 13 |
2 files changed, 8 insertions, 11 deletions
diff --git a/crates/ra_hir/src/code_model_impl/function.rs b/crates/ra_hir/src/code_model_impl/function.rs index c401528c6..c1654b069 100644 --- a/crates/ra_hir/src/code_model_impl/function.rs +++ b/crates/ra_hir/src/code_model_impl/function.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use ra_syntax::ast::{self, NameOwner}; | 3 | use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner}; |
4 | 4 | ||
5 | use crate::{ | 5 | use crate::{ |
6 | Name, AsName, Function, FnSignature, | 6 | Name, AsName, Function, FnSignature, |
@@ -19,7 +19,7 @@ impl FnSignature { | |||
19 | let mut has_self_param = false; | 19 | let mut has_self_param = false; |
20 | if let Some(param_list) = node.param_list() { | 20 | if let Some(param_list) = node.param_list() { |
21 | if let Some(self_param) = param_list.self_param() { | 21 | if let Some(self_param) = param_list.self_param() { |
22 | let self_type = if let Some(type_ref) = self_param.type_ref() { | 22 | let self_type = if let Some(type_ref) = self_param.ascribed_type() { |
23 | TypeRef::from_ast(type_ref) | 23 | TypeRef::from_ast(type_ref) |
24 | } else { | 24 | } else { |
25 | let self_type = TypeRef::Path(Name::self_type().into()); | 25 | let self_type = TypeRef::Path(Name::self_type().into()); |
@@ -37,7 +37,7 @@ impl FnSignature { | |||
37 | has_self_param = true; | 37 | has_self_param = true; |
38 | } | 38 | } |
39 | for param in param_list.params() { | 39 | for param in param_list.params() { |
40 | let type_ref = TypeRef::from_ast_opt(param.type_ref()); | 40 | let type_ref = TypeRef::from_ast_opt(param.ascribed_type()); |
41 | params.push(type_ref); | 41 | params.push(type_ref); |
42 | } | 42 | } |
43 | } | 43 | } |
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 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use ra_syntax::ast::{self, NameOwner}; | 3 | use ra_syntax::ast::{NameOwner, TypeAscriptionOwner}; |
4 | 4 | ||
5 | use crate::{ | 5 | use 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 | ||
11 | fn const_signature_for<N: NameOwner>( | 11 | fn 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 | } |