From f79ba857dd1271ea8d5207121c2487621ebc23dd Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 9 Jan 2020 22:25:58 +0100 Subject: clean up E0185 explanation --- src/librustc_error_codes/error_codes/E0185.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/librustc_error_codes/error_codes') 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! +} +``` -- cgit 1.4.1-3-g733a5