diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-01-09 22:25:58 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-01-09 22:25:58 +0100 |
| commit | f79ba857dd1271ea8d5207121c2487621ebc23dd (patch) | |
| tree | 5871f7fd2c829c3bcc6bf8ab5b16d79015337b0e /src/librustc_error_codes | |
| parent | ee84c30aee06a004b8d8f8d24000351e9d1cb4bf (diff) | |
| download | rust-f79ba857dd1271ea8d5207121c2487621ebc23dd.tar.gz rust-f79ba857dd1271ea8d5207121c2487621ebc23dd.zip | |
clean up E0185 explanation
Diffstat (limited to 'src/librustc_error_codes')
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0185.md | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/librustc_error_codes/error_codes/E0185.md b/src/librustc_error_codes/error_codes/E0185.md index f0ad2af144a..ea29e2d4516 100644 --- a/src/librustc_error_codes/error_codes/E0185.md +++ b/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 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! +} +``` |
