@@ -1013,30 +1013,31 @@ fn h1() -> i32 {
1013
1013
"## ,
1014
1014
1015
1015
E0424 : r##"
1016
- The `self` keyword was used inside of an associated function instead of inside
1017
- of a method. Associated functions have no " `self` receiver" argument, and are
1018
- equivalent to regular functions which exist in the namespace of a trait.
1019
- Methods, on the other hand, have a `self` reciver argument , like `self`,
1020
- `&self`, `& mut self` or `self: &mut Pin<Self>` (this last one is an example of
1021
- an ["abitrary `self` type"](https://github.com/rust-lang/rust/issues/44874)).
1016
+ The `self` keyword was used inside of an associated function without a "`self`
1017
+ receiver" parameter. The `self` keyword can only be used inside methods, which
1018
+ are associated functions ( functions defined inside of a ` trait` or `impl` block)
1019
+ that have a `self` receiver as its first parameter , like `self`, `& self`,
1020
+ `&mut self` or `self: &mut Pin<Self>` (this last one is an example of an
1021
+ ["abitrary `self` type"](https://github.com/rust-lang/rust/issues/44874)).
1022
1022
1023
1023
Erroneous code example:
1024
1024
1025
1025
```compile_fail,E0424
1026
1026
struct Foo;
1027
1027
1028
1028
impl Foo {
1029
- // `bar` is a method, because it has a receiver argument .
1029
+ // `bar` is a method, because it has a receiver parameter .
1030
1030
fn bar(&self) {}
1031
1031
1032
- // `foo` is an associated function , because it has no receiver argument .
1032
+ // `foo` is not a method , because it has no receiver parameter .
1033
1033
fn foo() {
1034
- self.bar(); // error: `self` is not available in an associated function
1034
+ self.bar(); // error: `self` value is a keyword only available in
1035
+ // methods with a `self` parameter
1035
1036
}
1036
1037
}
1037
1038
```
1038
1039
1039
- Check if the associated function's argument list should have contained a `self`
1040
+ Check if the associated function's parameter list should have contained a `self`
1040
1041
receiver for it to be a method, and add it if so. Example:
1041
1042
1042
1043
```
0 commit comments