diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-01-19 15:35:55 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-01-19 15:35:55 +0100 |
| commit | a9aa2dfe844840a7e414873ce55ef9d02f1038a7 (patch) | |
| tree | 2274bc7c3c41a2c863e529f1c3602c149655d741 /src | |
| parent | 0c7f40f3b2fb75649ec6ed3970486c34dbf4db3b (diff) | |
| download | rust-a9aa2dfe844840a7e414873ce55ef9d02f1038a7.tar.gz rust-a9aa2dfe844840a7e414873ce55ef9d02f1038a7.zip | |
clean up E0204 explanation
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0204.md | 17 |
1 files 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 31569011135..96e44758be4 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<u32>, + foo: Vec<u32>, } -impl Copy for Foo { } +impl Copy for Foo { } // error! ``` -This fails because `Vec<T>` 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, } |
