File tree 1 file changed +21
-5
lines changed
src/librustc_error_codes/error_codes
1 file changed +21
-5
lines changed Original file line number Diff line number Diff line change 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.
3
3
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:
7
5
8
6
``` compile_fail,E0050
9
7
trait Foo {
@@ -18,3 +16,21 @@ impl Foo for Bar {
18
16
fn foo(&self) -> bool { true }
19
17
}
20
18
```
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
+ ```
You can’t perform that action at this time.
0 commit comments