Closed

Description
I tried this code:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=7d186291bfe30222d01ed0af2fa28c4c
use serde::{Serialize, Deserialize};
#[repr(C)]
#[repr(packed)]
#[derive(Copy, Clone, Serialize, Deserialize, PartialEq, Debug)]
struct Packed {
a: u8,
b: u16,
c: u8
}
fn main() {}
I expected to see this happen: Compile without any warning or error.
Instead, this happened: The following warning was emitted:
Compiling playground v0.0.1 (/playground)
warning: `#[derive]` can't be used on a `#[repr(packed)]` struct that does not derive Copy (error E0133)
--> src/main.rs:8:23
|
8 | #[derive(Copy, Clone, Serialize, Deserialize, PartialEq, Debug)]
| ^^^^^^^^^
|
= note: `#[warn(safe_packed_borrows)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043>
= note: this warning originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
Finished dev [unoptimized + debuginfo] target(s) in 0.65s
Running `target/debug/playground`
Meta
rustc --version --verbose
:
<version>
Backtrace
<backtrace>
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Category: This is a bug.Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleRelevant to the compiler team, which will review and decide on the PR/issue.