Debian Codegraph @

debian/rust-vendor/zerocopy-derive/tests/ui/msrv_specific.rs

raw
1 // Copyright 2024 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 // This file contains tests which trigger errors on MSRV during a different
10 // compiler pass compared to the stable or nightly toolchains.
11
12 #[macro_use]
13 extern crate zerocopy_renamed;
14
15 #[path = "../include.rs"]
16 mod util;
17
18 use zerocopy_renamed::IntoBytes;
19
20 use self::util::util::AU16;
21
22 fn main() {}
23
24 // `repr(C, packed(2))` can still have padding between heterogeneous fields.
25 #[derive(IntoBytes)]
26 #[zerocopy(crate = "zerocopy_renamed")]
27 #[repr(C, packed(2))]
28 struct IntoBytes1<T> {
29 byte: u8,
30 // For `T = AU16`, this field remains 2-aligned and leaves a padding byte
31 // after `byte`.
32 t: T,
33 }
34
35 fn is_into_bytes_1<T: IntoBytes>() {
36 if false {
37 is_into_bytes_1::<IntoBytes1<AU16>>();
38 //~[msrv, stable, nightly]^ ERROR: the trait bound `AU16: zerocopy_renamed::Unaligned` is not satisfied
39 }
40 }