Rollup merge of #68365 - GuillaumeGomez:clean-up-err-codes-2, r=Dylan-DPC
Clean up error codes r? @Dylan-DPC
This commit is contained in:
commit
0259c10385
2 changed files with 13 additions and 10 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue