E0184 Copy on Type With Drop Fix
Written December 3, 2026 · Tested with Rust 1.99.0 · 15 min read
- The rule underneath: a copied value would run its destructor twice over
- How to read the diagnostic
- The first failure: the index example
- The same error in the other shapes
Written December 3, 2026
Tested with Rust 1.99.0
What this guide is
Error E0184 means the Copy trait was implemented on a type that has a destructor - in the index's words, the Copy trait was implemented on a type with a Drop implementation. The error codes index example derives Copy on a unit struct, Foo, that also implements Drop explicitly, and the index states that explicitly implementing both Drop and Copy on a type is currently disallowed.
In the shapes probed in this guide, the index example verbatim drew exactly one E0184 and no other code - this premise is clean, with no ride-along to separate. The count follows the bad types, in the probed shape: two Copy types with Drop implementations in one program drew exactly two E0184 reports, one per type. The conflict is not specific to the derive: a manual impl Copy (with a manual Clone, as Copy requires) drew exactly one E0184 in the probed shape, and so did a Copy enum, a Copy tuple struct, and a generic Copy struct, each with its own Drop implementation. The near neighbors land elsewhere, in the probed shapes: deriving Copy on a type holding a String field drew exactly one E0204, because that field does not implement Copy, and a manual impl Copy with no Clone implementation drew exactly one E0277, because Clone is a supertrait of Copy. An unresolved name elsewhere in the program did not hide this error in the probed shape: it was reported alongside, one E0184 and one E0425. Neither half of the pair is banned on its own: Copy without Drop compiled and ran, Drop without Copy compiled and ran, and Clone together with Drop compiled and ran, in the probed shapes. This guide shows the E0184 shapes, the neighboring shapes, the boundary, and the repairs.
Build every program in this guide with rustc --edition 2021. In the compiler transcripts, the file names are the bare names shown on the command line.
The rule underneath: a copied value would run its destructor twice over
Copy says a value can be duplicated by copying its bits, implicitly, on assignment or passing - the Copy documentation describes types whose values can be duplicated simply by copying bits, with Clone as a supertrait of Copy. A bitwise duplicate shares whatever the original owned: if the type also has a destructor, both copies would try to clean up the same resource when they go out of scope. The index gives the reason the combination is disabled: explicitly implementing both Drop and Copy can make sense in theory, but the current implementation is incorrect and can lead to memory unsafety, so it has been disabled for now.
That is why every repair gives up one half of the pair. Either the type keeps its destructor and duplicates explicitly with Clone - the explicit action the Copy documentation contrasts with implicit copying - or it keeps Copy and gives up the explicit Drop implementation, or values of the type are moved, the default semantics, instead of duplicated at all.
How to read the diagnostic
The E0184 header names the conflict: "the trait Copy cannot be implemented for this type; the type has a destructor". The report carries two spans: the type itself, labeled "Copy not allowed on types with destructors" and noting the derive macro expansion when the implementation was derived, and a note span, "destructor declared here", pointing at the Drop implementation. There is no suggested fix in the report; choosing which half to keep is the repair decision below.
The count follows the bad types, in the probed shape - one report per type that carries both halves. Two such types in one program drew two reports, ending with "aborting due to 2 previous errors":
error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor
--> fail_two_types.rs:2:8
|
1 | #[derive(Copy, Clone)]
| ---- in this derive macro expansion
2 | struct A;
| ^ `Copy` not allowed on types with destructors
|
note: destructor declared here
--> fail_two_types.rs:3:19
|
3 | impl Drop for A { fn drop(&mut self) {} }
| ^^^^^^^^^^^^^^^^^^
error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor
--> fail_two_types.rs:5:8
|
4 | #[derive(Copy, Clone)]
| ---- in this derive macro expansion
5 | struct B;
| ^ `Copy` not allowed on types with destructors
|
note: destructor declared here
--> fail_two_types.rs:6:19
|
6 | impl Drop for B { fn drop(&mut self) {} }
| ^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0184`.
Fix every Copy-with-destructor type in the output before recompiling; a second one is already reported, not hidden behind the first.
The first failure: the index example
The index's erroneous example, verbatim - the struct derives Copy and implements Drop:
#![allow(unused)]
fn main() {
#[derive(Copy)]
struct Foo; // error!
impl Drop for Foo {
fn drop(&mut self) {
}
}
}
error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor
--> fail_index.rs:4:8
|
3 | #[derive(Copy)]
| ---- in this derive macro expansion
4 | struct Foo; // error!
| ^^^ `Copy` not allowed on types with destructors
|
note: destructor declared here
--> fail_index.rs:7:5
|
7 | fn drop(&mut self) {
| ^^^^^^^^^^^^^^^^^^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0184`.
Exactly one report, and it is the whole story: no second code rides along in this example. The separation checks confirm the pair is the only defect. Copy alone is not the problem: a Copy struct with no Drop implementation compiled and ran in the probed shape, shown in the boundary section below. And Drop alone is not the problem either: a struct implementing only Drop compiled and ran in the same section.
The same error in the other shapes
The ban follows the combination, not the derive. A manual implementation draws the same code as a derived one, in the probed shape - a manual impl Copy alongside a manual impl Clone and a Drop implementation drew exactly one E0184 in the file fail_manual_copy.rs. The remaining type shapes agree, in the probed shapes: an enum deriving Copy and Clone with a Drop implementation drew exactly one E0184 in the file fail_enum_copy_drop.rs, a tuple struct did the same in the file fail_tuple_struct_copy_drop.rs, and a generic struct Wrap<T> did the same in the file fail_generic_copy_drop.rs. Unit, tuple, enum, and generic types all draw this one code when both halves are present.
One co-report belongs here. A program that carried the index pair and an unresolved name in main reported both - exactly one E0184 and one E0425, in the file ride_unresolved.rs:
error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor
--> ride_unresolved.rs:2:8
|
1 | #[derive(Copy)]
| ---- in this derive macro expansion
2 | struct Foo;
| ^^^ `Copy` not allowed on types with destructors
|
note: destructor declared here
--> ride_unresolved.rs:3:21
|
3 | impl Drop for Foo { fn drop(&mut self) {} }
| ^^^^^^^^^^^^^^^^^^
error[E0425]: cannot find function `missing_name` in this scope
--> ride_unresolved.rs:4:13
|
4 | fn main() { missing_name(); }
| ^^^^^^^^^^^^ not found in this scope
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0184, E0425.
For more information about an error, try `rustc --explain E0184`.
Read the pair as two separate defects, not one defect stated twice: the name error does not mask the Copy error in this shape, and fixing either one leaves the other standing.
The shapes that are not this error
Changing which half is wrong changes the code. Deriving Copy on a type whose field does not implement Copy - a String field - drew exactly one E0204 and no E0184 in the probed shape:
error[E0204]: the trait `Copy` cannot be implemented for this type
--> fail_noncopy_field.rs:2:8
|
1 | #[derive(Copy, Clone)]
| ---- in this derive macro expansion
2 | struct Bar { s: String }
| ^^^ --------- this field does not implement `Copy`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0204`.
The E0204 report points at the field, not at a destructor: there is no Drop implementation in that program at all. Read the header and the spans to tell them apart: E0184 names a destructor and points at the Drop implementation; E0204 names the field that does not implement Copy.
Forgetting the other supertrait requirement lands in a third place. A manual impl Copy with no Clone implementation anywhere drew exactly one E0277 in the probed shape:
error[E0277]: the trait bound `Foo: Clone` is not satisfied
--> fail_copy_without_clone.rs:2:15
|
2 | impl Copy for Foo {}
| ^^^ the trait `Clone` is not implemented for `Foo`
|
note: required by a bound in `Copy`
--> /rustc/b940084d7eb6a299eb4bfeb8e34901bc051e7ac4/library/core/src/marker.rs:454:0
help: consider annotating `Foo` with `#[derive(Clone)]`
|
1 + #[derive(Clone)]
2 | struct Foo;
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.
That report is about the missing Clone implementation - Clone is a supertrait of Copy, so a type that is Copy must also implement Clone. It fires before any destructor question arises, and the program that drew it has no Drop implementation either. None of these shapes drew E0184: each fails at a different part of the Copy rules.
The boundary: each half alone, and Clone with Drop
The line is the combination. On the other side of it, each half is ordinary code. A Copy struct with no destructor compiled and ran in the probed shape, printing 2 4 - the assignment copied the value, and both bindings stayed usable:
#[derive(Copy, Clone, Debug)]
struct Point { x: i32, y: i32 }
fn main() {
let a = Point { x: 1, y: 2 };
let b = a;
println!("{} {}", a.x + b.x, a.y + b.y);
}
2 4
A struct implementing only Drop compiled and ran in the probed shape, printing alive and then dropped, in the file boundary_drop_no_copy.rs - the destructor ran once, when the value went out of scope. And Clone does not conflict with a destructor at all: a Clone struct with a Drop implementation compiled and ran, printing 7 7, in the file boundary_clone_with_drop.rs. Explicit duplication and cleanup coexist; implicit bitwise duplication and cleanup do not.
Related guides
For a Copy implementation blocked by a field that does not implement Copy, the neighboring code is E0204. For a Copy implementation missing its required Clone supertrait, the code is E0277. For an unresolved name reported alongside a Copy error, the code is E0425.
The repairs
Every repair below starts from the same observation: the type may keep its destructor or it may keep implicit copying, but not both. What changes for callers is how values are duplicated afterward - explicitly with clone(), implicitly by assignment, or not at all.
Keep Drop, and clone instead of copying. This is the repair when the destructor does real cleanup: remove Copy, derive or implement Clone instead, and duplicate with an explicit clone() call:
#[derive(Clone, Debug)]
struct Foo { n: i32 }
impl Drop for Foo { fn drop(&mut self) { println!("drop {}", self.n); } }
fn main() { let a = Foo { n: 5 }; let b = a.clone(); println!("{} {}", a.n, b.n); }
5 5
drop 5
drop 5
Both values print, and each runs the destructor when it goes out of scope - the two drop 5 lines are the two values being cleaned up, in the probed shape.
Keep Copy, and remove the Drop implementation. This is the repair when the destructor was not needed - the type is plain data whose fields clean up after themselves:
#[derive(Copy, Clone, Debug)]
struct Foo { n: i32 }
fn main() { let a = Foo { n: 5 }; let b = a; println!("{} {}", a.n, b.n); }
5 5
The assignment copies the value and both bindings stay usable, exactly as in the boundary shape. If a field genuinely owns a resource, this is the wrong repair - keep the destructor and use the first one instead.
Move the value instead of duplicating it. Where only one owner is ever needed, neither trait is required: the value moves into its new owner and the destructor runs once, there:
struct Foo { n: i32 }
impl Drop for Foo { fn drop(&mut self) { println!("drop {}", self.n); } }
fn take(f: Foo) { println!("took {}", f.n); }
fn main() { let a = Foo { n: 9 }; take(a); }
took 9
drop 9
The function takes the value, prints it, and the destructor runs when that owned value goes out of scope at the end of the call.
Callers change with the repair choice in one visible way: the clone repair changes duplication sites - assignments that used to copy now need an explicit clone() call - while the remove-Drop repair changes cleanup, and the move repair changes ownership, so a moved-from binding can no longer be used afterward.
Fixes in reach order
First, read the header. "The trait Copy cannot be implemented for this type; the type has a destructor" is E0184, the Copy-plus-Drop combination. A report naming a field that does not implement Copy is E0204, and a report that Clone is not implemented for the type is E0277 - each is repaired where it is written.
Second, decide which half the type actually needs. If the Drop implementation cleans up a real resource, it stays and Copy goes - that clears every E0184 on that type at once.
Third, if values of the type still need duplicating after Copy is removed, derive or implement Clone and call clone() at the duplication sites. Clone carries no conflict with a destructor, in the probed shape.
Fourth, if the destructor was not needed, remove the Drop implementation and keep Copy - or, if only one owner is ever needed, drop both traits and let values move.
Fifth, if the output carries a second code, separate it before judging the program: an E0425 for an unresolved name is a second, independent defect reported alongside the E0184, and both must be fixed before the program compiles.
Decision summary
E0184 fired in the probed shapes for the index example verbatim (exactly one E0184, no other code), for two Copy-with-Drop types in one program (exactly two, one per type), for a manual Copy implementation with a manual Clone (exactly one), and for an enum, a tuple struct, and a generic struct each carrying both halves (exactly one each). It was reported alongside another code in one probed shape: an unresolved name in the same program drew one E0425 next to the one E0184, neither masking the other. It did not fire, in the probed shapes, for Copy without Drop (compiled and ran, printing 2 4), for Drop without Copy (compiled and ran, printing alive and dropped), or for Clone with Drop (compiled and ran, printing 7 7). The neighboring shapes drew other reports instead in the probed shapes: a Copy derive on a type holding a String field drew exactly one E0204, and a manual Copy implementation without Clone drew exactly one E0277. The repairs that compiled and ran in the probed shapes were keeping Drop and cloning instead of copying (printing 5 5, then drop 5, then drop 5), keeping Copy and removing Drop (printing 5 5), and moving the value instead of copying it (printing took 9 and drop 9).
Checklist
- The test is the combination, in the probed shapes: E0184 is
Copyon a type that also has a destructor - a non-Copyfield is E0204, and a missingCloneimplementation is E0277. - The count is per bad type, in the probed shape: two
Copy-with-Droptypes in one program drew two reports. - The implementation form does not matter, in the probed shapes: derived and manual
Copyimplementations drew the same single E0184, on unit, tuple, enum, and generic types alike. - Neither half is the problem alone, in the probed shapes:
CopywithoutDrop,DropwithoutCopy, andClonewithDropall compiled and ran. - An unresolved name does not mask this error, in the probed shape: E0184 and E0425 were reported together, as two defects.
- One half leaves in every repair, in the probed shapes: cloning with the destructor kept, copying with the destructor removed, and moving with neither trait all compiled and ran.
Sources
- Rust error codes index, E0184 - the
Copytrait was implemented on a type with aDropimplementation; the erroneous example derivesCopyon a unit struct that also implementsDrop, and the entry states that explicitly implementing bothDropandCopyon a type is currently disallowed because the current implementation can lead to memory unsafety. - Rust error codes index, E0204 - the
Copytrait was implemented on a type which contains a field that does not implement theCopytrait; the neighboring code drawn in the probed shape by aCopyderive on a type holding aStringfield. - Rust error codes index, E0277 - a trait bound was not satisfied; the neighboring code drawn in the probed shape by a manual
Copyimplementation with noCloneimplementation,Clonebeing a supertrait ofCopy. - Rust standard library, Copy trait - types whose values can be duplicated simply by copying bits; copies happen implicitly, cloning is an explicit action, and
Cloneis a supertrait ofCopy, so everything which isCopymust also implementClone. - Rust standard library, Drop trait - custom code within the destructor; when a value is no longer needed, Rust runs a destructor on that value, most commonly when it goes out of scope, and types that directly manage a resource use it to clean that resource up.
Keep Exploring
The full Rust hub \u2014 ownership, structs and enums, async, and measured comparisons.
Every guide on the site in one list, grouped by topic.
Every browser-only checker and verifier on the site.
The C++, Python, Sysadmin, Rust, Go, and TypeScript hubs.