-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-repr-packedArea: the naughtiest reprArea: the naughtiest reprD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
#[repr(packed, C)]
#[derive(PartialEq)]
struct Thing(u8, String);Current output
error[E0507]: cannot move out of a shared reference
--> src/lib.rs:3:18
|
2 | #[derive(PartialEq)]
| --------- in this derive macro expansion
3 | struct Thing(u8, String);
| ^^^^^^ move occurs because value has type `String`, which does not implement the `Copy` trait
|
= note: `#[derive(PartialEq)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour
help: consider cloning the value if the performance cost is acceptable
|
3 | struct Thing(u8, String.clone());
| ++++++++
For more information about this error, try `rustc --explain E0507`.Desired output
Don't suggest the cloneRationale and extra context
No response
Other cases
Rust Version
Reproducible on the playground with version 1.95.0-nightly (2026-02-24 859951e3c7c9d0322c39)Anything else?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-repr-packedArea: the naughtiest reprArea: the naughtiest reprD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.