Skip to content

Commit 714c8a5

Browse files
committed
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)
1 parent dc0c0dc commit 714c8a5

1 file changed

Lines changed: 27 additions & 5 deletions

File tree

‎test_suite/tests/test_gen.rs‎

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -851,14 +851,36 @@ where
851851

852852
#[repr(packed)]
853853
pub struct RemotePacked {
854-
pub a: u8,
855-
pub b: u16,
854+
pub a: u16,
855+
pub b: u32,
856856
}
857857

858-
#[derive(Serialize, Deserialize)]
858+
#[derive(Serialize)]
859859
#[repr(packed)]
860860
#[serde(remote = "RemotePacked")]
861861
pub struct RemotePackedDef {
862-
a: u8,
863-
b: u16,
862+
a: u16,
863+
b: u32,
864+
}
865+
866+
impl Drop for RemotePackedDef {
867+
fn drop(&mut self) {}
868+
}
869+
870+
#[repr(packed)]
871+
pub struct RemotePackedNonCopy {
872+
pub a: u16,
873+
pub b: String,
874+
}
875+
876+
#[derive(Deserialize)]
877+
#[repr(packed)]
878+
#[serde(remote = "RemotePackedNonCopy")]
879+
pub struct RemotePackedNonCopyDef {
880+
a: u16,
881+
b: String,
882+
}
883+
884+
impl Drop for RemotePackedNonCopyDef {
885+
fn drop(&mut self) {}
864886
}

0 commit comments

Comments
 (0)