diff --git a/tests/unaligned_references.rs b/tests/unaligned_references.rs new file mode 100644 index 0000000..00e72cc --- /dev/null +++ b/tests/unaligned_references.rs @@ -0,0 +1,18 @@ +#[repr(packed)] +pub struct X { + pub inner: u16, +} + +#[forbid(unaligned_references)] +fn _f(this: &X) { + let _ = &this.inner; + //~^ ERROR reference to packed field is unaligned +} + +pin_project_lite::pin_project! { + //~^ WARN borrow of packed field is unsafe and requires unsafe function or block (error E0133) + #[repr(packed)] + pub struct Y { + pub inner: u16 + } +}