-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
E0424 The self keyword was used in a static method. #59782
Comments
cc @Centril |
Yea; the diagnostic is wrong. Methods are only those things that have receivers ( |
"Static method" is just an older terminology, which should be natural and familiar if you used any other popular language before, but, IIRC, the doc (or lang) team made a decision not to use it in documentation at one point without providing a good alternative. If you want to "fix" this you may want to update a bunch of other docs as well, rust-by-example in particular. |
@Centril I think it would be better to get the lang team to sign on how to call these. I agree with @petrochenkov that we used to have terminology for these ( From a grammar POV, an |
@gnzlbg I don't view "non-method" as a name really; it's describing things explicitly by opposition to methods, which makes sense for this diagnostic since having a cc @rust-lang/lang @rust-lang/docs I don't want to FCP this... it's not important enough to get all the team to sign off. |
Regarding arbitrary self types... There are a couple of places where suggestions or help text is technically incorrect by omission, like this one. We need to walk the line of being correct, thorough, and succinct. I'm not sure this case is a good place to teach people about this feature, depending on how much text/space it takes. |
@estebank perhaps link to a more elaborate description in the message? |
@estebank maybe using something like: "self receivers (like |
…tril Refer to "associated functions" instead of "static methods" Fix rust-lang#59782.
…tril Refer to "associated functions" instead of "static methods" Fix rust-lang#59782.
Just came across this error in Rust edition 2021. I understand what the error means, but for anyone looking for a simpler explanation, struct MyStruct {
name: String
}
impl MyStruct {
fn first_fn() {
self.second_fn()
}
fn second_fn(&self) {
println!("Second fn");
}
} The above code was similar to my use-case. To make the code work, you have to make the |
Note that the current error for that example is
which I feel provides the context needed. @dayo777 is there anything there that you'd want to add? |
Hello @estebank , nothing. |
E0424 states:
But
static
method is probably wrong, it should just say a non-method (I don't think we have a technical term to refer to methods that do not take an arbitrary self type as first argument).It continues with:
That's outdated,
&mut Pin<Self>
(and others) work too. So this should be updated to cover arbitrarySelf
types.The text was updated successfully, but these errors were encountered: