File tree Expand file tree Collapse file tree 2 files changed +13
-10
lines changed
src/librustc_error_codes/error_codes Expand file tree Collapse file tree 2 files changed +13
-10
lines changed Original file line number Diff line number Diff line change 1- It is an error to define two associated items (like methods, associated types,
2- associated functions, etc.) with the same identifier.
1+ Two associated items (like methods, associated types, associated functions ,
2+ etc.) were defined with the same identifier.
33
4- For example:
4+ Erroneous code example:
55
66``` compile_fail,E0201
77struct Foo(u8);
Original file line number Diff line number Diff line change 1- An attempt to implement the ` Copy ` trait for a struct failed because one of the
2- fields does not implement ` Copy ` . To fix this, you must implement ` Copy ` for the
3- mentioned field. Note that this may not be possible, as in the example of
1+ The ` Copy ` trait was implemented on a type which contains a field that doesn't
2+ implement the ` Copy ` trait.
3+
4+ Erroneous code example:
45
56``` compile_fail,E0204
67struct Foo {
7- foo : Vec<u32>,
8+ foo: Vec<u32>,
89}
910
10- impl Copy for Foo { }
11+ impl Copy for Foo { } // error!
1112```
1213
13- This fails because ` Vec<T> ` does not implement ` Copy ` for any ` T ` .
14+ The ` Copy ` trait is implemented by default only on primitive types. If your
15+ type only contains primitive types, you'll be able to implement ` Copy ` on it.
16+ Otherwise, it won't be possible.
1417
1518Here's another example that will fail:
1619
1720``` compile_fail,E0204
18- #[derive(Copy)]
21+ #[derive(Copy)] // error!
1922struct Foo<'a> {
2023 ty: &'a mut bool,
2124}
You can’t perform that action at this time.
0 commit comments