Skip to content

Commit 1a3c8c8

Browse files
Clean up E0050
1 parent 2312207 commit 1a3c8c8

File tree

1 file changed

+21
-5
lines changed
  • src/librustc_error_codes/error_codes

1 file changed

+21
-5
lines changed

src/librustc_error_codes/error_codes/E0050.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
This error indicates that an attempted implementation of a trait method
2-
has the wrong number of function parameters.
1+
An attempted implementation of a trait method has the wrong number of function
2+
parameters.
33

4-
For example, the trait below has a method `foo` with two function parameters
5-
(`&self` and `u8`), but the implementation of `foo` for the type `Bar` omits
6-
the `u8` parameter:
4+
Erroneous code example:
75

86
```compile_fail,E0050
97
trait Foo {
@@ -18,3 +16,21 @@ impl Foo for Bar {
1816
fn foo(&self) -> bool { true }
1917
}
2018
```
19+
20+
For example, the `Foo` trait has a method `foo` with two function parameters
21+
(`&self` and `u8`), but the implementation of `foo` for the type `Bar` omits
22+
the `u8` parameter. To fix this error, they must have the same parameters:
23+
24+
```
25+
trait Foo {
26+
fn foo(&self, x: u8) -> bool;
27+
}
28+
29+
struct Bar;
30+
31+
impl Foo for Bar {
32+
fn foo(&self, x: u8) -> bool { // ok!
33+
true
34+
}
35+
}
36+
```

0 commit comments

Comments
 (0)