Rust

E0204 Copy Trait Field Fix

You mark a struct Copy — by derive or by writing the implementation yourself — and the compiler refuses, naming one of its fields. E0204 means Copy was claimed for a type that cannot be duplicated by a plain bitwise copy, because at least one field inside it is not Copy: a String or Vec owns heap memory, and a &mut reference must stay unique. The diagnostic names the field, and the repair is a decision about that field — stop claiming Copy, change what the field holds, or change the field's type until every field is Copy and the claim becomes true.

Written November 26, 2026 · Tested with Rust 1.99.1 · 11 min read

By the end of this guide
  • The error: Copy claimed for a type holding a Vec
  • The fix: drop Copy, keep Clone
  • The fix: change the field to a Copy type
  • The fix: make every field Copy, then implement Copy

Written November 26, 2026

Tested with Rust 1.99.1

What this guide is

Copy is a promise about how a value duplicates: assigning it, passing it, or returning it copies the bits and leaves the original fully usable, with no allocation and no cleanup shared between the two. A type can only keep that promise if every part of it can — which is why the compiler checks the claim field by field. The error codes index states the rule in one line: the Copy trait was implemented on a type which contains a field that doesn't implement the Copy trait. The standard library documentation puts the same point from the other side: Copy types are duplicated simply by copying bits, and types that own resources — a String's heap buffer, a Vec's allocation — cannot be duplicated that way, because two owners of one buffer would free it twice.

E0204 is the report for a broken claim, and it fires at the claim, not at a use. It makes no difference whether Copy arrives through #[derive(Copy)] or through a hand-written Copy implementation: both are checked the same way, and both are shown below. The diagnostic also names the exact field that fails, which makes the three repairs a short list. Drop the Copy claim and duplicate explicitly with Clone instead. Change the field to a type that is Copy, when the data allows it. Or change the field's contents until every field is Copy, and only then make the claim. Which one is right depends on what the field holds and why Copy was wanted — the sections below take them in that order.

The error: Copy claimed for a type holding a Vec

This is the error index's own example shape: a struct with a Vec<u32> field and a manual Copy implementation:

Rust
struct Foo {
    foo: Vec<u32>,
}

impl Copy for Foo { }

fn main() {
    let f = Foo { foo: vec![1, 2, 3] };
    println!("{}", f.foo.len());
}
Terminal
$ rustc --edition 2021 official.rs -o official.bin
error[E0204]: the trait `Copy` cannot be implemented for this type
 --> official.rs:5:15
  |
2 |     foo: Vec<u32>,
  |     ------------- this field does not implement `Copy`
...
5 | impl Copy for Foo { }
  |               ^^^

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0204`.

The report has two carets doing two jobs. The underline on the field line names the reason — Vec<u32> does not implement Copy, because copying a Vec's bits would copy the pointer to one heap allocation and hand it to two owners. The caret on the implementation line names the claim being rejected. Nothing in main is at fault; the program would fail identically if main never used the value, because the claim itself is what cannot stand.

The derive form of the same mistake reports the same code, with the derive line marked as the expansion site. Here the non-Copy field is a String:

Rust
#[derive(Copy, Clone)]
struct Label {
    name: String,
}

fn main() {
    let a = Label { name: String::from("alpha") };
    let b = a;
    println!("{} {}", a.name, b.name);
}
Terminal
$ rustc --edition 2021 broken.rs -o broken.bin
error[E0204]: the trait `Copy` cannot be implemented for this type
 --> broken.rs:2:8
  |
1 | #[derive(Copy, Clone)]
  |          ---- in this derive macro expansion
2 | struct Label {
  |        ^^^^^
3 |     name: String,
  |     ------------ this field does not implement `Copy`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0204`.

Same structure: the field is named, the claim is rejected, and the intended use in main — assign a to b and keep using both — is exactly the use Copy would have allowed and exactly the use that is unsafe for an owning field. Every fix below is a way of making that use honest: pay for a real duplication, hold data that can be bit-copied, or reshape the field until it can.

The fix: drop Copy, keep Clone

When the field genuinely owns data — the Vec holds elements the program built, the String holds text it owns — the type is not Copy and the correct repair is to stop claiming it is. Clone stays: duplication is still available, it is just explicit, because it allocates. Removing the Copy implementation line and deriving Clone is the whole change to the type:

Rust
#[derive(Clone)]
struct Foo {
    foo: Vec<u32>,
}

fn main() {
    let a = Foo { foo: vec![1, 2, 3] };
    let b = a.clone();
    println!("{} {}", a.foo.len(), b.foo[2]);
}
Terminal
$ rustc --edition 2021 fixed_clone_vec.rs -o fixed_clone_vec.bin
$ ./fixed_clone_vec.bin
3 3

The cost of this fix is a change in assignment semantics, and it is worth seeing once, because it is the mistake that follows this fix most often. Without Copy, a plain assignment moves the value. Keeping let b = a; and then using a afterward — the shape the broken program wanted — fails with E0382, borrow of moved value:

Rust
#[derive(Clone)]
struct Label {
    name: String,
}

fn main() {
    let a = Label { name: String::from("alpha") };
    let b = a;
    println!("{} {}", a.name, b.name);
}
Terminal
$ rustc --edition 2021 probe_move.rs -o probe_move.bin
error[E0382]: borrow of moved value: `a`
 --> probe_move.rs:9:23
  |
7 |     let a = Label { name: String::from("alpha") };
  |         - move occurs because `a` has type `Label`, which does not implement the `Copy` trait
8 |     let b = a;
  |             - value moved here
9 |     println!("{} {}", a.name, b.name);
  |                       ^^^^^^ value borrowed here after move
  |
help: consider cloning the value if the performance cost is acceptable
  |
8 |     let b = a.clone();
  |              ++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0382`.

That is not a new problem introduced by the fix; it is the compiler stating the semantics the type always had. The String version with the clone written in compiles and runs the way the original program intended:

Rust
#[derive(Clone)]
struct Label {
    name: String,
}

fn main() {
    let a = Label { name: String::from("alpha") };
    let b = a.clone();
    println!("{} {}", a.name, b.name);
}
Terminal
$ rustc --edition 2021 fixed_clone.rs -o fixed_clone.bin
$ ./fixed_clone.bin
alpha alpha

The fix: change the field to a Copy type

Sometimes the owning field is stronger than the data needs. If the text a String field holds is always a literal known at compile time, the field does not need to own it: a &'static str is a pointer and a length, it is Copy, and with the field changed the derive the compiler rejected now succeeds unchanged:

Rust
#[derive(Copy, Clone)]
struct Label {
    name: &'static str,
}

fn main() {
    let a = Label { name: "alpha" };
    let b = a;
    println!("{} {}", a.name, b.name);
}
Terminal
$ rustc --edition 2021 fixed_static_str.rs -o fixed_static_str.bin
$ ./fixed_static_str.bin
alpha alpha

Note what this fix trades. The assignment let b = a; is a real copy again and both values stay usable — that is the behavior the original program wanted. But the field can now only hold text that lives for the whole program, and the struct borrows rather than owns its text. The same shape applies to other over-strong fields: an identifier stored as a String that is really a fixed set of codes, a path stored owned that is really one of a few constants. Where the data is genuinely built at runtime and varies, this fix does not apply — that is the Clone fix above, or the reshape below.

The fix: make every field Copy, then implement Copy

The third repair keeps Copy and changes what the field holds until the claim is true. A Vec<u32> is not Copy, but a fixed-size array of u32 is: its contents have a known size, live inside the struct, and own nothing on the heap. Swapping the field type is the only change the data needs; after it, the manual Copy implementation that E0204 rejected compiles as written:

Rust
#[derive(Clone)]
struct Foo {
    foo: [u32; 3],
}

impl Copy for Foo { }

fn main() {
    let a = Foo { foo: [1, 2, 3] };
    let b = a;
    println!("{} {}", a.foo[0], b.foo[2]);
}
Terminal
$ rustc --edition 2021 fixed_manual.rs -o fixed_manual.bin
$ ./fixed_manual.bin
1 3

Two details in this version are load-bearing. The #[derive(Clone)] stays, because Copy requires Clone as a supertrait — a Copy claim without Clone anywhere in the program fails separately, with E0277, the trait bound Clone is not satisfied, and the compiler's help for that error is to add the Clone derive. And the array's length is part of its type: [u32; 3] is Copy, and so is any other fixed length, but the field can never hold a fourth element. This fix fits data whose size is fixed by the problem — coordinates, a fixed set of channels, a day's fixed readings. Data that grows belongs in the Vec, and that type takes the Clone fix instead.

One more field type belongs in this section because it surprises people: a mutable reference. The error index's second example derives Copy on a struct holding a &'a mut bool, and it fails with E0204 — &mut T is not Copy even when T is, because copying a mutable reference would create two exclusive references to the same value. The same program also draws E0277, since &mut bool is not Clone either. A shared reference &T is always Copy; the mutable one never is, and no reshape of the struct changes that — the repair is to restructure so the mutable borrow is not stored in a Copy type at all.

Which fix for which cause

Cause Message Fix
Field owns heap data the program builds, such as a String or a Vec E0204, the field named as not implementing Copy Drop Copy, keep Clone, and write .clone() where a second value is needed
Field is stronger than the data needs, such as owned text that is always a literal E0204, the field named as not implementing Copy Change the field to a Copy type that fits the data, such as &'static str, and keep the derive
Field's contents have a fixed size known at compile time E0204, the field named as not implementing Copy Change the field to a fixed-size Copy form, such as [u32; 3], so every field is Copy, then derive or implement Copy
Field is a &mut reference E0204, plus E0277 for the Clone derive Do not store a mutable reference in a Copy type; restructure so the borrow is not a field of the copied value
Every field is Copy but Clone was never derived or implemented E0277, the trait bound Clone is not satisfied Add #[derive(Clone)] or a Clone implementation — Copy requires Clone as a supertrait
Copy removed, but code still uses a value after assigning it E0382, borrow of moved value Write .clone() at the assignment, or restructure so the original is not used after the move

Checklist

  • Read the field the diagnostic names before changing anything. E0204 always identifies the non-Copy field; that field, not the struct as a whole, is what each fix operates on.
  • Decide whether the type should duplicate silently at all. A type that owns heap data is telling you duplication has a cost; making that cost explicit with Clone is a correct outcome, not a workaround.
  • Check whether the field is stronger than its data. Owned text that is always a literal, and collections whose size the problem fixes, can become Copy types — &'static str, fixed-size arrays, plain numbers — and then the Copy claim stands.
  • Keep Clone wherever Copy is claimed. Copy is a subtrait of Clone; a Copy derive or implementation with no Clone in sight fails with E0277 before the field check is even the question.
  • Never store a &mut reference in a type that needs to be Copy. Shared references are Copy; mutable references are not, by design, and the fix is structural.
  • After removing Copy, search the code for uses after assignment. Every place that relied on copy semantics now moves, and each one surfaces as E0204's neighbor E0382 until the clone — or a borrow — is written in.
  • E0382 Borrow of Moved Value Fix — the error that follows when Copy is removed and a value is used after being moved, including where that guide contrasts the move error with this guide's E0204 field report.
  • E0277 Trait Bound Not Satisfied Fix — the general trait-bound error, which is also the report when Copy is claimed without Clone, since Copy requires Clone as a supertrait.
  • E0046 Missing Trait Items Fix — the neighboring trait-implementation error for a manual implementation that leaves out items the trait requires, where this guide covers an implementation rejected because of a field's type.

Sources

  • Rust Compiler Error Index, E0204 — for the Copy trait being implemented on a type which contains a field that doesn't implement the Copy trait, for the Vec<u32> field with a manual Copy implementation example, and for &mut T not being Copy even when T is.
  • The Rust Standard Library, Copy trait — for types whose values can be duplicated simply by copying bits, for move semantics as the default, and for Clone being required as a supertrait of Copy.
  • The Rust Programming Language, What is Ownership? — for stack-only data and the Copy behavior of types with a known size at compile time, stored entirely on the stack, whose copies are quick to make.

Keep Exploring