Add test of packed struct that cannot be destructured

Currently fails:

    error[E0509]: cannot move out of type `RemotePackedNonCopyDef`, which implements the `Drop` trait
       --> test_suite/tests/test_gen.rs:876:10
        |
    876 | #[derive(Deserialize)]
        |          ^^^^^^^^^^^
        |          |
        |          cannot move out of here
        |          data moved here
        |          move occurs because `__v1` has type `std::string::String`, which does not implement the `Copy` trait
        |
        = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
This commit is contained in:
David Tolnay 2021-08-23 10:49:32 -07:00
parent dc0c0dcba1
commit 714c8a5586
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -851,14 +851,36 @@ where
#[repr(packed)]
pub struct RemotePacked {
pub a: u8,
pub b: u16,
pub a: u16,
pub b: u32,
}
#[derive(Serialize, Deserialize)]
#[derive(Serialize)]
#[repr(packed)]
#[serde(remote = "RemotePacked")]
pub struct RemotePackedDef {
a: u8,
b: u16,
a: u16,
b: u32,
}
impl Drop for RemotePackedDef {
fn drop(&mut self) {}
}
#[repr(packed)]
pub struct RemotePackedNonCopy {
pub a: u16,
pub b: String,
}
#[derive(Deserialize)]
#[repr(packed)]
#[serde(remote = "RemotePackedNonCopy")]
pub struct RemotePackedNonCopyDef {
a: u16,
b: String,
}
impl Drop for RemotePackedNonCopyDef {
fn drop(&mut self) {}
}