diff options
author | Florian Diebold <[email protected]> | 2019-10-31 14:13:52 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-11-01 18:57:08 +0000 |
commit | c7cedea270c492e9a2c8b81c1312fda44fd8217e (patch) | |
tree | 85bac34220791ed418d07830a8f456d2d5629555 /crates | |
parent | 7b7133ec58818894d3d56df021ae70159e2c3252 (diff) |
Record assoc item resolution
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/ty/infer/path.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide_api/src/goto_definition.rs | 55 |
2 files changed, 58 insertions, 1 deletions
diff --git a/crates/ra_hir/src/ty/infer/path.rs b/crates/ra_hir/src/ty/infer/path.rs index 0cde77265..c58564b22 100644 --- a/crates/ra_hir/src/ty/infer/path.rs +++ b/crates/ra_hir/src/ty/infer/path.rs | |||
@@ -230,7 +230,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
230 | &mut self, | 230 | &mut self, |
231 | ty: Ty, | 231 | ty: Ty, |
232 | name: &Name, | 232 | name: &Name, |
233 | _id: ExprOrPatId, | 233 | id: ExprOrPatId, |
234 | ) -> Option<(ValueNs, Option<Substs>)> { | 234 | ) -> Option<(ValueNs, Option<Substs>)> { |
235 | let krate = self.resolver.krate()?; | 235 | let krate = self.resolver.krate()?; |
236 | 236 | ||
@@ -276,6 +276,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
276 | trait_: t, | 276 | trait_: t, |
277 | substs: trait_substs, | 277 | substs: trait_substs, |
278 | })); | 278 | })); |
279 | |||
280 | self.write_assoc_resolution(id, *item); | ||
279 | return Some((ValueNs::Function(f), Some(substs))); | 281 | return Some((ValueNs::Function(f), Some(substs))); |
280 | } | 282 | } |
281 | } | 283 | } |
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs index 323faab33..c1ce54bea 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs | |||
@@ -390,6 +390,61 @@ mod tests { | |||
390 | "spam RECORD_FIELD_DEF FileId(1) [17; 26) [17; 21)", | 390 | "spam RECORD_FIELD_DEF FileId(1) [17; 26) [17; 21)", |
391 | ); | 391 | ); |
392 | } | 392 | } |
393 | |||
394 | #[test] | ||
395 | fn goto_definition_works_for_ufcs_inherent_methods() { | ||
396 | check_goto( | ||
397 | " | ||
398 | //- /lib.rs | ||
399 | struct Foo; | ||
400 | impl Foo { | ||
401 | fn frobnicate() { } | ||
402 | } | ||
403 | |||
404 | fn bar(foo: &Foo) { | ||
405 | Foo::frobnicate<|>(); | ||
406 | } | ||
407 | ", | ||
408 | "frobnicate FN_DEF FileId(1) [27; 47) [30; 40)", | ||
409 | ); | ||
410 | } | ||
411 | |||
412 | #[test] | ||
413 | fn goto_definition_works_for_ufcs_trait_methods_through_traits() { | ||
414 | check_goto( | ||
415 | " | ||
416 | //- /lib.rs | ||
417 | trait Foo { | ||
418 | fn frobnicate(); | ||
419 | } | ||
420 | |||
421 | fn bar() { | ||
422 | Foo::frobnicate<|>(); | ||
423 | } | ||
424 | ", | ||
425 | "frobnicate FN_DEF FileId(1) [16; 32) [19; 29)", | ||
426 | ); | ||
427 | } | ||
428 | |||
429 | #[test] | ||
430 | fn goto_definition_works_for_ufcs_trait_methods_through_self() { | ||
431 | check_goto( | ||
432 | " | ||
433 | //- /lib.rs | ||
434 | struct Foo; | ||
435 | trait Trait { | ||
436 | fn frobnicate(); | ||
437 | } | ||
438 | impl Trait for Foo {} | ||
439 | |||
440 | fn bar() { | ||
441 | Foo::frobnicate<|>(); | ||
442 | } | ||
443 | ", | ||
444 | "frobnicate FN_DEF FileId(1) [30; 46) [33; 43)", | ||
445 | ); | ||
446 | } | ||
447 | |||
393 | #[test] | 448 | #[test] |
394 | fn goto_definition_on_self() { | 449 | fn goto_definition_on_self() { |
395 | check_goto( | 450 | check_goto( |