File tree 1 file changed +17
-3
lines changed
src/librustc_error_codes/error_codes
1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 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
+ ```
3
17
4
18
Methods take a special first parameter, of which there are three variants:
5
19
` self ` , ` &self ` , and ` &mut self ` . These are syntactic sugar for
@@ -36,7 +50,7 @@ impl Trait for Foo {
36
50
}
37
51
```
38
52
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,
40
54
like in the following example:
41
55
42
56
``` compile_fail,E0307
You can’t perform that action at this time.
0 commit comments