diff options
| author | bors <bors@rust-lang.org> | 2020-01-13 08:20:49 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-01-13 08:20:49 +0000 |
| commit | af958046e5855a4254831102b502f57dafa40f69 (patch) | |
| tree | 731b779310aa28b33dc1108624e9d96e60db1c64 /src/librustc_error_codes/error_codes | |
| parent | e82febc78e5a14356de5f713b904eebef1e86956 (diff) | |
| parent | 87bdc8eb73b5dd48f58bca00b307cbca1351b2f9 (diff) | |
| download | rust-af958046e5855a4254831102b502f57dafa40f69.tar.gz rust-af958046e5855a4254831102b502f57dafa40f69.zip | |
Auto merge of #68174 - JohnTitor:rollup-ix4amrj, r=JohnTitor
Rollup of 8 pull requests Successful merges: - #67313 (Document more use cases of dataflow) - #67959 (rustdoc: improve stability mark arrows) - #68097 (Specify units for test timeout environment variables) - #68135 (restore some rustc_parse visibilities for rustfmt) - #68145 (Expose `context::CheckLintNameResult`) - #68156 (Fix crate paths in comments) - #68157 (Clean up E0186 explanation) - #68161 (Fix system call docs for time::Instant) Failed merges: r? @ghost
Diffstat (limited to 'src/librustc_error_codes/error_codes')
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0186.md | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/librustc_error_codes/error_codes/E0186.md b/src/librustc_error_codes/error_codes/E0186.md index 9135d5c1d5e..7db1e843323 100644 --- a/src/librustc_error_codes/error_codes/E0186.md +++ b/src/librustc_error_codes/error_codes/E0186.md @@ -2,7 +2,7 @@ An associated function for a trait was defined to be a method (i.e., to take a `self` parameter), but an implementation of the trait declared the same function to be static. -Here's an example of this error: +Erroneous code example: ```compile_fail,E0186 trait Foo { @@ -17,3 +17,19 @@ impl Foo for Bar { fn foo() {} } ``` + +When a type implements a trait's associated function, it has to use the same +signature. So in this case, since `Foo::foo` takes `self` as argument and +does not return anything, its implementation on `Bar` should be the same: + +``` +trait Foo { + fn foo(&self); +} + +struct Bar; + +impl Foo for Bar { + fn foo(&self) {} // ok! +} +``` |
