Skip to content

Commit 14accf7

Browse files
committed
Add test of remote with a packed struct
Currently fails to build: error: reference to packed field is unaligned --> test_suite/tests/test_gen.rs:858:10 | 858 | #[derive(Serialize, Deserialize)] | ^^^^^^^^^ | note: the lint level is defined here --> test_suite/tests/test_gen.rs:5:9 | 5 | #![deny(warnings)] | ^^^^^^^^ = note: `#[deny(unaligned_references)]` implied by `#[deny(warnings)]` = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = note: this error originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace for more info) error: reference to packed field is unaligned --> test_suite/tests/test_gen.rs:858:21 | 858 | #[derive(Serialize, Deserialize)] | ^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
1 parent 55fdbea commit 14accf7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test_suite/tests/test_gen.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,3 +846,19 @@ where
846846
{
847847
T::deserialize(deserializer)
848848
}
849+
850+
//////////////////////////////////////////////////////////////////////////
851+
852+
#[repr(packed)]
853+
pub struct RemotePacked {
854+
pub a: u8,
855+
pub b: u16,
856+
}
857+
858+
#[derive(Serialize, Deserialize)]
859+
#[repr(packed)]
860+
#[serde(remote = "RemotePacked")]
861+
pub struct RemotePackedDef {
862+
a: u8,
863+
b: u16,
864+
}

0 commit comments

Comments
 (0)