Skip to content

Commit a9aa2df

Browse files
clean up E0204 explanation
1 parent 0c7f40f commit a9aa2df

File tree

1 file changed

+10
-7
lines changed
  • src/librustc_error_codes/error_codes

1 file changed

+10
-7
lines changed

src/librustc_error_codes/error_codes/E0204.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
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
67
struct 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

1518
Here's another example that will fail:
1619

1720
```compile_fail,E0204
18-
#[derive(Copy)]
21+
#[derive(Copy)] // error!
1922
struct Foo<'a> {
2023
ty: &'a mut bool,
2124
}

0 commit comments

Comments
 (0)