1 #![deny(unaligned_references)]
3 // Check that deriving certain builtin traits on certain packed structs cause
4 // errors. To avoid potentially misaligned references, field copies must be
5 // used, which involves adding `T: Copy` bounds.
7 #[derive(Copy, Clone, Default, PartialEq, Eq)]
9 pub struct Foo<T>(T, T, T);
11 // This one is fine because the fields all impl `Copy`.
12 #[derive(Default, Hash)]
14 pub struct Bar(u32, u32, u32);
16 // This one is fine because it's not packed.
17 #[derive(Debug, Default)]
20 // This one has an error because `Y` doesn't impl `Copy`.
21 // Note: there is room for improvement in the error message.
22 #[derive(Debug, Default)]
25 //~^ ERROR cannot move out of `self` which is behind a shared reference
27 // This is currently allowed, but will be phased out at some point. From
28 // `zerovec` within icu4x-0.9.0.
31 struct FlexZeroSlice {
34 //~^ WARNING byte slice in a packed struct that derives a built-in trait
35 //~^^ this was previously accepted