Method call reference: major rewrite by adetaylor · Pull Request #1725 · rust-lang/reference (original) (raw)

this is currently confusing to me, it's also confusing in the source :3

what's happening here is:

However, we manually look for methods from T: Trait bounds to give them precedence over methods from other traits:

trait Trait { fn method(&self) {} } impl Trait for T {} trait OtherTrait { fn method(&self) {} } impl OtherTrait for T {}

struct Wrapper(T); fn foo(x: T, y: Wrapper) where T: Trait, Wrapper: Trait, { x.method(); // ok y.method(); // error }

The same in the "trait object" section.

I personally would prefer to only talk about 'inherent' and 'trait' candidates and then mention at the end that some trait candidates are given the same precedence as inherent ones. But that feels like a fairly big change (and diverges from the current terminology used in rustc)

there's already a convo with @traviscross about this, i think it's fine and idk how to meaningfully change this to be clearer for me 🤔