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 #[macro_use]
10 extern crate zerocopy;
11
12 #[path = "../util.rs"]
13 mod util;
14
15 use self::util::{NotZerocopy, AU16};
16 use zerocopy::KnownLayout;
17
main()18 fn main() {}
19
20 // These tests cause errors which are generated by a later compilation pass than
21 // the other errors we generate, and so if they're compiled in the same file,
22 // the compiler will never get to that pass, and so we won't get the errors.
23
24 //
25 // FromZeroes errors
26 //
27
28 #[derive(FromZeroes)]
29 struct FromZeroes1 {
30 value: NotZerocopy,
31 }
32
33 //
34 // FromBytes errors
35 //
36
37 #[derive(FromBytes)]
38 struct FromBytes1 {
39 value: NotZerocopy,
40 }
41
42 //
43 // AsBytes errors
44 //
45
46 #[derive(AsBytes)]
47 #[repr(C)]
48 struct AsBytes1 {
49 value: NotZerocopy,
50 }
51
52 //
53 // Unaligned errors
54 //
55
56 #[derive(Unaligned)]
57 #[repr(C)]
58 struct Unaligned1 {
59 aligned: AU16,
60 }
61
62 // This specifically tests a bug we had in an old version of the code in which
63 // the trait bound would only be enforced for the first field's type.
64 #[derive(Unaligned)]
65 #[repr(C)]
66 struct Unaligned2 {
67 unaligned: u8,
68 aligned: AU16,
69 }
70
71 #[derive(Unaligned)]
72 #[repr(transparent)]
73 struct Unaligned3 {
74 aligned: AU16,
75 }
76