Monomorphised go to definition #8373
Labels
A-ide
general IDE features
C-feature
Category: feature request
E-hard
fun
A technically challenging issue with high impact
S-actionable
Someone could pick this issue up and work on it right now
Ideally, we should be able to follow a chain of go-to definitions to drill down to the specific implementations relied upon.
This would happen after #4558 is resolved.
One example is give in #2541 (comment)
Larger example
I often find myself trying to work out what code gets called in a specific instantiation of a generic function, e.g. inI would click go to definition on
exec
at A, which would take me to B. I'd then click go to definition offlobulate
at C, which I would want to take me to D, but instead takes me to E. If I want to find out what the specific implementation of flobulate actually does, I have to drop what I'm doing to track this manually. This means tracking which types are used in the instantiation I am interested in, trace them though (following associated types manually) and then track down the specific trait implementation which is actually used.This is not fun, and feels like something rust-analyzer could help with.
My proposed user experience would be that the generics would be tracked, in a sense monomorphising the generic types upon go to definition.
My super high level implementation suggestion would be:
When you follow a go to definition on a generic function, the generics the function is called with are pushed onto a stack somewhere. Ideally, going back using mouse 4 or alt-left would pop this stack. These generics would then be used to get the specific type information for the first step as far as possible. These types could also be displayed as inlay hints next to the generic declaraction, e.g.
in my example and
in the example from #2541 (comment)
Most of this is copied from my comment on zulip, where further related discussion might occur.
The text was updated successfully, but these errors were encountered: