Debian Codegraph @

debian/missing-sources/zerocopy-derive/tests/enum_unaligned.rs

raw
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 // See comment in `include.rs` for why we disable the prelude.
10 #![no_implicit_prelude]
11 #![allow(warnings)]
12
13 include!("include.rs");
14
15 // An enum is `Unaligned` if:
16 // - No `repr(align(N > 1))`
17 // - `repr(u8)` or `repr(i8)`
18
19 #[derive(imp::Unaligned)]
20 #[zerocopy(crate = "zerocopy_renamed")]
21 #[repr(u8)]
22 enum Foo {
23 A,
24 }
25
26 util_assert_impl_all!(Foo: imp::Unaligned);
27
28 #[derive(imp::Unaligned)]
29 #[zerocopy(crate = "zerocopy_renamed")]
30 #[repr(i8)]
31 enum Bar {
32 A,
33 }
34
35 util_assert_impl_all!(Bar: imp::Unaligned);
36
37 #[derive(imp::Unaligned)]
38 #[zerocopy(crate = "zerocopy_renamed")]
39 #[repr(u8, align(1))]
40 enum Baz {
41 A,
42 }
43
44 util_assert_impl_all!(Baz: imp::Unaligned);
45
46 #[derive(imp::Unaligned)]
47 #[zerocopy(crate = "zerocopy_renamed")]
48 #[repr(i8, align(1))]
49 enum Blah {
50 B,
51 }
52
53 util_assert_impl_all!(Blah: imp::Unaligned);