aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-05-23 22:55:51 +0100
committerGitHub <[email protected]>2021-05-23 22:55:51 +0100
commit495c9586ec51e0cf9b06397d99ec4f65c55e7a28 (patch)
treec18eb1b1568ab0f0251339f7995b6ea177b3285f /crates/ide_db/src
parenta2ce091fd7e149f809bdf0ee0d960d9e185ee5fb (diff)
parentb8262099cc51065259daf10b4b23ff49ce74434f (diff)
Merge #8945
8945: fix: Make expected type work in more situations r=flodiebold a=flodiebold Also makes call info show the correct types for generic methods. ![2021-05-23-182952_1134x616_scrot](https://user-images.githubusercontent.com/906069/119269023-dd5a5b00-bbf5-11eb-993a-b6e122c3b9a6.png) ![2021-05-23-183117_922x696_scrot](https://user-images.githubusercontent.com/906069/119269025-dfbcb500-bbf5-11eb-983c-fc415b8428e0.png) Co-authored-by: Florian Diebold <[email protected]>
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
2 files changed, 19 insertions, 1 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),