From f79ba857dd1271ea8d5207121c2487621ebc23dd Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 9 Jan 2020 22:25:58 +0100 Subject: [PATCH 1/3] clean up E0185 explanation --- src/librustc_error_codes/error_codes/E0185.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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! +} +``` From c899f676733c8b7a732294ca7484c64ae3d6dddf Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 10 Jan 2020 10:05:49 +0100 Subject: [PATCH 2/3] Improve E0185 wording --- src/librustc_error_codes/error_codes/E0185.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0185.md b/src/librustc_error_codes/error_codes/E0185.md index ea29e2d4516..ac5d8bd766f 100644 --- a/src/librustc_error_codes/error_codes/E0185.md +++ b/src/librustc_error_codes/error_codes/E0185.md @@ -19,8 +19,8 @@ impl Foo for Bar { ``` 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: +signature. So in this case, since `Foo::foo` doesn't take any argument and +doesn't return anything, its implementation on `Bar` should be the same: ``` trait Foo { From 4fadb507f48a0f959518bbf9b7d0969a159d76f1 Mon Sep 17 00:00:00 2001 From: Dylan DPC Date: Fri, 10 Jan 2020 23:56:00 +0530 Subject: [PATCH 3/3] Update E0185.md --- src/librustc_error_codes/error_codes/E0185.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0185.md b/src/librustc_error_codes/error_codes/E0185.md index ac5d8bd766f..944a93ed14e 100644 --- a/src/librustc_error_codes/error_codes/E0185.md +++ b/src/librustc_error_codes/error_codes/E0185.md @@ -19,8 +19,8 @@ impl Foo for Bar { ``` 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 any argument and -doesn't return anything, its implementation on `Bar` should be 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 {