• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1error: reference to packed field is unaligned
2  --> tests/ui/pin_project/packed.rs:5:1
3   |
45  | / pin_project! { //~ ERROR reference to packed field is unaligned
56  | |     #[repr(packed, C)]
67  | |     struct Packed {
78  | |         #[pin]
89  | |         field: u16,
910 | |     }
1011 | | }
11   | |_^
12   |
13note: the lint level is defined here
14  --> tests/ui/pin_project/packed.rs:5:1
15   |
165  | / pin_project! { //~ ERROR reference to packed field is unaligned
176  | |     #[repr(packed, C)]
187  | |     struct Packed {
198  | |         #[pin]
209  | |         field: u16,
2110 | |     }
2211 | | }
23   | |_^
24   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
25   = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
26   = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
27   = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
28   = note: this error originates in the macro `$crate::__pin_project_constant` (in Nightly builds, run with -Z macro-backtrace for more info)
29
30error: reference to packed field is unaligned
31  --> tests/ui/pin_project/packed.rs:13:1
32   |
3313 | / pin_project! { //~ ERROR reference to packed field is unaligned
3414 | |     #[repr(packed(2))]
3515 | |     struct PackedN {
3616 | |         #[pin]
3717 | |         field: u32,
3818 | |     }
3919 | | }
40   | |_^
41   |
42note: the lint level is defined here
43  --> tests/ui/pin_project/packed.rs:13:1
44   |
4513 | / pin_project! { //~ ERROR reference to packed field is unaligned
4614 | |     #[repr(packed(2))]
4715 | |     struct PackedN {
4816 | |         #[pin]
4917 | |         field: u32,
5018 | |     }
5119 | | }
52   | |_^
53   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
54   = note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
55   = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
56   = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
57   = note: this error originates in the macro `$crate::__pin_project_constant` (in Nightly builds, run with -Z macro-backtrace for more info)
58