-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Hint about missing trait method suggests incorrect code (self parameter not named "self"). #71150
Comments
@rustbot claim |
I managed to fix this issue by just manually checking if the argument is of type |
I’m not just interested in a fix for this particular case. Types that allow dispatch can be arbitrarily nested AFAIK and also I didn’t tag Oh, wow, I’ll expand this bug-report. Hint about missing trait method suggests incorrect code (non-self parameter mistakenly named "self").Create a binary crate named “my-crate” with: main.rs struct S;
impl my_crate::Tr for S {}
fn main() {
println!("Hello, world!");
} lib.rs pub trait Tr {
fn f(self: &Self, not_self: &Self);
} Error message is:
|
Makes sense as if I recall correctly (can't link files rn as I am on my phone) the code literally just checks if the type is (&/&mut)Self and if it is it prints (&/&mut)self otherwise it prints _: Type. A potential fix could be printing (&/&mut)self only if it's the first argument of the function |
Won’t be enough. The first parameter of a trait fn could be of type |
Another issue related to this is when you have a function that has a signature of I should have fixed it, as soon as all of the tests pass I will make a PR |
Fixed missing trait method suggests incorrect code (self parameter not named "self"). fixes rust-lang#71150
In the error message below, the first argument of
poll
is not namedself
.(Playground)
Errors:
@rustbot modify labels: T-compiler, A-diagnostics, C-enhancement, D-papercut, F-arbitrary_self_types.
This issue has been assigned to @Duddino via this comment.
The text was updated successfully, but these errors were encountered: