-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee84c30
commit 326994d
Showing
1 changed file
with
18 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |