I have a giant Rust codebase (one workspace containing a bunch of crates) that contains something like this:
pub struct Foo { .. }
impl PartialOrd for Foo {
fn partial_cmp((&self, other: &Self) -> Option<Ordering> { .. }
}
// also `Eq` and `PartialEq` are implemented consistently with `PartialOrd`
Is there a way I can find all the places in my codebase where I'm comparing two instances of Foo
using my PartialOrd
implementation?
I've tried using rust-analyzer
's "go to reference" functionality, but it only finds explicit calls to the partial_cmp
function, and not any of the comparison operators (like <
). I've also tried adding explicit definitions of the comparison functions (e.g. overriding fn lt(..)
) to "go to reference" on it, but it also misses the comparison operators, as it'll find x.lt(&y)
, but not x < y
).