Skip to content

Commit

Permalink
Rollup merge of rust-lang#68070 - GuillaumeGomez:clean-up-e0185, r=Dy…
Browse files Browse the repository at this point in the history
…lan-DPC

clean up E0185 explanation

r? @Dylan-DPC
  • Loading branch information
Centril authored Jan 11, 2020
2 parents 82e6a6b + 4fadb50 commit c47118c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/librustc_error_codes/error_codes/E0185.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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` does not take any argument and
does not return anything, its implementation on `Bar` should be the same:

```
trait Foo {
fn foo();
}
struct Bar;
impl Foo for Bar {
fn foo() {} // ok!
}
```

0 comments on commit c47118c

Please sign in to comment.