File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
src/librustc_error_codes/error_codes Expand file tree Collapse file tree 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+ ```
317
418Methods 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,
4054like in the following example:
4155
4256``` compile_fail,E0307
You can’t perform that action at this time.
0 commit comments