]> git.proxmox.com Git - rustc.git/blame - src/librustc_error_codes/error_codes/E0050.md
New upstream version 1.47.0+dfsg1
[rustc.git] / src / librustc_error_codes / error_codes / E0050.md
CommitLineData
60c5eb7d
XL
1An attempted implementation of a trait method has the wrong number of function
2parameters.
3
4Erroneous code example:
5
6```compile_fail,E0050
7trait Foo {
8 fn foo(&self, x: u8) -> bool;
9}
10
11struct Bar;
12
13// error: method `foo` has 1 parameter but the declaration in trait `Foo::foo`
14// has 2
15impl Foo for Bar {
16 fn foo(&self) -> bool { true }
17}
18```
19
20For 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
22the `u8` parameter. To fix this error, they must have the same parameters:
23
24```
25trait Foo {
26 fn foo(&self, x: u8) -> bool;
27}
28
29struct Bar;
30
31impl Foo for Bar {
32 fn foo(&self, x: u8) -> bool { // ok!
33 true
34 }
35}
36```