| 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; |
| 14 |
|
| 15 |
#[path = "../include.rs"] |
| 16 |
mod util; |
| 17 |
|
| 18 |
use zerocopy::IntoBytes; |
| 19 |
|
| 20 |
use self::util::util::AU16; |
| 21 |
|
| 22 |
fn main() {} |
| 23 |
|
| 24 |
// `repr(C, packed(2))` is not equivalent to `repr(C, packed)`. |
| 25 |
#[derive(IntoBytes)] |
| 26 |
#[repr(C, packed(2))] |
| 27 |
struct IntoBytes1<T> { |
| 28 |
t0: T, |
| 29 |
// Add a second field to avoid triggering the "repr(C) struct with one |
| 30 |
// field" special case. |
| 31 |
t1: T, |
| 32 |
} |
| 33 |
|
| 34 |
fn is_into_bytes_1<T: IntoBytes>() { |
| 35 |
if false { |
| 36 |
is_into_bytes_1::<IntoBytes1<AU16>>(); |
| 37 |
} |
| 38 |
} |