diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-06-07 05:52:38 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-07 05:52:38 +0100 |
commit | efa84cd08d9e4d1d464ffc6832a1d1b1c85aed23 (patch) | |
tree | 062f9e4fdb3e675c5a361e3f14a5659a6f4bb810 /crates/hir | |
parent | 13da28cc2bc1b59f7af817eca36927a71edb023c (diff) | |
parent | 34ce05781fbca1bc6b717cce3bee6bd9923248b2 (diff) |
Merge #9106
9106: feat: goto definition on an impl fn goes to that fn in the trait r=lf- a=lf-
e.g. if you have a trait T and `impl T for S` for some struct, if you
goto definition on some function name inside the impl, it will go to the
definition of that function inside the `trait T` block, rather than the
current behaviour of not going anywhere at all.
![ra goto def trait the other way](https://user-images.githubusercontent.com/6652840/120403989-39aa3280-c2fa-11eb-9359-639346878acd.gif)
Co-authored-by: Jade <[email protected]>
Diffstat (limited to 'crates/hir')
-rw-r--r-- | crates/hir/src/lib.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index b43d61d0e..c2b68a853 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -50,7 +50,6 @@ use hir_def::{ | |||
50 | per_ns::PerNs, | 50 | per_ns::PerNs, |
51 | resolver::{HasResolver, Resolver}, | 51 | resolver::{HasResolver, Resolver}, |
52 | src::HasSource as _, | 52 | src::HasSource as _, |
53 | type_ref::TraitRef, | ||
54 | AdtId, AssocContainerId, AssocItemId, AssocItemLoc, AttrDefId, ConstId, ConstParamId, | 53 | AdtId, AssocContainerId, AssocItemId, AssocItemLoc, AttrDefId, ConstId, ConstParamId, |
55 | DefWithBodyId, EnumId, FunctionId, GenericDefId, HasModule, ImplId, LifetimeParamId, | 54 | DefWithBodyId, EnumId, FunctionId, GenericDefId, HasModule, ImplId, LifetimeParamId, |
56 | LocalEnumVariantId, LocalFieldId, Lookup, ModuleId, StaticId, StructId, TraitId, TypeAliasId, | 55 | LocalEnumVariantId, LocalFieldId, Lookup, ModuleId, StaticId, StructId, TraitId, TypeAliasId, |
@@ -1797,9 +1796,11 @@ impl Impl { | |||
1797 | } | 1796 | } |
1798 | 1797 | ||
1799 | // FIXME: the return type is wrong. This should be a hir version of | 1798 | // FIXME: the return type is wrong. This should be a hir version of |
1800 | // `TraitRef` (ie, resolved `TypeRef`). | 1799 | // `TraitRef` (to account for parameters and qualifiers) |
1801 | pub fn trait_(self, db: &dyn HirDatabase) -> Option<TraitRef> { | 1800 | pub fn trait_(self, db: &dyn HirDatabase) -> Option<Trait> { |
1802 | db.impl_data(self.id).target_trait.as_deref().cloned() | 1801 | let trait_ref = db.impl_trait(self.id)?.skip_binders().clone(); |
1802 | let id = hir_ty::from_chalk_trait_id(trait_ref.trait_id); | ||
1803 | Some(Trait { id }) | ||
1803 | } | 1804 | } |
1804 | 1805 | ||
1805 | pub fn self_ty(self, db: &dyn HirDatabase) -> Type { | 1806 | pub fn self_ty(self, db: &dyn HirDatabase) -> Type { |