Rollup merge of #68005 - GuillaumeGomez:explanation-e0184, r=Dylan-DPC

Improve E0184 explanation

r? @Dylan-DPC
This commit is contained in:
Mazdak Farrokhzad 2020-01-09 00:22:16 +01:00 committed by GitHub
commit 91d5fbaeb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 4 deletions

View File

@ -1,6 +1,20 @@
Explicitly implementing both Drop and Copy for a type is currently disallowed.
This feature can make some sense in theory, but the current implementation is
incorrect and can lead to memory unsafety (see [issue #20126][iss20126]), so
it has been disabled for now.
The `Copy` trait was implemented on a type with a `Drop` implementation.
Erroneous code example:
```compile_fail,E0184
#[derive(Copy)]
struct Foo; // error!
impl Drop for Foo {
fn drop(&mut self) {
}
}
```
Explicitly implementing both `Drop` and `Copy` trait on a type is currently
disallowed. This feature can make some sense in theory, but the current
implementation is incorrect and can lead to memory unsafety (see
[issue #20126][iss20126]), so it has been disabled for now.
[iss20126]: https://github.com/rust-lang/rust/issues/20126