From 1b6a04ca5504955c571d1c97504fb45ea0befee4 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Mon, 8 Jan 2024 01:21:28 +0400 Subject: Initial vendor packages Signed-off-by: Valentin Popov --- vendor/bytemuck/tests/derive.rs | 77 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 vendor/bytemuck/tests/derive.rs (limited to 'vendor/bytemuck/tests/derive.rs') diff --git a/vendor/bytemuck/tests/derive.rs b/vendor/bytemuck/tests/derive.rs new file mode 100644 index 0000000..1c6b10e --- /dev/null +++ b/vendor/bytemuck/tests/derive.rs @@ -0,0 +1,77 @@ +#![cfg(feature = "derive")] +#![allow(dead_code)] + +use bytemuck::{ByteEq, ByteHash, Pod, TransparentWrapper, Zeroable}; +use std::marker::PhantomData; + +#[derive(Copy, Clone, Pod, Zeroable, ByteEq, ByteHash)] +#[repr(C)] +struct Test { + a: u16, + b: u16, +} + +#[derive(TransparentWrapper)] +#[repr(transparent)] +struct TransparentSingle { + a: u16, +} + +#[derive(TransparentWrapper)] +#[repr(transparent)] +#[transparent(u16)] +struct TransparentWithZeroSized { + a: u16, + b: (), +} + +#[derive(TransparentWrapper)] +#[repr(transparent)] +struct TransparentWithGeneric { + a: T, +} + +/// Ensuring that no additional bounds are emitted. +/// See https://github.com/Lokathor/bytemuck/issues/145 +fn test_generic(x: T) -> TransparentWithGeneric { + TransparentWithGeneric::wrap(x) +} + +#[derive(TransparentWrapper)] +#[repr(transparent)] +#[transparent(T)] +struct TransparentWithGenericAndZeroSized { + a: (), + b: T, +} + +/// Ensuring that no additional bounds are emitted. +/// See https://github.com/Lokathor/bytemuck/issues/145 +fn test_generic_with_zst(x: T) -> TransparentWithGenericAndZeroSized { + TransparentWithGenericAndZeroSized::wrap(x) +} + +#[derive(TransparentWrapper)] +#[repr(transparent)] +struct TransparentUnsized { + a: dyn std::fmt::Debug, +} + +type DynDebug = dyn std::fmt::Debug; + +#[derive(TransparentWrapper)] +#[repr(transparent)] +#[transparent(DynDebug)] +struct TransparentUnsizedWithZeroSized { + a: (), + b: DynDebug, +} + +#[derive(TransparentWrapper)] +#[repr(transparent)] +#[transparent(DynDebug)] +struct TransparentUnsizedWithGenericZeroSizeds { + a: PhantomData, + b: PhantomData, + c: DynDebug, +} -- cgit v1.2.3