aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_db/src')
-rw-r--r--crates/ide_db/src/call_info/tests.rs18
-rw-r--r--crates/ide_db/src/defs.rs2
-rw-r--r--crates/ide_db/src/ty_filter.rs6
3 files changed, 22 insertions, 4 deletions
diff --git a/crates/ide_db/src/call_info/tests.rs b/crates/ide_db/src/call_info/tests.rs
index be1cc12de..1aeda08e5 100644
--- a/crates/ide_db/src/call_info/tests.rs
+++ b/crates/ide_db/src/call_info/tests.rs
@@ -189,6 +189,24 @@ fn main() { S.foo($0); }
189} 189}
190 190
191#[test] 191#[test]
192fn test_fn_signature_for_generic_method() {
193 check(
194 r#"
195struct S<T>(T);
196impl<T> S<T> {
197 fn foo(&self, x: T) {}
198}
199
200fn main() { S(1u32).foo($0); }
201"#,
202 expect![[r#"
203 fn foo(&self, x: u32)
204 (<x: u32>)
205 "#]],
206 );
207}
208
209#[test]
192fn test_fn_signature_for_method_with_arg_as_assoc_fn() { 210fn test_fn_signature_for_method_with_arg_as_assoc_fn() {
193 check( 211 check(
194 r#" 212 r#"
diff --git a/crates/ide_db/src/defs.rs b/crates/ide_db/src/defs.rs
index de0dc2a40..1dcccbb8b 100644
--- a/crates/ide_db/src/defs.rs
+++ b/crates/ide_db/src/defs.rs
@@ -311,7 +311,7 @@ impl NameRefClass {
311 } 311 }
312 312
313 if let Some(record_field) = ast::RecordExprField::for_field_name(name_ref) { 313 if let Some(record_field) = ast::RecordExprField::for_field_name(name_ref) {
314 if let Some((field, local)) = sema.resolve_record_field(&record_field) { 314 if let Some((field, local, _)) = sema.resolve_record_field(&record_field) {
315 let field = Definition::Field(field); 315 let field = Definition::Field(field);
316 let res = match local { 316 let res = match local {
317 None => NameRefClass::Definition(field), 317 None => NameRefClass::Definition(field),
diff --git a/crates/ide_db/src/ty_filter.rs b/crates/ide_db/src/ty_filter.rs
index 00678bf3e..766d8c628 100644
--- a/crates/ide_db/src/ty_filter.rs
+++ b/crates/ide_db/src/ty_filter.rs
@@ -4,7 +4,7 @@
4 4
5use std::iter; 5use std::iter;
6 6
7use hir::{Adt, Semantics, Type}; 7use hir::Semantics;
8use syntax::ast::{self, make}; 8use syntax::ast::{self, make};
9 9
10use crate::RootDatabase; 10use crate::RootDatabase;
@@ -20,9 +20,9 @@ impl TryEnum {
20 const ALL: [TryEnum; 2] = [TryEnum::Option, TryEnum::Result]; 20 const ALL: [TryEnum; 2] = [TryEnum::Option, TryEnum::Result];
21 21
22 /// Returns `Some(..)` if the provided type is an enum that implements `std::ops::Try`. 22 /// Returns `Some(..)` if the provided type is an enum that implements `std::ops::Try`.
23 pub fn from_ty(sema: &Semantics<RootDatabase>, ty: &Type) -> Option<TryEnum> { 23 pub fn from_ty(sema: &Semantics<RootDatabase>, ty: &hir::Type) -> Option<TryEnum> {
24 let enum_ = match ty.as_adt() { 24 let enum_ = match ty.as_adt() {
25 Some(Adt::Enum(it)) => it, 25 Some(hir::Adt::Enum(it)) => it,
26 _ => return None, 26 _ => return None,
27 }; 27 };
28 TryEnum::ALL.iter().find_map(|&var| { 28 TryEnum::ALL.iter().find_map(|&var| {