Skip to content

Go to definition on overloadable operators #11105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lunacookies opened this issue Dec 23, 2021 · 3 comments
Closed

Go to definition on overloadable operators #11105

lunacookies opened this issue Dec 23, 2021 · 3 comments
Labels
A-ide general IDE features C-feature Category: feature request E-has-instructions Issue has some instructions and pointers to code to get started E-medium S-actionable Someone could pick this issue up and work on it right now

Comments

@lunacookies
Copy link
Contributor

As far as I can tell, rust-analyzer already supports operator overloading in type inference, at least. Would it be possible to extend this so using ‘go to definition’ on operators such as + and ? would jump to the corresponding impl block?

@Veykril Veykril added the A-ide general IDE features label Dec 23, 2021
@Veykril
Copy link
Member

Veykril commented Dec 23, 2021

That should be somewhat doable(probably needs some extra work once we are able to resolve to actual impls of traits for this to also work there), https://github.com/rust-analyzer/rust-analyzer/blob/4ea1f58bf6b3fd5bb59ed583f2ac432e237e1e1e/crates/ide_db/src/defs.rs#L44-L110 is where we probably want to do this resolution which should make this work for most of the ide area.

@flodiebold
Copy link
Member

Going to the actual impl is blocked on #4558, but making go to definition work for operators could be done right now, as @Veykril described. It would just go to the trait for now. We actually already record the resolution (to the trait method) during type inference, so the IDE code should just be able to look it up in the method_resolutions.

@flodiebold flodiebold added C-feature Category: feature request E-has-instructions Issue has some instructions and pointers to code to get started E-medium S-actionable Someone could pick this issue up and work on it right now labels Dec 23, 2021
@l1nxy
Copy link
Contributor

l1nxy commented Dec 28, 2023

This feature has been implemented by #4558, so maybe we should close this issue.
Any idea? @Veykril @flodiebold

@Veykril Veykril closed this as completed Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ide general IDE features C-feature Category: feature request E-has-instructions Issue has some instructions and pointers to code to get started E-medium S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants