File tree 2 files changed +13
-10
lines changed
src/librustc_error_codes/error_codes
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.
3
3
4
- For example:
4
+ Erroneous code example:
5
5
6
6
``` compile_fail,E0201
7
7
struct 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:
4
5
5
6
``` compile_fail,E0204
6
7
struct Foo {
7
- foo : Vec<u32>,
8
+ foo: Vec<u32>,
8
9
}
9
10
10
- impl Copy for Foo { }
11
+ impl Copy for Foo { } // error!
11
12
```
12
13
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.
14
17
15
18
Here's another example that will fail:
16
19
17
20
``` compile_fail,E0204
18
- #[derive(Copy)]
21
+ #[derive(Copy)] // error!
19
22
struct Foo<'a> {
20
23
ty: &'a mut bool,
21
24
}
You can’t perform that action at this time.
0 commit comments