We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 71a719c + 4fadb50 commit b2027dfCopy full SHA for b2027df
src/librustc_error_codes/error_codes/E0185.md
@@ -2,7 +2,7 @@ An associated function for a trait was defined to be static, but an
2
implementation of the trait declared the same function to be a method (i.e., to
3
take a `self` parameter).
4
5
-Here's an example of this error:
+Erroneous code example:
6
7
```compile_fail,E0185
8
trait Foo {
@@ -17,3 +17,19 @@ impl Foo for Bar {
17
fn foo(&self) {}
18
}
19
```
20
+
21
+When a type implements a trait's associated function, it has to use the same
22
+signature. So in this case, since `Foo::foo` does not take any argument and
23
+does not return anything, its implementation on `Bar` should be the same:
24
25
+```
26
+trait Foo {
27
+ fn foo();
28
+}
29
30
+struct Bar;
31
32
+impl Foo for Bar {
33
+ fn foo() {} // ok!
34
35
0 commit comments