Skip to content
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

"Go To References" for PartialOrd functions should find comparison operators #18540

Open
JarredAllen opened this issue Nov 21, 2024 · 1 comment
Labels
C-feature Category: feature request

Comments

@JarredAllen
Copy link

If I have code like this:

pub struct Foo { .. }

impl PartialOrd for Foo { .. }

// also `Eq` and `PartialEq` are implemented consistently with `PartialOrd`

fn compare_foos(foo1: Foo, foo2: Foo) -> bool {
    foo1 <= foo2
}

Running "go to definition" on the <= will go to the definition of the le method in the impl PartialOrd for Foo (including to the default implementation in the PartialOrd trait if not explicitly overridden in the impl block), but running "go to references" can't go back the other way.

It'd be great if I could "go to references" on the le function to find all places where <= is used to compare 2 Foos. It'd be even greater if, for a type that only implements the partial_cmp function and leaves the default implementations alone, "go to references" could find all the </<=/>/>= comparison operators (not sure if this second part is feasible, since it does technically go through a different method).

@JarredAllen JarredAllen added the C-feature Category: feature request label Nov 21, 2024
@ChayimFriedman2
Copy link
Contributor

Ah yes I noticed that a while ago. Do note however that this is going to be pretty much the slowest thing we ever provide (find all references is based on textual search then refinement using semantics info - because calculating semantic info is expensive. Searching for operators is going to find a lot of matches).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category: feature request
Projects
None yet
Development

No branches or pull requests

2 participants