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 // See comment in `include.rs` for why we disable the prelude. 10 #![no_implicit_prelude] 11 #![allow(warnings)] 12 13 include!("include.rs"); 14 15 #[derive(imp::Immutable)] 16 enum Foo { 17 A, 18 } 19 20 util_assert_impl_all!(Foo: imp::Immutable); 21 22 #[derive(imp::Immutable)] 23 enum Bar { 24 A = 0, 25 } 26 27 util_assert_impl_all!(Bar: imp::Immutable); 28 29 #[derive(imp::Immutable)] 30 enum Baz { 31 A = 1, 32 B = 0, 33 } 34 35 util_assert_impl_all!(Baz: imp::Immutable); 36 37 // Deriving `Immutable` should work if the enum has bounded parameters. 38 39 #[derive(imp::Immutable)] 40 #[repr(C)] 41 enum WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + imp::Immutable, const N: ::core::primitive::usize> 42 where 43 'a: 'b, 44 'b: 'a, 45 T: 'a + 'b + imp::Immutable, 46 { 47 Variant([T; N], imp::PhantomData<&'a &'b ()>), 48 UnsafeCell(imp::PhantomData<imp::UnsafeCell<()>>, &'a imp::UnsafeCell<()>), 49 } 50 51 util_assert_impl_all!(WithParams<'static, 'static, u8, 42>: imp::Immutable); 52