Debian Codegraph @

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