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