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

An error message should not contain a keyword x such that searching rust + x has 0 relevant results on the first page #42603

Closed
SRGOM opened this issue Jun 12, 2017 · 8 comments · Fixed by #64110
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@SRGOM
Copy link

SRGOM commented Jun 12, 2017

Case in point: I get an error:

the trait `Foo` cannot be made into an object
....
method add has no receiver

I looked up rust receiver but couldn't find any relevant results. Upon investigating further, in this case, method add does not have a self parameter would be more appropriate.

@frewsxcv
Copy link
Member

Is it possible you could share the code that results in this error?

@frewsxcv frewsxcv added the A-diagnostics Area: Messages for errors, warnings, and lints label Jun 12, 2017
@jonas-schievink
Copy link
Contributor

Anything like this'll work:

trait Tr { fn recv(); }

fn main() {
    let t: &Tr = panic!();
}

@SRGOM
Copy link
Author

SRGOM commented Jun 12, 2017

What @jonas-schievink said, my code:


trait Foo{
    fn add( s: Self, o: Self ) -> Self;
}

impl Foo for i32{
    fn add( s: Self, o: Self ) -> Self {
        s + o
    }
}

fn scratchpad()
{
     let a: &Foo = &99;
}

@estebank
Copy link
Contributor

For me the fourth result for "rust method has no receiver" is the Error Index, where there's a full explanation of error E0038 (which you can also see using rustc --explain E0038). That explanation has a subsection titled "Method has no receiver" which explain this case and proposes a solution:

Adding a Self: Sized bound to these methods will generally make this compile.

@SRGOM
Copy link
Author

SRGOM commented Jun 13, 2017

@estebank I hit 1st and 3rd results on that one and they were irrelevant so I figured i'll try to understand the problem from the bottom. That's why I searched "Rust receiver" (without quotes) as the issue title says.

@durka
Copy link
Contributor

durka commented Jun 13, 2017

I think "receiver" is the correct term here and as mentioned, rustc --explain E0038 has a good amount of explanation. So I understand @SRGOM's frustration but I don't think there is really anything to do here, besides maybe adding a section to the Book along these lines.

@nikomatsakis
Copy link
Contributor

The receiver term is pretty standard "OO jargon", but I think that it would be clearer still for us to say "no self parameter".

@nikomatsakis
Copy link
Contributor

Also, in my opinion, an associated function without a parameter named self is not a method at all, but just a function; so I'd probably say something like "the function add has no self parameter")

@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 26, 2017
Centril added a commit to Centril/rust that referenced this issue Sep 5, 2019
Refer to "`self` type" instead of "receiver type"

Fix rust-lang#42603.
@bors bors closed this as completed in 8ef11fc Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants