Skip to content

Commit 865c4bc

Browse files
committed
review comments: help wording
1 parent f65a492 commit 865c4bc

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/librustc_resolve/error_codes.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -1013,30 +1013,31 @@ fn h1() -> i32 {
10131013
"##,
10141014

10151015
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)).
10221022
10231023
Erroneous code example:
10241024
10251025
```compile_fail,E0424
10261026
struct Foo;
10271027
10281028
impl Foo {
1029-
// `bar` is a method, because it has a receiver argument.
1029+
// `bar` is a method, because it has a receiver parameter.
10301030
fn bar(&self) {}
10311031
1032-
// `foo` is an associated function, because it has no receiver argument.
1032+
// `foo` is not a method, because it has no receiver parameter.
10331033
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
10351036
}
10361037
}
10371038
```
10381039
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`
10401041
receiver for it to be a method, and add it if so. Example:
10411042
10421043
```

0 commit comments

Comments
 (0)