S0039: copy type contains non-copy field
Generated from rellum-diagnostics/src/db.rs.
Explanation
A record declared copy must be duplicable without transferring ownership. If any field is a Move type, such as String, Bytes, arrays, or a non-copy user-defined type, the record cannot be copied by value.
Common causes
- declaring
copyon a record that contains String, Bytes, or an array - declaring
copyon a record that contains another Move record or enum - adding a Move field to an existing copy record
Canonical fixes
- remove copy from the type declaration
Before:
type Packet = copy { payload: String }
After:
type Packet = { payload: String }
- change the field to a Copy representation
Before:
type Packet = copy { payload: String }
After:
type Packet = copy { code: Int }
Code example
type Packet = copy { payload: String }