clean up E0185 explanation

This commit is contained in:
Guillaume Gomez 2020-01-09 22:25:58 +01:00
parent ee84c30aee
commit f79ba857dd

View file

@ -2,7 +2,7 @@ An associated function for a trait was defined to be static, but an
implementation of the trait declared the same function to be a method (i.e., to
take a `self` parameter).
Here's an example of this error:
Erroneous code example:
```compile_fail,E0185
trait Foo {
@ -17,3 +17,19 @@ impl Foo for Bar {
fn foo(&self) {}
}
```
When a type implements a trait's associated function, it has to use the same
signature. So in this case, since `Foo::foo` doesn't take argument and doesn't
return anything, its implementation on `Bar` should the same:
```
trait Foo {
fn foo();
}
struct Bar;
impl Foo for Bar {
fn foo() {} // ok!
}
```