• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // See comment in `include.rs` for why we disable the prelude.
10 #![no_implicit_prelude]
11 #![allow(warnings)]
12 #![deny(deprecated)]
13 
14 include!("include.rs");
15 
16 // Make sure no deprecation warnings are generated from our derives (see #553).
17 
18 #[macro_export]
19 macro_rules! test {
20     ($name:ident => $ty:item => $($trait:ident),*) => {
21         #[allow(non_snake_case)]
22         mod $name {
23             $(
24                 mod $trait {
25                     use super::super::*;
26 
27                     #[deprecated = "do not use"]
28                     #[derive(imp::$trait)]
29                     $ty
30 
31                     #[allow(deprecated)]
32                     fn _allow_deprecated() {
33                         util_assert_impl_all!($name: imp::$trait);
34                     }
35                 }
36             )*
37         }
38     };
39 }
40 
41 // NOTE: `FromBytes` is tested separately in `enum_from_bytes.rs` since it
42 // requires 256-variant enums which are extremely verbose; such enums are
43 // already in that file.
44 test!(Enum => #[repr(u8)] enum Enum { A, } => TryFromBytes, FromZeros, KnownLayout, Immutable, IntoBytes, Unaligned);
45 
46 test!(Struct => #[repr(C)] struct Struct; => TryFromBytes, FromZeros, FromBytes, KnownLayout, Immutable, IntoBytes, Unaligned);
47 
48 test!(Union => #[repr(C)] union Union{ a: (), } => TryFromBytes, FromZeros, FromBytes, KnownLayout, Immutable, IntoBytes, Unaligned);
49