Debian Codegraph @

debian/missing-sources/zerocopy-derive/tests/ui-stable/mid_compile_pass.rs

raw
1 // Copyright 2023 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 extern crate zerocopy_renamed;
10
11 use zerocopy_renamed::KnownLayout;
12
13 fn main() {}
14
15 // These tests cause errors which are generated by a later compilation pass than
16 // the other errors we generate, and so if they're compiled in the same file,
17 // the compiler will never get to that pass, and so we won't get the errors.
18
19 //
20 // KnownLayout errors
21 //
22
23 fn assert_kl<T: ?Sized + KnownLayout>(_: &T) {}
24
25 // | `repr(C)`? | generic? | `KnownLayout`? | `Sized`? | Type Name |
26 // | N | Y | N | N | KL04 |
27 #[derive(KnownLayout)]
28 #[zerocopy(crate = "zerocopy_renamed")]
29 struct KL04<T: ?Sized>(u8, T);
30
31 fn test_kl04<T: ?Sized>(kl: &KL04<T>) {
32 assert_kl(kl);
33 }
34
35 // | `repr(C)`? | generic? | `KnownLayout`? | `Sized`? | Type Name |
36 // | N | Y | Y | N | KL06 |
37 #[derive(KnownLayout)]
38 #[zerocopy(crate = "zerocopy_renamed")]
39 struct KL06<T: ?Sized + KnownLayout>(u8, T);
40
41 fn test_kl06<T: ?Sized + KnownLayout>(kl: &KL06<T>) {
42 assert_kl(kl);
43 }
44
45 // | `repr(C)`? | generic? | `KnownLayout`? | `Sized`? | Type Name |
46 // | Y | Y | N | N | KL12 |
47 #[derive(KnownLayout)]
48 #[zerocopy(crate = "zerocopy_renamed")]
49 #[repr(C)]
50 struct KL12<T: ?Sized>(u8, T);
51
52 fn test_kl12<T: ?Sized>(kl: &KL12<T>) {
53 assert_kl(kl)
54 }
55
56 // | `repr(C)`? | generic? | `KnownLayout`? | `Sized`? | Type Name |
57 // | Y | Y | N | Y | KL13 |
58 #[derive(KnownLayout)]
59 #[zerocopy(crate = "zerocopy_renamed")]
60 #[repr(C)]
61 struct KL13<T>(u8, T);
62
63 fn test_kl13<T>(t: T) -> impl KnownLayout {
64 KL13(0u8, t)
65 }