Skip to content

Commit 82a366a

Browse files
authored
Rollup merge of #69055 - GuillaumeGomez:clean-up-e0307, r=Dylan-DPC
Clean up E0307 explanation r? @Dylan-DPC
2 parents c88b349 + e20108f commit 82a366a

File tree

1 file changed

+17
-3
lines changed
  • src/librustc_error_codes/error_codes

1 file changed

+17
-3
lines changed

src/librustc_error_codes/error_codes/E0307.md

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
This error indicates that the `self` parameter in a method has an invalid
2-
"receiver type".
1+
The `self` parameter in a method has an invalid "receiver type".
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0307
6+
struct Foo;
7+
struct Bar;
8+
9+
trait Trait {
10+
fn foo(&self);
11+
}
12+
13+
impl Trait for Foo {
14+
fn foo(self: &Bar) {}
15+
}
16+
```
317

418
Methods take a special first parameter, of which there are three variants:
519
`self`, `&self`, and `&mut self`. These are syntactic sugar for
@@ -36,7 +50,7 @@ impl Trait for Foo {
3650
}
3751
```
3852

39-
E0307 will be emitted by the compiler when using an invalid receiver type,
53+
This error will be emitted by the compiler when using an invalid receiver type,
4054
like in the following example:
4155

4256
```compile_fail,E0307

0 commit comments

Comments
 (0)