1 // Copyright 2019 The Fuchsia Authors
2 //
3 // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
4 // <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
5 // license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
6 // This file may not be copied, modified, or distributed except according to
7 // those terms.
8 
9 #![allow(warnings)]
10 
11 use {static_assertions::assert_impl_all, zerocopy::Unaligned};
12 
13 // An enum is `Unaligned` if:
14 // - No `repr(align(N > 1))`
15 // - `repr(u8)` or `repr(i8)`
16 
17 #[derive(Unaligned)]
18 #[repr(u8)]
19 enum Foo {
20     A,
21 }
22 
23 assert_impl_all!(Foo: Unaligned);
24 
25 #[derive(Unaligned)]
26 #[repr(i8)]
27 enum Bar {
28     A,
29 }
30 
31 assert_impl_all!(Bar: Unaligned);
32 
33 #[derive(Unaligned)]
34 #[repr(u8, align(1))]
35 enum Baz {
36     A,
37 }
38 
39 assert_impl_all!(Baz: Unaligned);
40 
41 #[derive(Unaligned)]
42 #[repr(i8, align(1))]
43 enum Blah {
44     B,
45 }
46 
47 assert_impl_all!(Blah: Unaligned);
48