diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-27 12:18:55 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-27 12:18:55 +0000 |
commit | 2e2a6dd2fbeb4da16e602fa1902ab6bbd850b442 (patch) | |
tree | b42e6faf8618c3625e41d5a2011b4ffd145f22de /crates/ra_hir/src/code_model_impl/function.rs | |
parent | 1927eb088ac9aa3851f77bb929296873ccb4faed (diff) | |
parent | d3ce69aee3297e683691ec0123f5a2584a8075a0 (diff) |
Merge #900
900: Add new trait ast::TypeAscriptionOwner r=vipentti a=vipentti
This trait should be implemented for nodes which have an ascribed type,
e.g. thing : Type. Such as let, const, static, param, named struct fields.
In addition, we update some places where previously we used node + node.type_ref() with `TypeAscriptionOwner` in the trait bounds.
Co-authored-by: Ville Penttinen <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/code_model_impl/function.rs')
-rw-r--r-- | crates/ra_hir/src/code_model_impl/function.rs | 6 |
1 files changed, 3 insertions, 3 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 | } |