From 0c7f40f3b2fb75649ec6ed3970486c34dbf4db3b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 19 Jan 2020 15:35:44 +0100 Subject: [PATCH 1/2] clean up E0201 explanation --- src/librustc_error_codes/error_codes/E0201.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0201.md b/src/librustc_error_codes/error_codes/E0201.md index bdbf02f0033ab..0e1a7b7b7deb1 100644 --- a/src/librustc_error_codes/error_codes/E0201.md +++ b/src/librustc_error_codes/error_codes/E0201.md @@ -1,7 +1,7 @@ -It is an error to define two associated items (like methods, associated types, -associated functions, etc.) with the same identifier. +Two associated items (like methods, associated types, associated functions, +etc.) were defined with the same identifier. -For example: +Erroneous code example: ```compile_fail,E0201 struct Foo(u8); From a9aa2dfe844840a7e414873ce55ef9d02f1038a7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 19 Jan 2020 15:35:55 +0100 Subject: [PATCH 2/2] clean up E0204 explanation --- src/librustc_error_codes/error_codes/E0204.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0204.md b/src/librustc_error_codes/error_codes/E0204.md index 315690111359f..96e44758be4fd 100644 --- a/src/librustc_error_codes/error_codes/E0204.md +++ b/src/librustc_error_codes/error_codes/E0204.md @@ -1,21 +1,24 @@ -An attempt to implement the `Copy` trait for a struct failed because one of the -fields does not implement `Copy`. To fix this, you must implement `Copy` for the -mentioned field. Note that this may not be possible, as in the example of +The `Copy` trait was implemented on a type which contains a field that doesn't +implement the `Copy` trait. + +Erroneous code example: ```compile_fail,E0204 struct Foo { - foo : Vec, + foo: Vec, } -impl Copy for Foo { } +impl Copy for Foo { } // error! ``` -This fails because `Vec` does not implement `Copy` for any `T`. +The `Copy` trait is implemented by default only on primitive types. If your +type only contains primitive types, you'll be able to implement `Copy` on it. +Otherwise, it won't be possible. Here's another example that will fail: ```compile_fail,E0204 -#[derive(Copy)] +#[derive(Copy)] // error! struct Foo<'a> { ty: &'a mut bool, }