From 3bd47c0285433b5eb258196a81b95141d2a70505 Mon Sep 17 00:00:00 2001 From: Marcus Klaas de Vries Date: Fri, 25 Jan 2019 21:16:02 +0100 Subject: First attempt at generic type inference for fns --- crates/ra_hir/src/code_model_api.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'crates/ra_hir/src/code_model_api.rs') diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index 191104890..82ebb275a 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs @@ -388,7 +388,7 @@ pub use crate::code_model_impl::function::ScopeEntryWithSyntax; #[derive(Debug, Clone, PartialEq, Eq)] pub struct FnSignature { pub(crate) name: Name, - pub(crate) params: Vec, + pub(crate) args: Vec, pub(crate) ret_type: TypeRef, /// True if the first param is `self`. This is relevant to decide whether this /// can be called as a method. @@ -400,8 +400,8 @@ impl FnSignature { &self.name } - pub fn params(&self) -> &[TypeRef] { - &self.params + pub fn args(&self) -> &[TypeRef] { + &self.args } pub fn ret_type(&self) -> &TypeRef { -- cgit v1.2.3 From 67e40e431aa966a76b6a247b19505e22b620a0c7 Mon Sep 17 00:00:00 2001 From: Marcus Klaas de Vries Date: Fri, 25 Jan 2019 22:18:13 +0100 Subject: Initial implementation of generics for method calls --- crates/ra_hir/src/code_model_api.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'crates/ra_hir/src/code_model_api.rs') diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index 82ebb275a..defb9fd0a 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs @@ -424,6 +424,10 @@ impl Function { self.id.module(db) } + pub fn name(&self, db: &impl HirDatabase) -> Name { + self.signature(db).name.clone() + } + pub fn body_syntax_mapping(&self, db: &impl HirDatabase) -> Arc { db.body_syntax_mapping(*self) } -- cgit v1.2.3 From aa06893a1493770f8009d098a5340f1a9ba13dec Mon Sep 17 00:00:00 2001 From: Marcus Klaas de Vries Date: Sat, 26 Jan 2019 00:30:56 +0100 Subject: Add type params to FnSignature --- crates/ra_hir/src/code_model_api.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'crates/ra_hir/src/code_model_api.rs') diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index defb9fd0a..a13da58d2 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs @@ -388,6 +388,7 @@ pub use crate::code_model_impl::function::ScopeEntryWithSyntax; #[derive(Debug, Clone, PartialEq, Eq)] pub struct FnSignature { pub(crate) name: Name, + pub(crate) type_params: Arc, pub(crate) args: Vec, pub(crate) ret_type: TypeRef, /// True if the first param is `self`. This is relevant to decide whether this @@ -413,6 +414,10 @@ impl FnSignature { pub fn has_self_param(&self) -> bool { self.has_self_param } + + pub fn generics(&self) -> &GenericParams { + &self.type_params + } } impl Function { -- cgit v1.2.3 From 089b1c57c1774eb1aacec53828ce2d2648adff2d Mon Sep 17 00:00:00 2001 From: Marcus Klaas de Vries Date: Sat, 26 Jan 2019 12:06:41 +0100 Subject: Address some issues flagged in review --- crates/ra_hir/src/code_model_api.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'crates/ra_hir/src/code_model_api.rs') diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index a13da58d2..e4008058c 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs @@ -388,8 +388,7 @@ pub use crate::code_model_impl::function::ScopeEntryWithSyntax; #[derive(Debug, Clone, PartialEq, Eq)] pub struct FnSignature { pub(crate) name: Name, - pub(crate) type_params: Arc, - pub(crate) args: Vec, + pub(crate) params: Vec, pub(crate) ret_type: TypeRef, /// True if the first param is `self`. This is relevant to decide whether this /// can be called as a method. @@ -401,8 +400,8 @@ impl FnSignature { &self.name } - pub fn args(&self) -> &[TypeRef] { - &self.args + pub fn params(&self) -> &[TypeRef] { + &self.params } pub fn ret_type(&self) -> &TypeRef { @@ -414,10 +413,6 @@ impl FnSignature { pub fn has_self_param(&self) -> bool { self.has_self_param } - - pub fn generics(&self) -> &GenericParams { - &self.type_params - } } impl Function { -- cgit v1.2.3