Skip to content

Small mistake in method call expressions explanation? #718

Open
@LukasKalbertodt

Description

@LukasKalbertodt

Here it says:

Then, for each candidate type T, search for a visible method with a receiver of that type in the following places:

  1. T's inherent methods (methods implemented directly on T).
  2. [...]

The part "methods implemented directly on T" is not completely correct, I think. As first sentence already says, we are searching for methods with the receiver type T, not methods in an impl block for T. And those two types can obviously be different.

impl Foo {
    fn by_ref(&self) {}
}

Suppose our candidate type T is &Foo, then by_ref would be a "visible method with a receiver of that type". However, the method by_ref is not implemented on &Foo, but on Foo. In other words: Self in that method is Foo, not &Foo.

To fix this, I would replace "methods implemented directly on T" with: "methods that belong to a type and not to a trait". Or something like that.

Am I correct that the current phrasing is wrong/very misleading? Or am I missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions