diff --git a/zerocopy-derive/src/enum.rs b/zerocopy-derive/src/enum.rs index 2fbd3c74ef..21ddaffdf7 100644 --- a/zerocopy-derive/src/enum.rs +++ b/zerocopy-derive/src/enum.rs @@ -41,7 +41,7 @@ pub(crate) fn generate_tag_enum(repr: &EnumRepr, data: &DataEnum) -> TokenStream quote! { #repr - #[allow(dead_code, non_camel_case_types)] + #[allow(dead_code)] enum ___ZerocopyTag { #(#variants,)* } @@ -90,7 +90,6 @@ fn generate_tag_consts(data: &DataEnum) -> TokenStream { // // Casting between two integers of the same size (e.g. i32 -> u32) // is a no-op. - #[allow(non_upper_case_globals)] const #tag_ident: ___ZerocopyTagPrimitive = ___ZerocopyTag::#variant_ident as ___ZerocopyTagPrimitive; } @@ -143,7 +142,6 @@ fn generate_variant_structs( let variant_struct = parse_quote! { #[repr(C)] - #[allow(non_snake_case)] struct #variant_struct_ident #impl_generics ( core_reexport::mem::MaybeUninit<___ZerocopyInnerTag>, #(#field_types,)* @@ -200,7 +198,6 @@ fn generate_variants_union( let variants_union = parse_quote! { #[repr(C)] - #[allow(non_snake_case)] union ___ZerocopyVariants #generics { #(#fields)* // Enums can have variants with no fields, but unions must @@ -446,7 +443,6 @@ pub(crate) fn derive_is_bit_valid( let variants = raw_enum.project::<_, { #zerocopy_crate::ident_id!(variants) }>(); - #[allow(non_upper_case_globals)] match tag { #(#match_arms,)* _ => false, diff --git a/zerocopy-derive/src/lib.rs b/zerocopy-derive/src/lib.rs index 37f57c94ff..a62b82a0d4 100644 --- a/zerocopy-derive/src/lib.rs +++ b/zerocopy-derive/src/lib.rs @@ -91,7 +91,11 @@ macro_rules! derive { Ok(zerocopy_crate) => zerocopy_crate, Err(e) => return e.into_compile_error().into(), }; - $inner(&ast, Trait::$trait, &zerocopy_crate).into_ts().into() + let ts = $inner(&ast, Trait::$trait, &zerocopy_crate).into_ts(); + // We wrap in `const_block` as a backstop in case any derive fails + // to wrap its output in `const_block` (and thus fails to annotate) + // with the full set of `#[allow(...)]` attributes). + const_block([Some(ts)]).into() } }; } @@ -337,7 +341,6 @@ fn derive_known_layout_inner( // Define the collection of type-level field handles. let field_defs = field_indices.iter().zip(&fields).map(|(idx, (vis, _, _))| { quote! { - #[allow(non_camel_case_types)] #vis struct #idx; } }); @@ -352,7 +355,6 @@ fn derive_known_layout_inner( // would not respect `Self` hygiene, as `Self` would refer to // the helper struct we are generating, not the derive target // type. - #[allow(deprecated)] unsafe impl #impl_generics #zerocopy_crate::util::macro_util::Field<#idx> for #ident #ty_generics where #predicates @@ -393,11 +395,6 @@ fn derive_known_layout_inner( // `#ty`, not `__ZerocopyKnownLayoutMaybeUninit` (see #2116). #repr #[doc(hidden)] - // Required on some rustc versions due to a lint that is only - // triggered when `derive(KnownLayout)` is applied to `repr(C)` - // structs that are generated by macros. See #2177 for details. - #[allow(private_bounds)] - #[allow(deprecated)] #vis struct __ZerocopyKnownLayoutMaybeUninit<#params> ( #(#zerocopy_crate::util::macro_util::core_reexport::mem::MaybeUninit< <#ident #ty_generics as @@ -424,13 +421,11 @@ fn derive_known_layout_inner( // sound, since `__ZerocopyKnownLayoutMaybeUninit` is guaranteed // to have the same layout as the derive target type, except // that `__ZerocopyKnownLayoutMaybeUninit` admits uninit bytes. - #[allow(deprecated)] unsafe impl #impl_generics #zerocopy_crate::KnownLayout for __ZerocopyKnownLayoutMaybeUninit #ty_generics where #trailing_field_ty: #zerocopy_crate::KnownLayout, #predicates { - #[allow(clippy::missing_inline_in_public_items)] fn only_derive_is_allowed_to_implement_this_trait() {} type PointerMetadata = <#ident #ty_generics as #zerocopy_crate::KnownLayout>::PointerMetadata; @@ -631,10 +626,6 @@ fn derive_hash_inner( let (impl_generics, ty_generics, where_clause) = ast.generics.split_for_impl(); let where_predicates = where_clause.map(|clause| &clause.predicates); Ok(quote! { - #[allow(deprecated)] - // While there are not currently any warnings that this suppresses (that - // we're aware of), it's good future-proofing hygiene. - #[automatically_derived] impl #impl_generics #zerocopy_crate::util::macro_util::core_reexport::hash::Hash for #type_ident #ty_generics where Self: #zerocopy_crate::IntoBytes + #zerocopy_crate::Immutable, @@ -677,12 +668,6 @@ fn derive_eq_inner( let (impl_generics, ty_generics, where_clause) = ast.generics.split_for_impl(); let where_predicates = where_clause.map(|clause| &clause.predicates); Ok(quote! { - // FIXME(#553): Add a test that generates a warning when - // `#[allow(deprecated)]` isn't present. - #[allow(deprecated)] - // While there are not currently any warnings that this suppresses (that - // we're aware of), it's good future-proofing hygiene. - #[automatically_derived] impl #impl_generics #zerocopy_crate::util::macro_util::core_reexport::cmp::PartialEq for #type_ident #ty_generics where Self: #zerocopy_crate::IntoBytes + #zerocopy_crate::Immutable, @@ -696,12 +681,6 @@ fn derive_eq_inner( } } - // FIXME(#553): Add a test that generates a warning when - // `#[allow(deprecated)]` isn't present. - #[allow(deprecated)] - // While there are not currently any warnings that this suppresses (that - // we're aware of), it's good future-proofing hygiene. - #[automatically_derived] impl #impl_generics #zerocopy_crate::util::macro_util::core_reexport::cmp::Eq for #type_ident #ty_generics where Self: #zerocopy_crate::IntoBytes + #zerocopy_crate::Immutable, @@ -867,13 +846,7 @@ fn derive_has_field_struct_union( .build() }); - quote! { - #[allow(non_camel_case_types)] - const _: () = { - #(#field_tokens)* - #(#has_fields)* - }; - } + const_block(field_tokens.into_iter().chain(has_fields).map(Some)) } /// A struct is `TryFromBytes` if: @@ -1945,10 +1918,6 @@ impl<'a> ImplBlockBuilder<'a> { let inner_extras = self.inner_extras; let impl_tokens = quote! { - #[allow(deprecated, non_local_definitions)] - // While there are not currently any warnings that this suppresses - // (that we're aware of), it's good future-proofing hygiene. - #[automatically_derived] unsafe impl < #(#params),* > #trait_path for #type_ident < #(#param_idents),* > where #(#bounds,)* @@ -1959,23 +1928,8 @@ impl<'a> ImplBlockBuilder<'a> { } }; - if let Some(outer_extras) = self.outer_extras.filter(|e| !e.is_empty()) { - // So that any items defined in `#outer_extras` don't conflict with - // existing names defined in this scope. - quote! { - #[allow(deprecated, non_local_definitions)] - // While there are not currently any warnings that this suppresses - // (that we're aware of), it's good future-proofing hygiene. - #[automatically_derived] - const _: () = { - #impl_tokens - - #outer_extras - }; - } - } else { - impl_tokens - } + let outer_extras = self.outer_extras.filter(|e| !e.is_empty()); + const_block([Some(impl_tokens), outer_extras]) } } @@ -2000,3 +1954,30 @@ impl BoolExt for bool { } } } + +fn const_block(items: impl IntoIterator>) -> TokenStream { + let items = items.into_iter().flatten(); + quote! { + #[allow( + // FIXME(#553): Add a test that generates a warning when + // `#[allow(deprecated)]` isn't present. + deprecated, + // Required on some rustc versions due to a lint that is only + // triggered when `derive(KnownLayout)` is applied to `repr(C)` + // structs that are generated by macros. See #2177 for details. + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + // While there are not currently any warnings that this suppresses + // (that we're aware of), it's good future-proofing hygiene. + #[automatically_derived] + const _: () = { + #(#items)* + }; + } +} diff --git a/zerocopy-derive/src/output_tests.rs b/zerocopy-derive/src/output_tests.rs index d7856c2139..bf823f9ce3 100644 --- a/zerocopy-derive/src/output_tests.rs +++ b/zerocopy-derive/src/output_tests.rs @@ -105,31 +105,39 @@ fn test_known_layout() { KnownLayout { struct Foo; } expands to { - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::KnownLayout for Foo - where - Self: ::zerocopy::util::macro_util::core_reexport::marker::Sized, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - - type PointerMetadata = (); - - type MaybeUninit = ::zerocopy::util::macro_util::core_reexport::mem::MaybeUninit; - - const LAYOUT: ::zerocopy::DstLayout = ::zerocopy::DstLayout::for_type::(); - - #[inline(always)] - fn raw_from_ptr_len( - bytes: ::zerocopy::util::macro_util::core_reexport::ptr::NonNull, - _meta: (), - ) -> ::zerocopy::util::macro_util::core_reexport::ptr::NonNull { - bytes.cast::() + const _: () = { + unsafe impl ::zerocopy::KnownLayout for Foo + where + Self: ::zerocopy::util::macro_util::core_reexport::marker::Sized, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type PointerMetadata = (); + type MaybeUninit = ::zerocopy::util::macro_util::core_reexport::mem::MaybeUninit< + Self, + >; + const LAYOUT: ::zerocopy::DstLayout = ::zerocopy::DstLayout::for_type::(); + #[inline(always)] + fn raw_from_ptr_len( + bytes: ::zerocopy::util::macro_util::core_reexport::ptr::NonNull, + _meta: (), + ) -> ::zerocopy::util::macro_util::core_reexport::ptr::NonNull { + bytes.cast::() + } + #[inline(always)] + fn pointer_to_metadata(_ptr: *mut Self) -> () {} } - - #[inline(always)] - fn pointer_to_metadata(_ptr: *mut Self) -> () {} - } + }; } no_build } @@ -139,11 +147,18 @@ fn test_known_layout() { struct Foo(T, U); } expands to { - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] const _: () = { - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] unsafe impl ::zerocopy::KnownLayout for Foo where U: ::zerocopy::KnownLayout, @@ -181,16 +196,12 @@ fn test_known_layout() { ::pointer_to_metadata(ptr as *mut _) } } - #[allow(non_camel_case_types)] struct __Zerocopy_Field_0; - #[allow(non_camel_case_types)] struct __Zerocopy_Field_1; - #[allow(deprecated)] unsafe impl ::zerocopy::util::macro_util::Field<__Zerocopy_Field_0> for Foo { type Type = T; } - #[allow(deprecated)] unsafe impl ::zerocopy::util::macro_util::Field<__Zerocopy_Field_1> for Foo { type Type = U; @@ -198,8 +209,6 @@ fn test_known_layout() { #[repr(C)] #[repr(align(2))] #[doc(hidden)] - #[allow(private_bounds)] - #[allow(deprecated)] struct __ZerocopyKnownLayoutMaybeUninit( ::zerocopy::util::macro_util::core_reexport::mem::MaybeUninit< as ::zerocopy::util::macro_util::Field<__Zerocopy_Field_0>>::Type, @@ -220,7 +229,6 @@ fn test_known_layout() { > as ::zerocopy::util::macro_util::Field< __Zerocopy_Field_1, >>::Type: ::zerocopy::KnownLayout; - #[allow(deprecated)] unsafe impl ::zerocopy::KnownLayout for __ZerocopyKnownLayoutMaybeUninit where >::Type: ::zerocopy::KnownLayout, { - #[allow(clippy::missing_inline_in_public_items)] fn only_derive_is_allowed_to_implement_this_trait() {} type PointerMetadata = as ::zerocopy::KnownLayout>::PointerMetadata; type MaybeUninit = Self; @@ -283,11 +290,22 @@ fn test_immutable() { Immutable { struct Foo; } expands to { - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::Immutable for Foo { - fn only_derive_is_allowed_to_implement_this_trait() {} - } + const _: () = { + unsafe impl ::zerocopy::Immutable for Foo { + fn only_derive_is_allowed_to_implement_this_trait() {} + } + }; } no_build } } @@ -298,9 +316,19 @@ fn test_try_from_bytes() { TryFromBytes { struct Foo; } expands to { - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::TryFromBytes for Foo { + const _: () = { + unsafe impl ::zerocopy::TryFromBytes for Foo { fn only_derive_is_allowed_to_implement_this_trait() {} fn is_bit_valid<___ZerocopyAliasing>( @@ -312,6 +340,7 @@ fn test_try_from_bytes() { true } } + }; } no_build } } @@ -322,9 +351,19 @@ fn test_from_zeros() { FromZeros { struct Foo; } expands to { - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::TryFromBytes for Foo { + const _: () = { + unsafe impl ::zerocopy::TryFromBytes for Foo { fn only_derive_is_allowed_to_implement_this_trait() {} fn is_bit_valid<___ZerocopyAliasing>( mut candidate: ::zerocopy::Maybe, @@ -335,11 +374,23 @@ fn test_from_zeros() { true } } - #[allow(deprecated, non_local_definitions)] + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::FromZeros for Foo { + const _: () = { + unsafe impl ::zerocopy::FromZeros for Foo { fn only_derive_is_allowed_to_implement_this_trait() {} } + }; } no_build } } @@ -350,9 +401,19 @@ fn test_from_bytes_struct() { FromBytes { struct Foo; } expands to { - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::TryFromBytes for Foo { + const _: () = { + unsafe impl ::zerocopy::TryFromBytes for Foo { fn only_derive_is_allowed_to_implement_this_trait() {} fn is_bit_valid<___ZerocopyAliasing>( @@ -373,18 +434,41 @@ fn test_from_bytes_struct() { true } } + }; - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::FromZeros for Foo { + const _: () = { + unsafe impl ::zerocopy::FromZeros for Foo { fn only_derive_is_allowed_to_implement_this_trait() {} } + }; - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::FromBytes for Foo { + const _: () = { + unsafe impl ::zerocopy::FromBytes for Foo { fn only_derive_is_allowed_to_implement_this_trait() {} } + }; } no_build } } @@ -397,11 +481,18 @@ fn test_from_bytes_union() { a: u8, } } expands to { - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] const _: () = { - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] unsafe impl ::zerocopy::TryFromBytes for Foo where u8: ::zerocopy::TryFromBytes + ::zerocopy::Immutable, @@ -424,47 +515,91 @@ fn test_from_bytes_union() { true } } - #[allow(non_camel_case_types)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] const _: () = { enum ẕa {} - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::HasField< - ẕa, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(a) }, - > for Foo { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = u8; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).a - ) - + const _: () = { + unsafe impl ::zerocopy::HasField< + ẕa, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(a) }, + > for Foo { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = u8; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).a + ) + } } } - } + }; }; }; - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::FromZeros for Foo - where - u8: ::zerocopy::FromZeros + ::zerocopy::Immutable, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - } - #[allow(deprecated, non_local_definitions)] + const _: () = { + unsafe impl ::zerocopy::FromZeros for Foo + where + u8: ::zerocopy::FromZeros + ::zerocopy::Immutable, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::FromBytes for Foo - where - u8: ::zerocopy::FromBytes + ::zerocopy::Immutable, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - } + const _: () = { + unsafe impl ::zerocopy::FromBytes for Foo + where + u8: ::zerocopy::FromBytes + ::zerocopy::Immutable, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + } + }; } no_build } } @@ -476,11 +611,22 @@ fn test_into_bytes_struct() { #[repr(C)] struct Foo; } expands to { - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::IntoBytes for Foo { - fn only_derive_is_allowed_to_implement_this_trait() {} - } + const _: () = { + unsafe impl ::zerocopy::IntoBytes for Foo { + fn only_derive_is_allowed_to_implement_this_trait() {} + } + }; } no_build } @@ -492,19 +638,30 @@ fn test_into_bytes_struct() { b: u8, } } expands to { - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::IntoBytes for Foo - where - u8: ::zerocopy::IntoBytes, - u8: ::zerocopy::IntoBytes, - (): ::zerocopy::util::macro_util::PaddingFree< - Self, - { ::zerocopy::struct_padding!(Self, [(u8), (u8)]) }, - >, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - } + const _: () = { + unsafe impl ::zerocopy::IntoBytes for Foo + where + u8: ::zerocopy::IntoBytes, + u8: ::zerocopy::IntoBytes, + (): ::zerocopy::util::macro_util::PaddingFree< + Self, + { ::zerocopy::struct_padding!(Self, [(u8), (u8)]) }, + >, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + } + }; } no_build } @@ -516,19 +673,30 @@ fn test_into_bytes_struct() { b: [Trailing], } } expands to { - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::IntoBytes for Foo - where - u8: ::zerocopy::IntoBytes, - [Trailing]: ::zerocopy::IntoBytes, - (): ::zerocopy::util::macro_util::DynamicPaddingFree< - Self, - { ::zerocopy::repr_c_struct_has_padding!(Self, [(u8), ([Trailing])]) }, - >, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - } + const _: () = { + unsafe impl ::zerocopy::IntoBytes for Foo + where + u8: ::zerocopy::IntoBytes, + [Trailing]: ::zerocopy::IntoBytes, + (): ::zerocopy::util::macro_util::DynamicPaddingFree< + Self, + { ::zerocopy::repr_c_struct_has_padding!(Self, [(u8), ([Trailing])]) }, + >, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + } + }; } no_build } @@ -540,15 +708,26 @@ fn test_into_bytes_struct() { b: [Trailing], } } expands to { - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::IntoBytes for Foo - where - u8: ::zerocopy::IntoBytes + ::zerocopy::Unaligned, - [Trailing]: ::zerocopy::IntoBytes + ::zerocopy::Unaligned, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - } + const _: () = { + unsafe impl ::zerocopy::IntoBytes for Foo + where + u8: ::zerocopy::IntoBytes + ::zerocopy::Unaligned, + [Trailing]: ::zerocopy::IntoBytes + ::zerocopy::Unaligned, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + } + }; } no_build } } @@ -564,11 +743,22 @@ fn test_into_bytes_enum() { Bar, } } expands to { - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::IntoBytes for Foo { - fn only_derive_is_allowed_to_implement_this_trait() {} - } + const _: () = { + unsafe impl ::zerocopy::IntoBytes for Foo { + fn only_derive_is_allowed_to_implement_this_trait() {} + } + }; } no_build })* }; @@ -598,11 +788,22 @@ fn test_unaligned() { #[repr(C)] struct Foo; } expands to { - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::Unaligned for Foo { - fn only_derive_is_allowed_to_implement_this_trait() {} - } + const _: () = { + unsafe impl ::zerocopy::Unaligned for Foo { + fn only_derive_is_allowed_to_implement_this_trait() {} + } + }; } no_build } } @@ -621,4218 +822,5287 @@ fn test_try_from_bytes_enum() { TupleLike(bool, Y, PhantomData<&'a [(X, Y); N]>), } } expands to { - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl<'a: 'static, const N: usize, X, Y: Deref> ::zerocopy::TryFromBytes - for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - u8: ::zerocopy::TryFromBytes, - X: ::zerocopy::TryFromBytes, - X::Target: ::zerocopy::TryFromBytes, - Y::Target: ::zerocopy::TryFromBytes, - [(X, Y); N]: ::zerocopy::TryFromBytes, - bool: ::zerocopy::TryFromBytes, - Y: ::zerocopy::TryFromBytes, - PhantomData<&'a [(X, Y); N]>: ::zerocopy::TryFromBytes, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - fn is_bit_valid<___ZerocopyAliasing>( - candidate: ::zerocopy::Maybe<'_, Self, ___ZerocopyAliasing>, - ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool + const _: () = { + unsafe impl<'a: 'static, const N: usize, X, Y: Deref> ::zerocopy::TryFromBytes + for ComplexWithGenerics<'a, { N }, X, Y> where - ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, + X: Deref, + u8: ::zerocopy::TryFromBytes, + X: ::zerocopy::TryFromBytes, + X::Target: ::zerocopy::TryFromBytes, + Y::Target: ::zerocopy::TryFromBytes, + [(X, Y); N]: ::zerocopy::TryFromBytes, + bool: ::zerocopy::TryFromBytes, + Y: ::zerocopy::TryFromBytes, + PhantomData<&'a [(X, Y); N]>: ::zerocopy::TryFromBytes, { - use ::zerocopy::util::macro_util::core_reexport; - #[repr(u8)] - #[allow(dead_code, non_camel_case_types)] - enum ___ZerocopyTag { - UnitLike, - StructLike, - TupleLike, - } - unsafe impl ::zerocopy::Immutable for ___ZerocopyTag { - fn only_derive_is_allowed_to_implement_this_trait() {} - } - type ___ZerocopyTagPrimitive = ::zerocopy::util::macro_util::SizeToTag< - { core_reexport::mem::size_of::<___ZerocopyTag>() }, - >; - #[allow(non_upper_case_globals)] - const ___ZEROCOPY_TAG_UnitLike: ___ZerocopyTagPrimitive = ___ZerocopyTag::UnitLike - as ___ZerocopyTagPrimitive; - #[allow(non_upper_case_globals)] - const ___ZEROCOPY_TAG_StructLike: ___ZerocopyTagPrimitive = ___ZerocopyTag::StructLike - as ___ZerocopyTagPrimitive; - #[allow(non_upper_case_globals)] - const ___ZEROCOPY_TAG_TupleLike: ___ZerocopyTagPrimitive = ___ZerocopyTag::TupleLike - as ___ZerocopyTagPrimitive; - type ___ZerocopyOuterTag = (); - type ___ZerocopyInnerTag = ___ZerocopyTag; - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(tag) }, - > for ___ZerocopyRawEnum<'a, N, X, Y> { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = ___ZerocopyTag; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - slf.as_ptr().cast() - } - } - #[repr(C)] - #[allow(non_snake_case)] - struct ___ZerocopyVariantStruct_StructLike< - 'a: 'static, - const N: usize, - X, - Y: Deref, - >( - core_reexport::mem::MaybeUninit<___ZerocopyInnerTag>, - u8, - X, - X::Target, - Y::Target, - [(X, Y); N], - core_reexport::marker::PhantomData>, - ) + fn only_derive_is_allowed_to_implement_this_trait() {} + fn is_bit_valid<___ZerocopyAliasing>( + candidate: ::zerocopy::Maybe<'_, Self, ___ZerocopyAliasing>, + ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool where - X: Deref; - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - const _: () = { - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] + ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, + { + use ::zerocopy::util::macro_util::core_reexport; + #[repr(u8)] + #[allow(dead_code)] + enum ___ZerocopyTag { + UnitLike, + StructLike, + TupleLike, + } + unsafe impl ::zerocopy::Immutable for ___ZerocopyTag { + fn only_derive_is_allowed_to_implement_this_trait() {} + } + type ___ZerocopyTagPrimitive = ::zerocopy::util::macro_util::SizeToTag< + { core_reexport::mem::size_of::<___ZerocopyTag>() }, + >; + const ___ZEROCOPY_TAG_UnitLike: ___ZerocopyTagPrimitive = ___ZerocopyTag::UnitLike + as ___ZerocopyTagPrimitive; + const ___ZEROCOPY_TAG_StructLike: ___ZerocopyTagPrimitive = ___ZerocopyTag::StructLike + as ___ZerocopyTagPrimitive; + const ___ZEROCOPY_TAG_TupleLike: ___ZerocopyTagPrimitive = ___ZerocopyTag::TupleLike + as ___ZerocopyTagPrimitive; + type ___ZerocopyOuterTag = (); + type ___ZerocopyInnerTag = ___ZerocopyTag; unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, - > ::zerocopy::TryFromBytes - for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> - where - X: Deref, - core_reexport::mem::MaybeUninit< - ___ZerocopyInnerTag, - >: ::zerocopy::TryFromBytes, - u8: ::zerocopy::TryFromBytes, - X: ::zerocopy::TryFromBytes, - X::Target: ::zerocopy::TryFromBytes, - Y::Target: ::zerocopy::TryFromBytes, - [(X, Y); N]: ::zerocopy::TryFromBytes, - core_reexport::marker::PhantomData< - ComplexWithGenerics<'a, N, X, Y>, - >: ::zerocopy::TryFromBytes, - { + > ::zerocopy::HasField< + (), + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(tag) }, + > for ___ZerocopyRawEnum<'a, N, X, Y> { fn only_derive_is_allowed_to_implement_this_trait() {} - fn is_bit_valid<___ZerocopyAliasing>( - mut candidate: ::zerocopy::Maybe, - ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool - where - ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, - { - true - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(0) }>(); - as ::zerocopy::TryFromBytes>::is_bit_valid(field_candidate) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(1) }>(); - ::is_bit_valid( - field_candidate, - ) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(2) }>(); - ::is_bit_valid( - field_candidate, - ) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(3) }>(); - ::is_bit_valid( - field_candidate, - ) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(4) }>(); - ::is_bit_valid( - field_candidate, - ) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(5) }>(); - <[( - X, - Y, - ); N] as ::zerocopy::TryFromBytes>::is_bit_valid( - field_candidate, - ) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(6) }>(); - , - > as ::zerocopy::TryFromBytes>::is_bit_valid(field_candidate) - } + type Type = ___ZerocopyTag; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + slf.as_ptr().cast() } } - #[allow(non_camel_case_types)] + #[repr(C)] + struct ___ZerocopyVariantStruct_StructLike< + 'a: 'static, + const N: usize, + X, + Y: Deref, + >( + core_reexport::mem::MaybeUninit<___ZerocopyInnerTag>, + u8, + X, + X::Target, + Y::Target, + [(X, Y); N], + core_reexport::marker::PhantomData>, + ) + where + X: Deref; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] const _: () = { - enum ẕ0 {} - enum ẕ1 {} - enum ẕ2 {} - enum ẕ3 {} - enum ẕ4 {} - enum ẕ5 {} - enum ẕ6 {} - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, - > ::zerocopy::HasField< - ẕ0, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(0) }, - > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + > ::zerocopy::TryFromBytes + for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> where X: Deref, + core_reexport::mem::MaybeUninit< + ___ZerocopyInnerTag, + >: ::zerocopy::TryFromBytes, + u8: ::zerocopy::TryFromBytes, + X: ::zerocopy::TryFromBytes, + X::Target: ::zerocopy::TryFromBytes, + Y::Target: ::zerocopy::TryFromBytes, + [(X, Y); N]: ::zerocopy::TryFromBytes, + core_reexport::marker::PhantomData< + ComplexWithGenerics<'a, N, X, Y>, + >: ::zerocopy::TryFromBytes, { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = core_reexport::mem::MaybeUninit<___ZerocopyInnerTag>; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).0 - ) - } + fn is_bit_valid<___ZerocopyAliasing>( + mut candidate: ::zerocopy::Maybe, + ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool + where + ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, + { + true + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(0) }>(); + as ::zerocopy::TryFromBytes>::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(1) }>(); + ::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(2) }>(); + ::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(3) }>(); + ::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(4) }>(); + ::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(5) }>(); + <[( + X, + Y, + ); N] as ::zerocopy::TryFromBytes>::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(6) }>(); + , + > as ::zerocopy::TryFromBytes>::is_bit_valid( + field_candidate, + ) + } } } - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕ1, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(1) }, - > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = u8; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).1 - ) + const _: () = { + enum ẕ0 {} + enum ẕ1 {} + enum ẕ2 {} + enum ẕ3 {} + enum ẕ4 {} + enum ẕ5 {} + enum ẕ6 {} + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ0, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(0) }, + > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = core_reexport::mem::MaybeUninit< + ___ZerocopyInnerTag, + >; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).0 + ) + } + } } - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ1, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(1) }, + > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = u8; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).1 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ2, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(2) }, + > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = X; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).2 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ3, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(3) }, + > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = X::Target; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).3 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ4, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(4) }, + > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = Y::Target; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).4 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ5, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(5) }, + > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = [(X, Y); N]; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).5 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ6, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(6) }, + > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = core_reexport::marker::PhantomData< + ComplexWithGenerics<'a, N, X, Y>, + >; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).6 + ) + } + } + } + }; + }; + }; + #[repr(C)] + struct ___ZerocopyVariantStruct_TupleLike< + 'a: 'static, + const N: usize, + X, + Y: Deref, + >( + core_reexport::mem::MaybeUninit<___ZerocopyInnerTag>, + bool, + Y, + PhantomData<&'a [(X, Y); N]>, + core_reexport::marker::PhantomData>, + ) + where + X: Deref; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, - > ::zerocopy::HasField< - ẕ2, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(2) }, - > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + > ::zerocopy::TryFromBytes + for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> where X: Deref, + core_reexport::mem::MaybeUninit< + ___ZerocopyInnerTag, + >: ::zerocopy::TryFromBytes, + bool: ::zerocopy::TryFromBytes, + Y: ::zerocopy::TryFromBytes, + PhantomData<&'a [(X, Y); N]>: ::zerocopy::TryFromBytes, + core_reexport::marker::PhantomData< + ComplexWithGenerics<'a, N, X, Y>, + >: ::zerocopy::TryFromBytes, { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = X; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).2 - ) - } + fn is_bit_valid<___ZerocopyAliasing>( + mut candidate: ::zerocopy::Maybe, + ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool + where + ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, + { + true + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(0) }>(); + as ::zerocopy::TryFromBytes>::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(1) }>(); + ::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(2) }>(); + ::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(3) }>(); + as ::zerocopy::TryFromBytes>::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(4) }>(); + , + > as ::zerocopy::TryFromBytes>::is_bit_valid( + field_candidate, + ) + } } } - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕ3, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(3) }, - > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = X::Target; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).3 - ) + const _: () = { + enum ẕ0 {} + enum ẕ1 {} + enum ẕ2 {} + enum ẕ3 {} + enum ẕ4 {} + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ0, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(0) }, + > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = core_reexport::mem::MaybeUninit< + ___ZerocopyInnerTag, + >; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).0 + ) + } + } } - } - } - #[allow(deprecated, non_local_definitions)] + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ1, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(1) }, + > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = bool; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).1 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ2, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(2) }, + > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = Y; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).2 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ3, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(3) }, + > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = PhantomData<&'a [(X, Y); N]>; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).3 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ4, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(4) }, + > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = core_reexport::marker::PhantomData< + ComplexWithGenerics<'a, N, X, Y>, + >; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).4 + ) + } + } + } + }; + }; + }; + #[repr(C)] + union ___ZerocopyVariants<'a: 'static, const N: usize, X, Y: Deref> { + __field_StructLike: core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, + >, + __field_TupleLike: core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, + >, + __nonempty: (), + } + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + enum ẕ__field_StructLike {} + enum ẕ__field_TupleLike {} + enum ẕ__nonempty {} + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕ4, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(4) }, - > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = Y::Target; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).4 - ) + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ__field_StructLike, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + > for ___ZerocopyVariants<'a, { N }, X, Y> { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, + >; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).__field_StructLike + ) + } } } - } - #[allow(deprecated, non_local_definitions)] + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::pointer::cast::Cast< + ___ZerocopyVariants<'a, N, X, Y>, + core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, + >, + > + for ::zerocopy::pointer::cast::Projection< + ẕ__field_StructLike, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + > {} + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕ5, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(5) }, - > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = [(X, Y); N]; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).5 - ) + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ__field_TupleLike, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_TupleLike) }, + > for ___ZerocopyVariants<'a, { N }, X, Y> { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, + >; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).__field_TupleLike + ) + } } } - } - #[allow(deprecated, non_local_definitions)] + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::pointer::cast::Cast< + ___ZerocopyVariants<'a, N, X, Y>, + core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, + >, + > + for ::zerocopy::pointer::cast::Projection< + ẕ__field_TupleLike, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_TupleLike) }, + > {} + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕ6, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(6) }, - > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = core_reexport::marker::PhantomData< - ComplexWithGenerics<'a, N, X, Y>, - >; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).6 - ) + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ__nonempty, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__nonempty) }, + > for ___ZerocopyVariants<'a, { N }, X, Y> { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = (); + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).__nonempty + ) + } } } - } + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::pointer::cast::Cast< + ___ZerocopyVariants<'a, N, X, Y>, + (), + > + for ::zerocopy::pointer::cast::Projection< + ẕ__nonempty, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__nonempty) }, + > {} + }; }; - }; - #[repr(C)] - #[allow(non_snake_case)] - struct ___ZerocopyVariantStruct_TupleLike< - 'a: 'static, - const N: usize, - X, - Y: Deref, - >( - core_reexport::mem::MaybeUninit<___ZerocopyInnerTag>, - bool, - Y, - PhantomData<&'a [(X, Y); N]>, - core_reexport::marker::PhantomData>, - ) - where - X: Deref; - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - const _: () = { - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] + #[repr(C)] + struct ___ZerocopyRawEnum<'a: 'static, const N: usize, X, Y: Deref> { + tag: ___ZerocopyOuterTag, + variants: ___ZerocopyVariants<'a, N, X, Y>, + } unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, - > ::zerocopy::TryFromBytes - for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + > ::zerocopy::pointer::InvariantsEq<___ZerocopyRawEnum<'a, N, X, Y>> + for ComplexWithGenerics<'a, N, X, Y> where X: Deref, - core_reexport::mem::MaybeUninit< - ___ZerocopyInnerTag, - >: ::zerocopy::TryFromBytes, - bool: ::zerocopy::TryFromBytes, - Y: ::zerocopy::TryFromBytes, - PhantomData<&'a [(X, Y); N]>: ::zerocopy::TryFromBytes, - core_reexport::marker::PhantomData< - ComplexWithGenerics<'a, N, X, Y>, - >: ::zerocopy::TryFromBytes, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - fn is_bit_valid<___ZerocopyAliasing>( - mut candidate: ::zerocopy::Maybe, - ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool - where - ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, - { - true - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(0) }>(); - as ::zerocopy::TryFromBytes>::is_bit_valid(field_candidate) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(1) }>(); - ::is_bit_valid( - field_candidate, - ) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(2) }>(); - ::is_bit_valid( - field_candidate, - ) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(3) }>(); - as ::zerocopy::TryFromBytes>::is_bit_valid(field_candidate) + {} + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + enum ẕtag {} + enum ẕvariants {} + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕtag, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(tag) }, + > for ___ZerocopyRawEnum<'a, { N }, X, Y> { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = ___ZerocopyOuterTag; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).tag + ) + } } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(4) }>(); - , - > as ::zerocopy::TryFromBytes>::is_bit_valid(field_candidate) + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕvariants, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + > for ___ZerocopyRawEnum<'a, { N }, X, Y> { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = ___ZerocopyVariants<'a, N, X, Y>; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).variants + ) + } } - } - } - #[allow(non_camel_case_types)] + } + }; + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] const _: () = { - enum ẕ0 {} - enum ẕ1 {} - enum ẕ2 {} - enum ẕ3 {} - enum ẕ4 {} - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ0, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(0) }, - > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + (), + { ::zerocopy::ident_id!(StructLike) }, + { ::zerocopy::ident_id!(a) }, + > for ComplexWithGenerics<'a, { N }, X, Y> where X: Deref, { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = core_reexport::mem::MaybeUninit<___ZerocopyInnerTag>; + type Type = u8; #[inline(always)] fn project( slf: ::zerocopy::pointer::PtrInner<'_, Self>, ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).0 - ) - } + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(1) }, + >, + >() + .as_ptr() } } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ1, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(1) }, - > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + (), + { ::zerocopy::ident_id!(StructLike) }, + { ::zerocopy::ident_id!(b) }, + > for ComplexWithGenerics<'a, { N }, X, Y> where X: Deref, { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = bool; + type Type = X; #[inline(always)] fn project( slf: ::zerocopy::pointer::PtrInner<'_, Self>, ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).1 - ) - } + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(2) }, + >, + >() + .as_ptr() } } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ2, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(2) }, - > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + (), + { ::zerocopy::ident_id!(StructLike) }, + { ::zerocopy::ident_id!(c) }, + > for ComplexWithGenerics<'a, { N }, X, Y> where X: Deref, { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = Y; + type Type = X::Target; #[inline(always)] fn project( slf: ::zerocopy::pointer::PtrInner<'_, Self>, ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).2 - ) - } + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(3) }, + >, + >() + .as_ptr() } } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ3, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(3) }, - > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + (), + { ::zerocopy::ident_id!(StructLike) }, + { ::zerocopy::ident_id!(d) }, + > for ComplexWithGenerics<'a, { N }, X, Y> where X: Deref, { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = PhantomData<&'a [(X, Y); N]>; + type Type = Y::Target; #[inline(always)] fn project( slf: ::zerocopy::pointer::PtrInner<'_, Self>, ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).3 - ) - } + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(4) }, + >, + >() + .as_ptr() } } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ4, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(4) }, - > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + (), + { ::zerocopy::ident_id!(StructLike) }, + { ::zerocopy::ident_id!(e) }, + > for ComplexWithGenerics<'a, { N }, X, Y> where X: Deref, { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = core_reexport::marker::PhantomData< - ComplexWithGenerics<'a, N, X, Y>, - >; + type Type = [(X, Y); N]; #[inline(always)] fn project( slf: ::zerocopy::pointer::PtrInner<'_, Self>, ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).4 - ) - } + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(5) }, + >, + >() + .as_ptr() } } }; - }; - #[repr(C)] - #[allow(non_snake_case)] - union ___ZerocopyVariants<'a: 'static, const N: usize, X, Y: Deref> { - __field_StructLike: core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, - >, - __field_TupleLike: core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, - >, - __nonempty: (), - } - #[allow(non_camel_case_types)] - const _: () = { - enum ẕ__field_StructLike {} - enum ẕ__field_TupleLike {} - enum ẕ__nonempty {} - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] const _: () = { - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ__field_StructLike, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - > for ___ZerocopyVariants<'a, { N }, X, Y> { + (), + { ::zerocopy::ident_id!(TupleLike) }, + { ::zerocopy::ident_id!(0) }, + > for ComplexWithGenerics<'a, { N }, X, Y> + where + X: Deref, + { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, - >; + type Type = bool; #[inline(always)] fn project( slf: ::zerocopy::pointer::PtrInner<'_, Self>, ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).__field_StructLike - ) - } + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_TupleLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(1) }, + >, + >() + .as_ptr() } } - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::pointer::cast::Cast< - ___ZerocopyVariants<'a, N, X, Y>, - core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, - >, - > - for ::zerocopy::pointer::cast::Projection< - ẕ__field_StructLike, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - > {} }; - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] const _: () = { - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ__field_TupleLike, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_TupleLike) }, - > for ___ZerocopyVariants<'a, { N }, X, Y> { + (), + { ::zerocopy::ident_id!(TupleLike) }, + { ::zerocopy::ident_id!(1) }, + > for ComplexWithGenerics<'a, { N }, X, Y> + where + X: Deref, + { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, - >; + type Type = Y; #[inline(always)] fn project( slf: ::zerocopy::pointer::PtrInner<'_, Self>, ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).__field_TupleLike - ) - } + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_TupleLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(2) }, + >, + >() + .as_ptr() } } - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::pointer::cast::Cast< - ___ZerocopyVariants<'a, N, X, Y>, - core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, - >, - > - for ::zerocopy::pointer::cast::Projection< - ẕ__field_TupleLike, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_TupleLike) }, - > {} }; - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] const _: () = { - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ__nonempty, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__nonempty) }, - > for ___ZerocopyVariants<'a, { N }, X, Y> { + (), + { ::zerocopy::ident_id!(TupleLike) }, + { ::zerocopy::ident_id!(2) }, + > for ComplexWithGenerics<'a, { N }, X, Y> + where + X: Deref, + { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = (); + type Type = PhantomData<&'a [(X, Y); N]>; #[inline(always)] fn project( slf: ::zerocopy::pointer::PtrInner<'_, Self>, ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).__nonempty - ) - } + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_TupleLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(3) }, + >, + >() + .as_ptr() } } - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::pointer::cast::Cast<___ZerocopyVariants<'a, N, X, Y>, ()> - for ::zerocopy::pointer::cast::Projection< - ẕ__nonempty, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__nonempty) }, - > {} }; - }; - #[repr(C)] - struct ___ZerocopyRawEnum<'a: 'static, const N: usize, X, Y: Deref> { - tag: ___ZerocopyOuterTag, - variants: ___ZerocopyVariants<'a, N, X, Y>, + let mut raw_enum = candidate + .cast::< + ___ZerocopyRawEnum<'a, N, X, Y>, + ::zerocopy::pointer::cast::CastSized, + ::zerocopy::pointer::BecauseInvariantsEq, + >(); + let tag = { + let tag_ptr = raw_enum + .reborrow() + .project::<(), { ::zerocopy::ident_id!(tag) }>() + .cast::< + ___ZerocopyTagPrimitive, + ::zerocopy::pointer::cast::CastSized, + _, + >(); + tag_ptr + .recall_validity::<_, (_, (_, _))>() + .read_unaligned::<::zerocopy::BecauseImmutable>() + }; + let variants = raw_enum.project::<_, { ::zerocopy::ident_id!(variants) }>(); + match tag { + ___ZEROCOPY_TAG_UnitLike => true, + ___ZEROCOPY_TAG_StructLike => { + let variant_md = unsafe { + variants + .cast_unchecked::< + core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, + >, + ::zerocopy::pointer::cast::Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + >, + >() + }; + let variant = variant_md + .cast::< + ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, + ::zerocopy::pointer::cast::CastSized, + ::zerocopy::pointer::BecauseInvariantsEq, + >(); + <___ZerocopyVariantStruct_StructLike< + 'a, + N, + X, + Y, + > as ::zerocopy::TryFromBytes>::is_bit_valid(variant) + } + ___ZEROCOPY_TAG_TupleLike => { + let variant_md = unsafe { + variants + .cast_unchecked::< + core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, + >, + ::zerocopy::pointer::cast::Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_TupleLike) }, + >, + >() + }; + let variant = variant_md + .cast::< + ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, + ::zerocopy::pointer::cast::CastSized, + ::zerocopy::pointer::BecauseInvariantsEq, + >(); + <___ZerocopyVariantStruct_TupleLike< + 'a, + N, + X, + Y, + > as ::zerocopy::TryFromBytes>::is_bit_valid(variant) + } + _ => false, + } } - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::pointer::InvariantsEq<___ZerocopyRawEnum<'a, N, X, Y>> - for ComplexWithGenerics<'a, N, X, Y> + } + }; + } no_build + } + + test! { + TryFromBytes { + #[repr(u32)] + enum ComplexWithGenerics<'a: 'static, const N: usize, X, Y: Deref> + where + X: Deref, + { + UnitLike, + StructLike { a: u8, b: X, c: X::Target, d: Y::Target, e: [(X, Y); N] }, + TupleLike(bool, Y, PhantomData<&'a [(X, Y); N]>), + } + } expands to { + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl<'a: 'static, const N: usize, X, Y: Deref> ::zerocopy::TryFromBytes + for ComplexWithGenerics<'a, { N }, X, Y> + where + X: Deref, + u8: ::zerocopy::TryFromBytes, + X: ::zerocopy::TryFromBytes, + X::Target: ::zerocopy::TryFromBytes, + Y::Target: ::zerocopy::TryFromBytes, + [(X, Y); N]: ::zerocopy::TryFromBytes, + bool: ::zerocopy::TryFromBytes, + Y: ::zerocopy::TryFromBytes, + PhantomData<&'a [(X, Y); N]>: ::zerocopy::TryFromBytes, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + fn is_bit_valid<___ZerocopyAliasing>( + candidate: ::zerocopy::Maybe<'_, Self, ___ZerocopyAliasing>, + ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool where - X: Deref, - {} - #[allow(non_camel_case_types)] - const _: () = { - enum ẕtag {} - enum ẕvariants {} - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] + ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, + { + use ::zerocopy::util::macro_util::core_reexport; + #[repr(u32)] + #[allow(dead_code)] + enum ___ZerocopyTag { + UnitLike, + StructLike, + TupleLike, + } + unsafe impl ::zerocopy::Immutable for ___ZerocopyTag { + fn only_derive_is_allowed_to_implement_this_trait() {} + } + type ___ZerocopyTagPrimitive = ::zerocopy::util::macro_util::SizeToTag< + { core_reexport::mem::size_of::<___ZerocopyTag>() }, + >; + const ___ZEROCOPY_TAG_UnitLike: ___ZerocopyTagPrimitive = ___ZerocopyTag::UnitLike + as ___ZerocopyTagPrimitive; + const ___ZEROCOPY_TAG_StructLike: ___ZerocopyTagPrimitive = ___ZerocopyTag::StructLike + as ___ZerocopyTagPrimitive; + const ___ZEROCOPY_TAG_TupleLike: ___ZerocopyTagPrimitive = ___ZerocopyTag::TupleLike + as ___ZerocopyTagPrimitive; + type ___ZerocopyOuterTag = (); + type ___ZerocopyInnerTag = ___ZerocopyTag; unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕtag, + (), { ::zerocopy::STRUCT_VARIANT_ID }, { ::zerocopy::ident_id!(tag) }, - > for ___ZerocopyRawEnum<'a, { N }, X, Y> { + > for ___ZerocopyRawEnum<'a, N, X, Y> { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = ___ZerocopyOuterTag; + type Type = ___ZerocopyTag; #[inline(always)] fn project( slf: ::zerocopy::pointer::PtrInner<'_, Self>, ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).tag - ) - } + slf.as_ptr().cast() } } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< + #[repr(C)] + struct ___ZerocopyVariantStruct_StructLike< 'a: 'static, const N: usize, X, Y: Deref, - > ::zerocopy::HasField< - ẕvariants, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - > for ___ZerocopyRawEnum<'a, { N }, X, Y> { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = ___ZerocopyVariants<'a, N, X, Y>; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).variants - ) + >( + core_reexport::mem::MaybeUninit<___ZerocopyInnerTag>, + u8, + X, + X::Target, + Y::Target, + [(X, Y); N], + core_reexport::marker::PhantomData>, + ) + where + X: Deref; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::TryFromBytes + for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + core_reexport::mem::MaybeUninit< + ___ZerocopyInnerTag, + >: ::zerocopy::TryFromBytes, + u8: ::zerocopy::TryFromBytes, + X: ::zerocopy::TryFromBytes, + X::Target: ::zerocopy::TryFromBytes, + Y::Target: ::zerocopy::TryFromBytes, + [(X, Y); N]: ::zerocopy::TryFromBytes, + core_reexport::marker::PhantomData< + ComplexWithGenerics<'a, N, X, Y>, + >: ::zerocopy::TryFromBytes, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + fn is_bit_valid<___ZerocopyAliasing>( + mut candidate: ::zerocopy::Maybe, + ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool + where + ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, + { + true + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(0) }>(); + as ::zerocopy::TryFromBytes>::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(1) }>(); + ::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(2) }>(); + ::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(3) }>(); + ::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(4) }>(); + ::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(5) }>(); + <[( + X, + Y, + ); N] as ::zerocopy::TryFromBytes>::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(6) }>(); + , + > as ::zerocopy::TryFromBytes>::is_bit_valid( + field_candidate, + ) + } } } - } - }; - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(StructLike) }, - { ::zerocopy::ident_id!(a) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = u8; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - >, - >() - .project::< - _, - Projection< - _, + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + enum ẕ0 {} + enum ẕ1 {} + enum ẕ2 {} + enum ẕ3 {} + enum ẕ4 {} + enum ẕ5 {} + enum ẕ6 {} + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ0, { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, + { ::zerocopy::ident_id!(0) }, + > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = core_reexport::mem::MaybeUninit< + ___ZerocopyInnerTag, + >; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).0 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ1, { ::zerocopy::STRUCT_VARIANT_ID }, { ::zerocopy::ident_id!(1) }, - >, - >() - .as_ptr() - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(StructLike) }, - { ::zerocopy::ident_id!(b) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = X; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, + > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = u8; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).1 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ2, { ::zerocopy::STRUCT_VARIANT_ID }, { ::zerocopy::ident_id!(2) }, - >, - >() - .as_ptr() - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(StructLike) }, - { ::zerocopy::ident_id!(c) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = X::Target; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, + > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = X; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).2 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ3, { ::zerocopy::STRUCT_VARIANT_ID }, { ::zerocopy::ident_id!(3) }, - >, - >() - .as_ptr() - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(StructLike) }, - { ::zerocopy::ident_id!(d) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = Y::Target; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, + > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = X::Target; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).3 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ4, { ::zerocopy::STRUCT_VARIANT_ID }, { ::zerocopy::ident_id!(4) }, - >, - >() - .as_ptr() - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(StructLike) }, - { ::zerocopy::ident_id!(e) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = [(X, Y); N]; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, + > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = Y::Target; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).4 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ5, { ::zerocopy::STRUCT_VARIANT_ID }, { ::zerocopy::ident_id!(5) }, - >, - >() - .as_ptr() - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(TupleLike) }, - { ::zerocopy::ident_id!(0) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = bool; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_TupleLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(1) }, - >, - >() - .as_ptr() - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(TupleLike) }, - { ::zerocopy::ident_id!(1) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = Y; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_TupleLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(2) }, - >, - >() - .as_ptr() - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(TupleLike) }, - { ::zerocopy::ident_id!(2) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = PhantomData<&'a [(X, Y); N]>; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_TupleLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, + > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = [(X, Y); N]; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).5 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ6, { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(3) }, - >, - >() - .as_ptr() - } - } - let mut raw_enum = candidate - .cast::< - ___ZerocopyRawEnum<'a, N, X, Y>, - ::zerocopy::pointer::cast::CastSized, - ::zerocopy::pointer::BecauseInvariantsEq, - >(); - let tag = { - let tag_ptr = raw_enum - .reborrow() - .project::<(), { ::zerocopy::ident_id!(tag) }>() - .cast::< - ___ZerocopyTagPrimitive, - ::zerocopy::pointer::cast::CastSized, - _, - >(); - tag_ptr - .recall_validity::<_, (_, (_, _))>() - .read_unaligned::<::zerocopy::BecauseImmutable>() - }; - let variants = raw_enum.project::<_, { ::zerocopy::ident_id!(variants) }>(); - #[allow(non_upper_case_globals)] - match tag { - ___ZEROCOPY_TAG_UnitLike => true, - ___ZEROCOPY_TAG_StructLike => { - let variant_md = unsafe { - variants - .cast_unchecked::< - core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, - >, - ::zerocopy::pointer::cast::Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - >, - >() - }; - let variant = variant_md - .cast::< - ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, - ::zerocopy::pointer::cast::CastSized, - ::zerocopy::pointer::BecauseInvariantsEq, - >(); - <___ZerocopyVariantStruct_StructLike< - 'a, - N, - X, - Y, - > as ::zerocopy::TryFromBytes>::is_bit_valid(variant) - } - ___ZEROCOPY_TAG_TupleLike => { - let variant_md = unsafe { - variants - .cast_unchecked::< - core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, - >, - ::zerocopy::pointer::cast::Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_TupleLike) }, - >, - >() + { ::zerocopy::ident_id!(6) }, + > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = core_reexport::marker::PhantomData< + ComplexWithGenerics<'a, N, X, Y>, + >; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).6 + ) + } + } + } + }; }; - let variant = variant_md - .cast::< - ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, - ::zerocopy::pointer::cast::CastSized, - ::zerocopy::pointer::BecauseInvariantsEq, - >(); - <___ZerocopyVariantStruct_TupleLike< - 'a, - N, - X, - Y, - > as ::zerocopy::TryFromBytes>::is_bit_valid(variant) - } - _ => false, - } - } - } - } no_build - } - - test! { - TryFromBytes { - #[repr(u32)] - enum ComplexWithGenerics<'a: 'static, const N: usize, X, Y: Deref> - where - X: Deref, - { - UnitLike, - StructLike { a: u8, b: X, c: X::Target, d: Y::Target, e: [(X, Y); N] }, - TupleLike(bool, Y, PhantomData<&'a [(X, Y); N]>), - } - } expands to { - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl<'a: 'static, const N: usize, X, Y: Deref> ::zerocopy::TryFromBytes - for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - u8: ::zerocopy::TryFromBytes, - X: ::zerocopy::TryFromBytes, - X::Target: ::zerocopy::TryFromBytes, - Y::Target: ::zerocopy::TryFromBytes, - [(X, Y); N]: ::zerocopy::TryFromBytes, - bool: ::zerocopy::TryFromBytes, - Y: ::zerocopy::TryFromBytes, - PhantomData<&'a [(X, Y); N]>: ::zerocopy::TryFromBytes, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - fn is_bit_valid<___ZerocopyAliasing>( - candidate: ::zerocopy::Maybe<'_, Self, ___ZerocopyAliasing>, - ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool - where - ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, - { - use ::zerocopy::util::macro_util::core_reexport; - #[repr(u32)] - #[allow(dead_code, non_camel_case_types)] - enum ___ZerocopyTag { - UnitLike, - StructLike, - TupleLike, - } - unsafe impl ::zerocopy::Immutable for ___ZerocopyTag { - fn only_derive_is_allowed_to_implement_this_trait() {} - } - type ___ZerocopyTagPrimitive = ::zerocopy::util::macro_util::SizeToTag< - { core_reexport::mem::size_of::<___ZerocopyTag>() }, - >; - #[allow(non_upper_case_globals)] - const ___ZEROCOPY_TAG_UnitLike: ___ZerocopyTagPrimitive = ___ZerocopyTag::UnitLike - as ___ZerocopyTagPrimitive; - #[allow(non_upper_case_globals)] - const ___ZEROCOPY_TAG_StructLike: ___ZerocopyTagPrimitive = ___ZerocopyTag::StructLike - as ___ZerocopyTagPrimitive; - #[allow(non_upper_case_globals)] - const ___ZEROCOPY_TAG_TupleLike: ___ZerocopyTagPrimitive = ___ZerocopyTag::TupleLike - as ___ZerocopyTagPrimitive; - type ___ZerocopyOuterTag = (); - type ___ZerocopyInnerTag = ___ZerocopyTag; - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(tag) }, - > for ___ZerocopyRawEnum<'a, N, X, Y> { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = ___ZerocopyTag; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - slf.as_ptr().cast() - } - } - #[repr(C)] - #[allow(non_snake_case)] - struct ___ZerocopyVariantStruct_StructLike< - 'a: 'static, - const N: usize, - X, - Y: Deref, - >( - core_reexport::mem::MaybeUninit<___ZerocopyInnerTag>, - u8, - X, - X::Target, - Y::Target, - [(X, Y); N], - core_reexport::marker::PhantomData>, - ) - where - X: Deref; - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - const _: () = { - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< + }; + #[repr(C)] + struct ___ZerocopyVariantStruct_TupleLike< 'a: 'static, const N: usize, X, Y: Deref, - > ::zerocopy::TryFromBytes - for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + >( + core_reexport::mem::MaybeUninit<___ZerocopyInnerTag>, + bool, + Y, + PhantomData<&'a [(X, Y); N]>, + core_reexport::marker::PhantomData>, + ) where - X: Deref, - core_reexport::mem::MaybeUninit< - ___ZerocopyInnerTag, - >: ::zerocopy::TryFromBytes, - u8: ::zerocopy::TryFromBytes, - X: ::zerocopy::TryFromBytes, - X::Target: ::zerocopy::TryFromBytes, - Y::Target: ::zerocopy::TryFromBytes, - [(X, Y); N]: ::zerocopy::TryFromBytes, - core_reexport::marker::PhantomData< - ComplexWithGenerics<'a, N, X, Y>, - >: ::zerocopy::TryFromBytes, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - fn is_bit_valid<___ZerocopyAliasing>( - mut candidate: ::zerocopy::Maybe, - ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool - where - ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, - { - true - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(0) }>(); - as ::zerocopy::TryFromBytes>::is_bit_valid(field_candidate) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(1) }>(); - ::is_bit_valid( - field_candidate, - ) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(2) }>(); - ::is_bit_valid( - field_candidate, - ) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(3) }>(); - ::is_bit_valid( - field_candidate, - ) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(4) }>(); - ::is_bit_valid( - field_candidate, - ) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(5) }>(); - <[( - X, - Y, - ); N] as ::zerocopy::TryFromBytes>::is_bit_valid( - field_candidate, - ) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(6) }>(); - , - > as ::zerocopy::TryFromBytes>::is_bit_valid(field_candidate) - } - } - } - #[allow(non_camel_case_types)] + X: Deref; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] const _: () = { - enum ẕ0 {} - enum ẕ1 {} - enum ẕ2 {} - enum ẕ3 {} - enum ẕ4 {} - enum ẕ5 {} - enum ẕ6 {} - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕ0, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(0) }, - > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = core_reexport::mem::MaybeUninit<___ZerocopyInnerTag>; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).0 - ) - } - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕ1, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(1) }, - > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = u8; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).1 - ) - } - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕ2, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(2) }, - > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = X; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).2 - ) - } - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕ3, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(3) }, - > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = X::Target; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).3 - ) - } - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕ4, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(4) }, - > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = Y::Target; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).4 - ) - } - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕ5, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(5) }, - > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = [(X, Y); N]; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).5 - ) - } - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕ6, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(6) }, - > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = core_reexport::marker::PhantomData< - ComplexWithGenerics<'a, N, X, Y>, - >; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).6 - ) - } - } - } - }; - }; - #[repr(C)] - #[allow(non_snake_case)] - struct ___ZerocopyVariantStruct_TupleLike< - 'a: 'static, - const N: usize, - X, - Y: Deref, - >( - core_reexport::mem::MaybeUninit<___ZerocopyInnerTag>, - bool, - Y, - PhantomData<&'a [(X, Y); N]>, - core_reexport::marker::PhantomData>, - ) - where - X: Deref; - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - const _: () = { - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::TryFromBytes - for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> - where - X: Deref, - core_reexport::mem::MaybeUninit< - ___ZerocopyInnerTag, - >: ::zerocopy::TryFromBytes, - bool: ::zerocopy::TryFromBytes, - Y: ::zerocopy::TryFromBytes, - PhantomData<&'a [(X, Y); N]>: ::zerocopy::TryFromBytes, - core_reexport::marker::PhantomData< - ComplexWithGenerics<'a, N, X, Y>, - >: ::zerocopy::TryFromBytes, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - fn is_bit_valid<___ZerocopyAliasing>( - mut candidate: ::zerocopy::Maybe, - ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool - where - ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, - { - true - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(0) }>(); - as ::zerocopy::TryFromBytes>::is_bit_valid(field_candidate) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(1) }>(); - ::is_bit_valid( - field_candidate, - ) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(2) }>(); - ::is_bit_valid( - field_candidate, - ) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(3) }>(); - as ::zerocopy::TryFromBytes>::is_bit_valid(field_candidate) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(4) }>(); - , - > as ::zerocopy::TryFromBytes>::is_bit_valid(field_candidate) - } - } - } - #[allow(non_camel_case_types)] - const _: () = { - enum ẕ0 {} - enum ẕ1 {} - enum ẕ2 {} - enum ẕ3 {} - enum ẕ4 {} - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕ0, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(0) }, - > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = core_reexport::mem::MaybeUninit<___ZerocopyInnerTag>; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).0 - ) - } - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕ1, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(1) }, - > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = bool; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).1 - ) - } - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕ2, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(2) }, - > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = Y; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).2 - ) - } - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕ3, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(3) }, - > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = PhantomData<&'a [(X, Y); N]>; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).3 - ) - } - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕ4, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(4) }, - > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = core_reexport::marker::PhantomData< - ComplexWithGenerics<'a, N, X, Y>, - >; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).4 - ) - } - } - } - }; - }; - #[repr(C)] - #[allow(non_snake_case)] - union ___ZerocopyVariants<'a: 'static, const N: usize, X, Y: Deref> { - __field_StructLike: core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, - >, - __field_TupleLike: core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, - >, - __nonempty: (), - } - #[allow(non_camel_case_types)] - const _: () = { - enum ẕ__field_StructLike {} - enum ẕ__field_TupleLike {} - enum ẕ__nonempty {} - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - const _: () = { - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕ__field_StructLike, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - > for ___ZerocopyVariants<'a, { N }, X, Y> { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, - >; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).__field_StructLike - ) - } - } - } - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::pointer::cast::Cast< - ___ZerocopyVariants<'a, N, X, Y>, - core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, - >, - > - for ::zerocopy::pointer::cast::Projection< - ẕ__field_StructLike, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - > {} - }; - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - const _: () = { - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕ__field_TupleLike, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_TupleLike) }, - > for ___ZerocopyVariants<'a, { N }, X, Y> { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, - >; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).__field_TupleLike - ) - } - } - } - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::pointer::cast::Cast< - ___ZerocopyVariants<'a, N, X, Y>, - core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, - >, - > - for ::zerocopy::pointer::cast::Projection< - ẕ__field_TupleLike, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_TupleLike) }, - > {} - }; - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - const _: () = { - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕ__nonempty, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__nonempty) }, - > for ___ZerocopyVariants<'a, { N }, X, Y> { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = (); - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).__nonempty - ) - } - } - } - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::pointer::cast::Cast<___ZerocopyVariants<'a, N, X, Y>, ()> - for ::zerocopy::pointer::cast::Projection< - ẕ__nonempty, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__nonempty) }, - > {} - }; - }; - #[repr(C)] - struct ___ZerocopyRawEnum<'a: 'static, const N: usize, X, Y: Deref> { - tag: ___ZerocopyOuterTag, - variants: ___ZerocopyVariants<'a, N, X, Y>, - } - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::pointer::InvariantsEq<___ZerocopyRawEnum<'a, N, X, Y>> - for ComplexWithGenerics<'a, N, X, Y> - where - X: Deref, - {} - #[allow(non_camel_case_types)] - const _: () = { - enum ẕtag {} - enum ẕvariants {} - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕtag, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(tag) }, - > for ___ZerocopyRawEnum<'a, { N }, X, Y> { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = ___ZerocopyOuterTag; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).tag - ) - } - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕvariants, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - > for ___ZerocopyRawEnum<'a, { N }, X, Y> { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = ___ZerocopyVariants<'a, N, X, Y>; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).variants - ) - } - } - } - }; - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(StructLike) }, - { ::zerocopy::ident_id!(a) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = u8; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(1) }, - >, - >() - .as_ptr() - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(StructLike) }, - { ::zerocopy::ident_id!(b) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = X; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(2) }, - >, - >() - .as_ptr() - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(StructLike) }, - { ::zerocopy::ident_id!(c) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = X::Target; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(3) }, - >, - >() - .as_ptr() - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(StructLike) }, - { ::zerocopy::ident_id!(d) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = Y::Target; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(4) }, - >, - >() - .as_ptr() - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(StructLike) }, - { ::zerocopy::ident_id!(e) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = [(X, Y); N]; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(5) }, - >, - >() - .as_ptr() - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(TupleLike) }, - { ::zerocopy::ident_id!(0) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = bool; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_TupleLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(1) }, - >, - >() - .as_ptr() - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(TupleLike) }, - { ::zerocopy::ident_id!(1) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = Y; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_TupleLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(2) }, - >, - >() - .as_ptr() - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(TupleLike) }, - { ::zerocopy::ident_id!(2) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = PhantomData<&'a [(X, Y); N]>; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_TupleLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(3) }, - >, - >() - .as_ptr() - } - } - let mut raw_enum = candidate - .cast::< - ___ZerocopyRawEnum<'a, N, X, Y>, - ::zerocopy::pointer::cast::CastSized, - ::zerocopy::pointer::BecauseInvariantsEq, - >(); - let tag = { - let tag_ptr = raw_enum - .reborrow() - .project::<(), { ::zerocopy::ident_id!(tag) }>() - .cast::< - ___ZerocopyTagPrimitive, - ::zerocopy::pointer::cast::CastSized, - _, - >(); - tag_ptr - .recall_validity::<_, (_, (_, _))>() - .read_unaligned::<::zerocopy::BecauseImmutable>() - }; - let variants = raw_enum.project::<_, { ::zerocopy::ident_id!(variants) }>(); - #[allow(non_upper_case_globals)] - match tag { - ___ZEROCOPY_TAG_UnitLike => true, - ___ZEROCOPY_TAG_StructLike => { - let variant_md = unsafe { - variants - .cast_unchecked::< - core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, - >, - ::zerocopy::pointer::cast::Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - >, - >() - }; - let variant = variant_md - .cast::< - ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, - ::zerocopy::pointer::cast::CastSized, - ::zerocopy::pointer::BecauseInvariantsEq, - >(); - <___ZerocopyVariantStruct_StructLike< - 'a, - N, - X, - Y, - > as ::zerocopy::TryFromBytes>::is_bit_valid(variant) - } - ___ZEROCOPY_TAG_TupleLike => { - let variant_md = unsafe { - variants - .cast_unchecked::< - core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, - >, - ::zerocopy::pointer::cast::Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_TupleLike) }, - >, - >() - }; - let variant = variant_md - .cast::< - ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, - ::zerocopy::pointer::cast::CastSized, - ::zerocopy::pointer::BecauseInvariantsEq, - >(); - <___ZerocopyVariantStruct_TupleLike< - 'a, - N, - X, - Y, - > as ::zerocopy::TryFromBytes>::is_bit_valid(variant) - } - _ => false, - } - } - } - } no_build - } - - test! { - TryFromBytes { - #[repr(C)] - enum ComplexWithGenerics<'a: 'static, const N: usize, X, Y: Deref> - where - X: Deref, - { - UnitLike, - StructLike { a: u8, b: X, c: X::Target, d: Y::Target, e: [(X, Y); N] }, - TupleLike(bool, Y, PhantomData<&'a [(X, Y); N]>), - } - } expands to { - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl<'a: 'static, const N: usize, X, Y: Deref> ::zerocopy::TryFromBytes - for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - u8: ::zerocopy::TryFromBytes, - X: ::zerocopy::TryFromBytes, - X::Target: ::zerocopy::TryFromBytes, - Y::Target: ::zerocopy::TryFromBytes, - [(X, Y); N]: ::zerocopy::TryFromBytes, - bool: ::zerocopy::TryFromBytes, - Y: ::zerocopy::TryFromBytes, - PhantomData<&'a [(X, Y); N]>: ::zerocopy::TryFromBytes, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - fn is_bit_valid<___ZerocopyAliasing>( - candidate: ::zerocopy::Maybe<'_, Self, ___ZerocopyAliasing>, - ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool - where - ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, - { - use ::zerocopy::util::macro_util::core_reexport; - #[repr(C)] - #[allow(dead_code, non_camel_case_types)] - enum ___ZerocopyTag { - UnitLike, - StructLike, - TupleLike, - } - unsafe impl ::zerocopy::Immutable for ___ZerocopyTag { - fn only_derive_is_allowed_to_implement_this_trait() {} - } - type ___ZerocopyTagPrimitive = ::zerocopy::util::macro_util::SizeToTag< - { core_reexport::mem::size_of::<___ZerocopyTag>() }, - >; - #[allow(non_upper_case_globals)] - const ___ZEROCOPY_TAG_UnitLike: ___ZerocopyTagPrimitive = ___ZerocopyTag::UnitLike - as ___ZerocopyTagPrimitive; - #[allow(non_upper_case_globals)] - const ___ZEROCOPY_TAG_StructLike: ___ZerocopyTagPrimitive = ___ZerocopyTag::StructLike - as ___ZerocopyTagPrimitive; - #[allow(non_upper_case_globals)] - const ___ZEROCOPY_TAG_TupleLike: ___ZerocopyTagPrimitive = ___ZerocopyTag::TupleLike - as ___ZerocopyTagPrimitive; - type ___ZerocopyOuterTag = ___ZerocopyTag; - type ___ZerocopyInnerTag = (); - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(tag) }, - > for ___ZerocopyRawEnum<'a, N, X, Y> { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = ___ZerocopyTag; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - slf.as_ptr().cast() - } - } - #[repr(C)] - #[allow(non_snake_case)] - struct ___ZerocopyVariantStruct_StructLike< - 'a: 'static, - const N: usize, - X, - Y: Deref, - >( - core_reexport::mem::MaybeUninit<___ZerocopyInnerTag>, - u8, - X, - X::Target, - Y::Target, - [(X, Y); N], - core_reexport::marker::PhantomData>, - ) - where - X: Deref; - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - const _: () = { - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::TryFromBytes - for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> - where - X: Deref, - core_reexport::mem::MaybeUninit< - ___ZerocopyInnerTag, - >: ::zerocopy::TryFromBytes, - u8: ::zerocopy::TryFromBytes, - X: ::zerocopy::TryFromBytes, - X::Target: ::zerocopy::TryFromBytes, - Y::Target: ::zerocopy::TryFromBytes, - [(X, Y); N]: ::zerocopy::TryFromBytes, - core_reexport::marker::PhantomData< - ComplexWithGenerics<'a, N, X, Y>, - >: ::zerocopy::TryFromBytes, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - fn is_bit_valid<___ZerocopyAliasing>( - mut candidate: ::zerocopy::Maybe, - ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::TryFromBytes + for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> where - ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, + X: Deref, + core_reexport::mem::MaybeUninit< + ___ZerocopyInnerTag, + >: ::zerocopy::TryFromBytes, + bool: ::zerocopy::TryFromBytes, + Y: ::zerocopy::TryFromBytes, + PhantomData<&'a [(X, Y); N]>: ::zerocopy::TryFromBytes, + core_reexport::marker::PhantomData< + ComplexWithGenerics<'a, N, X, Y>, + >: ::zerocopy::TryFromBytes, { - true - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(0) }>(); - ( + mut candidate: ::zerocopy::Maybe, + ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool + where + ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, + { + true + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(0) }>(); + as ::zerocopy::TryFromBytes>::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(1) }>(); + ::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(2) }>(); + ::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(3) }>(); + as ::zerocopy::TryFromBytes>::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(4) }>(); + , + > as ::zerocopy::TryFromBytes>::is_bit_valid( + field_candidate, + ) + } + } + } + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + enum ẕ0 {} + enum ẕ1 {} + enum ẕ2 {} + enum ẕ3 {} + enum ẕ4 {} + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ0, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(0) }, + > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = core_reexport::mem::MaybeUninit< ___ZerocopyInnerTag, - > as ::zerocopy::TryFromBytes>::is_bit_valid(field_candidate) + >; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).0 + ) + } + } } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(1) }>(); - ::is_bit_valid( - field_candidate, - ) + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ1, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(1) }, + > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = bool; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).1 + ) + } + } } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(2) }>(); - ::is_bit_valid( - field_candidate, - ) + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ2, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(2) }, + > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = Y; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).2 + ) + } + } } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(3) }>(); - ::is_bit_valid( - field_candidate, - ) + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ3, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(3) }, + > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = PhantomData<&'a [(X, Y); N]>; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).3 + ) + } + } } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(4) }>(); - ::is_bit_valid( - field_candidate, - ) + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ4, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(4) }, + > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = core_reexport::marker::PhantomData< + ComplexWithGenerics<'a, N, X, Y>, + >; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).4 + ) + } + } } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(5) }>(); - <[( - X, - Y, - ); N] as ::zerocopy::TryFromBytes>::is_bit_valid( - field_candidate, - ) + }; + }; + }; + #[repr(C)] + union ___ZerocopyVariants<'a: 'static, const N: usize, X, Y: Deref> { + __field_StructLike: core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, + >, + __field_TupleLike: core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, + >, + __nonempty: (), + } + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + enum ẕ__field_StructLike {} + enum ẕ__field_TupleLike {} + enum ẕ__nonempty {} + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ__field_StructLike, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + > for ___ZerocopyVariants<'a, { N }, X, Y> { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, + >; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).__field_StructLike + ) + } } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(6) }>(); - , - > as ::zerocopy::TryFromBytes>::is_bit_valid(field_candidate) + } + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::pointer::cast::Cast< + ___ZerocopyVariants<'a, N, X, Y>, + core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, + >, + > + for ::zerocopy::pointer::cast::Projection< + ẕ__field_StructLike, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + > {} + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ__field_TupleLike, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_TupleLike) }, + > for ___ZerocopyVariants<'a, { N }, X, Y> { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, + >; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).__field_TupleLike + ) + } } - } + } + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::pointer::cast::Cast< + ___ZerocopyVariants<'a, N, X, Y>, + core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, + >, + > + for ::zerocopy::pointer::cast::Projection< + ẕ__field_TupleLike, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_TupleLike) }, + > {} + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ__nonempty, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__nonempty) }, + > for ___ZerocopyVariants<'a, { N }, X, Y> { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = (); + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).__nonempty + ) + } + } + } + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::pointer::cast::Cast< + ___ZerocopyVariants<'a, N, X, Y>, + (), + > + for ::zerocopy::pointer::cast::Projection< + ẕ__nonempty, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__nonempty) }, + > {} + }; + }; + #[repr(C)] + struct ___ZerocopyRawEnum<'a: 'static, const N: usize, X, Y: Deref> { + tag: ___ZerocopyOuterTag, + variants: ___ZerocopyVariants<'a, N, X, Y>, } - #[allow(non_camel_case_types)] + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::pointer::InvariantsEq<___ZerocopyRawEnum<'a, N, X, Y>> + for ComplexWithGenerics<'a, N, X, Y> + where + X: Deref, + {} + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] const _: () = { - enum ẕ0 {} - enum ẕ1 {} - enum ẕ2 {} - enum ẕ3 {} - enum ẕ4 {} - enum ẕ5 {} - enum ẕ6 {} - #[allow(deprecated, non_local_definitions)] + enum ẕtag {} + enum ẕvariants {} + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕtag, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(tag) }, + > for ___ZerocopyRawEnum<'a, { N }, X, Y> { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = ___ZerocopyOuterTag; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).tag + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕvariants, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + > for ___ZerocopyRawEnum<'a, { N }, X, Y> { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = ___ZerocopyVariants<'a, N, X, Y>; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).variants + ) + } + } + } + }; + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ0, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(0) }, - > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + (), + { ::zerocopy::ident_id!(StructLike) }, + { ::zerocopy::ident_id!(a) }, + > for ComplexWithGenerics<'a, { N }, X, Y> where X: Deref, { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = core_reexport::mem::MaybeUninit<___ZerocopyInnerTag>; + type Type = u8; #[inline(always)] fn project( slf: ::zerocopy::pointer::PtrInner<'_, Self>, ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).0 - ) - } + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(1) }, + >, + >() + .as_ptr() } } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ1, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(1) }, - > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + (), + { ::zerocopy::ident_id!(StructLike) }, + { ::zerocopy::ident_id!(b) }, + > for ComplexWithGenerics<'a, { N }, X, Y> where X: Deref, { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = u8; + type Type = X; #[inline(always)] fn project( slf: ::zerocopy::pointer::PtrInner<'_, Self>, ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).1 - ) - } + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(2) }, + >, + >() + .as_ptr() } } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ2, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(2) }, - > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + (), + { ::zerocopy::ident_id!(StructLike) }, + { ::zerocopy::ident_id!(c) }, + > for ComplexWithGenerics<'a, { N }, X, Y> where X: Deref, { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = X; + type Type = X::Target; #[inline(always)] fn project( slf: ::zerocopy::pointer::PtrInner<'_, Self>, ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).2 - ) - } + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(3) }, + >, + >() + .as_ptr() } } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ3, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(3) }, - > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + (), + { ::zerocopy::ident_id!(StructLike) }, + { ::zerocopy::ident_id!(d) }, + > for ComplexWithGenerics<'a, { N }, X, Y> where X: Deref, { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = X::Target; + type Type = Y::Target; #[inline(always)] fn project( slf: ::zerocopy::pointer::PtrInner<'_, Self>, ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).3 - ) - } + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(4) }, + >, + >() + .as_ptr() } } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ4, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(4) }, - > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + (), + { ::zerocopy::ident_id!(StructLike) }, + { ::zerocopy::ident_id!(e) }, + > for ComplexWithGenerics<'a, { N }, X, Y> where X: Deref, { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = Y::Target; + type Type = [(X, Y); N]; #[inline(always)] fn project( slf: ::zerocopy::pointer::PtrInner<'_, Self>, ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).4 - ) - } + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(5) }, + >, + >() + .as_ptr() } } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + (), + { ::zerocopy::ident_id!(TupleLike) }, + { ::zerocopy::ident_id!(0) }, + > for ComplexWithGenerics<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = bool; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_TupleLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(1) }, + >, + >() + .as_ptr() + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + (), + { ::zerocopy::ident_id!(TupleLike) }, + { ::zerocopy::ident_id!(1) }, + > for ComplexWithGenerics<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = Y; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_TupleLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(2) }, + >, + >() + .as_ptr() + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ5, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(5) }, - > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + (), + { ::zerocopy::ident_id!(TupleLike) }, + { ::zerocopy::ident_id!(2) }, + > for ComplexWithGenerics<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = PhantomData<&'a [(X, Y); N]>; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_TupleLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(3) }, + >, + >() + .as_ptr() + } + } + }; + let mut raw_enum = candidate + .cast::< + ___ZerocopyRawEnum<'a, N, X, Y>, + ::zerocopy::pointer::cast::CastSized, + ::zerocopy::pointer::BecauseInvariantsEq, + >(); + let tag = { + let tag_ptr = raw_enum + .reborrow() + .project::<(), { ::zerocopy::ident_id!(tag) }>() + .cast::< + ___ZerocopyTagPrimitive, + ::zerocopy::pointer::cast::CastSized, + _, + >(); + tag_ptr + .recall_validity::<_, (_, (_, _))>() + .read_unaligned::<::zerocopy::BecauseImmutable>() + }; + let variants = raw_enum.project::<_, { ::zerocopy::ident_id!(variants) }>(); + match tag { + ___ZEROCOPY_TAG_UnitLike => true, + ___ZEROCOPY_TAG_StructLike => { + let variant_md = unsafe { + variants + .cast_unchecked::< + core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, + >, + ::zerocopy::pointer::cast::Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + >, + >() + }; + let variant = variant_md + .cast::< + ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, + ::zerocopy::pointer::cast::CastSized, + ::zerocopy::pointer::BecauseInvariantsEq, + >(); + <___ZerocopyVariantStruct_StructLike< + 'a, + N, + X, + Y, + > as ::zerocopy::TryFromBytes>::is_bit_valid(variant) + } + ___ZEROCOPY_TAG_TupleLike => { + let variant_md = unsafe { + variants + .cast_unchecked::< + core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, + >, + ::zerocopy::pointer::cast::Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_TupleLike) }, + >, + >() + }; + let variant = variant_md + .cast::< + ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, + ::zerocopy::pointer::cast::CastSized, + ::zerocopy::pointer::BecauseInvariantsEq, + >(); + <___ZerocopyVariantStruct_TupleLike< + 'a, + N, + X, + Y, + > as ::zerocopy::TryFromBytes>::is_bit_valid(variant) + } + _ => false, + } + } + } + }; + + } no_build + } + + test! { + TryFromBytes { + #[repr(C)] + enum ComplexWithGenerics<'a: 'static, const N: usize, X, Y: Deref> + where + X: Deref, + { + UnitLike, + StructLike { a: u8, b: X, c: X::Target, d: Y::Target, e: [(X, Y); N] }, + TupleLike(bool, Y, PhantomData<&'a [(X, Y); N]>), + } + } expands to { + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl<'a: 'static, const N: usize, X, Y: Deref> ::zerocopy::TryFromBytes + for ComplexWithGenerics<'a, { N }, X, Y> + where + X: Deref, + u8: ::zerocopy::TryFromBytes, + X: ::zerocopy::TryFromBytes, + X::Target: ::zerocopy::TryFromBytes, + Y::Target: ::zerocopy::TryFromBytes, + [(X, Y); N]: ::zerocopy::TryFromBytes, + bool: ::zerocopy::TryFromBytes, + Y: ::zerocopy::TryFromBytes, + PhantomData<&'a [(X, Y); N]>: ::zerocopy::TryFromBytes, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + fn is_bit_valid<___ZerocopyAliasing>( + candidate: ::zerocopy::Maybe<'_, Self, ___ZerocopyAliasing>, + ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool + where + ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, + { + use ::zerocopy::util::macro_util::core_reexport; + #[repr(C)] + #[allow(dead_code)] + enum ___ZerocopyTag { + UnitLike, + StructLike, + TupleLike, + } + unsafe impl ::zerocopy::Immutable for ___ZerocopyTag { + fn only_derive_is_allowed_to_implement_this_trait() {} + } + type ___ZerocopyTagPrimitive = ::zerocopy::util::macro_util::SizeToTag< + { core_reexport::mem::size_of::<___ZerocopyTag>() }, + >; + const ___ZEROCOPY_TAG_UnitLike: ___ZerocopyTagPrimitive = ___ZerocopyTag::UnitLike + as ___ZerocopyTagPrimitive; + const ___ZEROCOPY_TAG_StructLike: ___ZerocopyTagPrimitive = ___ZerocopyTag::StructLike + as ___ZerocopyTagPrimitive; + const ___ZEROCOPY_TAG_TupleLike: ___ZerocopyTagPrimitive = ___ZerocopyTag::TupleLike + as ___ZerocopyTagPrimitive; + type ___ZerocopyOuterTag = ___ZerocopyTag; + type ___ZerocopyInnerTag = (); + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + (), + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(tag) }, + > for ___ZerocopyRawEnum<'a, N, X, Y> { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = ___ZerocopyTag; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + slf.as_ptr().cast() + } + } + #[repr(C)] + struct ___ZerocopyVariantStruct_StructLike< + 'a: 'static, + const N: usize, + X, + Y: Deref, + >( + core_reexport::mem::MaybeUninit<___ZerocopyInnerTag>, + u8, + X, + X::Target, + Y::Target, + [(X, Y); N], + core_reexport::marker::PhantomData>, + ) + where + X: Deref; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::TryFromBytes + for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> where X: Deref, + core_reexport::mem::MaybeUninit< + ___ZerocopyInnerTag, + >: ::zerocopy::TryFromBytes, + u8: ::zerocopy::TryFromBytes, + X: ::zerocopy::TryFromBytes, + X::Target: ::zerocopy::TryFromBytes, + Y::Target: ::zerocopy::TryFromBytes, + [(X, Y); N]: ::zerocopy::TryFromBytes, + core_reexport::marker::PhantomData< + ComplexWithGenerics<'a, N, X, Y>, + >: ::zerocopy::TryFromBytes, { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = [(X, Y); N]; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).5 - ) - } + fn is_bit_valid<___ZerocopyAliasing>( + mut candidate: ::zerocopy::Maybe, + ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool + where + ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, + { + true + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(0) }>(); + as ::zerocopy::TryFromBytes>::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(1) }>(); + ::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(2) }>(); + ::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(3) }>(); + ::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(4) }>(); + ::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(5) }>(); + <[( + X, + Y, + ); N] as ::zerocopy::TryFromBytes>::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(6) }>(); + , + > as ::zerocopy::TryFromBytes>::is_bit_valid( + field_candidate, + ) + } } } - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] + const _: () = { + enum ẕ0 {} + enum ẕ1 {} + enum ẕ2 {} + enum ẕ3 {} + enum ẕ4 {} + enum ẕ5 {} + enum ẕ6 {} + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ0, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(0) }, + > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = core_reexport::mem::MaybeUninit< + ___ZerocopyInnerTag, + >; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).0 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ1, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(1) }, + > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = u8; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).1 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ2, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(2) }, + > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = X; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).2 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ3, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(3) }, + > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = X::Target; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).3 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ4, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(4) }, + > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = Y::Target; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).4 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ5, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(5) }, + > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = [(X, Y); N]; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).5 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ6, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(6) }, + > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = core_reexport::marker::PhantomData< + ComplexWithGenerics<'a, N, X, Y>, + >; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).6 + ) + } + } + } + }; + }; + }; + #[repr(C)] + struct ___ZerocopyVariantStruct_TupleLike< + 'a: 'static, + const N: usize, + X, + Y: Deref, + >( + core_reexport::mem::MaybeUninit<___ZerocopyInnerTag>, + bool, + Y, + PhantomData<&'a [(X, Y); N]>, + core_reexport::marker::PhantomData>, + ) + where + X: Deref; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, - > ::zerocopy::HasField< - ẕ6, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(6) }, - > for ___ZerocopyVariantStruct_StructLike<'a, { N }, X, Y> + > ::zerocopy::TryFromBytes + for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> where X: Deref, + core_reexport::mem::MaybeUninit< + ___ZerocopyInnerTag, + >: ::zerocopy::TryFromBytes, + bool: ::zerocopy::TryFromBytes, + Y: ::zerocopy::TryFromBytes, + PhantomData<&'a [(X, Y); N]>: ::zerocopy::TryFromBytes, + core_reexport::marker::PhantomData< + ComplexWithGenerics<'a, N, X, Y>, + >: ::zerocopy::TryFromBytes, { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = core_reexport::marker::PhantomData< - ComplexWithGenerics<'a, N, X, Y>, - >; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).6 - ) - } + fn is_bit_valid<___ZerocopyAliasing>( + mut candidate: ::zerocopy::Maybe, + ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool + where + ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, + { + true + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(0) }>(); + as ::zerocopy::TryFromBytes>::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(1) }>(); + ::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(2) }>(); + ::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(3) }>(); + as ::zerocopy::TryFromBytes>::is_bit_valid( + field_candidate, + ) + } + && { + let field_candidate = candidate + .reborrow() + .project::<_, { ::zerocopy::ident_id!(4) }>(); + , + > as ::zerocopy::TryFromBytes>::is_bit_valid( + field_candidate, + ) + } } } + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + enum ẕ0 {} + enum ẕ1 {} + enum ẕ2 {} + enum ẕ3 {} + enum ẕ4 {} + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ0, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(0) }, + > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = core_reexport::mem::MaybeUninit< + ___ZerocopyInnerTag, + >; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).0 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ1, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(1) }, + > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = bool; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).1 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ2, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(2) }, + > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = Y; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).2 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ3, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(3) }, + > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = PhantomData<&'a [(X, Y); N]>; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).3 + ) + } + } + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ4, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(4) }, + > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + where + X: Deref, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = core_reexport::marker::PhantomData< + ComplexWithGenerics<'a, N, X, Y>, + >; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).4 + ) + } + } + } + }; + }; }; - }; - #[repr(C)] - #[allow(non_snake_case)] - struct ___ZerocopyVariantStruct_TupleLike< - 'a: 'static, - const N: usize, - X, - Y: Deref, - >( - core_reexport::mem::MaybeUninit<___ZerocopyInnerTag>, - bool, - Y, - PhantomData<&'a [(X, Y); N]>, - core_reexport::marker::PhantomData>, - ) - where - X: Deref; - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - const _: () = { - #[allow(deprecated, non_local_definitions)] + #[repr(C)] + union ___ZerocopyVariants<'a: 'static, const N: usize, X, Y: Deref> { + __field_StructLike: core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, + >, + __field_TupleLike: core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, + >, + __nonempty: (), + } + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] + const _: () = { + enum ẕ__field_StructLike {} + enum ẕ__field_TupleLike {} + enum ẕ__nonempty {} + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ__field_StructLike, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + > for ___ZerocopyVariants<'a, { N }, X, Y> { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, + >; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).__field_StructLike + ) + } + } + } + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::pointer::cast::Cast< + ___ZerocopyVariants<'a, N, X, Y>, + core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, + >, + > + for ::zerocopy::pointer::cast::Projection< + ẕ__field_StructLike, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + > {} + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ__field_TupleLike, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_TupleLike) }, + > for ___ZerocopyVariants<'a, { N }, X, Y> { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, + >; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).__field_TupleLike + ) + } + } + } + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::pointer::cast::Cast< + ___ZerocopyVariants<'a, N, X, Y>, + core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, + >, + > + for ::zerocopy::pointer::cast::Projection< + ẕ__field_TupleLike, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_TupleLike) }, + > {} + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕ__nonempty, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__nonempty) }, + > for ___ZerocopyVariants<'a, { N }, X, Y> { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = (); + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).__nonempty + ) + } + } + } + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::pointer::cast::Cast< + ___ZerocopyVariants<'a, N, X, Y>, + (), + > + for ::zerocopy::pointer::cast::Projection< + ẕ__nonempty, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__nonempty) }, + > {} + }; + }; + #[repr(C)] + struct ___ZerocopyRawEnum<'a: 'static, const N: usize, X, Y: Deref> { + tag: ___ZerocopyOuterTag, + variants: ___ZerocopyVariants<'a, N, X, Y>, + } unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, - > ::zerocopy::TryFromBytes - for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + > ::zerocopy::pointer::InvariantsEq<___ZerocopyRawEnum<'a, N, X, Y>> + for ComplexWithGenerics<'a, N, X, Y> where X: Deref, - core_reexport::mem::MaybeUninit< - ___ZerocopyInnerTag, - >: ::zerocopy::TryFromBytes, - bool: ::zerocopy::TryFromBytes, - Y: ::zerocopy::TryFromBytes, - PhantomData<&'a [(X, Y); N]>: ::zerocopy::TryFromBytes, - core_reexport::marker::PhantomData< - ComplexWithGenerics<'a, N, X, Y>, - >: ::zerocopy::TryFromBytes, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - fn is_bit_valid<___ZerocopyAliasing>( - mut candidate: ::zerocopy::Maybe, - ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool - where - ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, - { - true - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(0) }>(); - as ::zerocopy::TryFromBytes>::is_bit_valid(field_candidate) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(1) }>(); - ::is_bit_valid( - field_candidate, - ) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(2) }>(); - ::is_bit_valid( - field_candidate, - ) - } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(3) }>(); - as ::zerocopy::TryFromBytes>::is_bit_valid(field_candidate) + {} + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + enum ẕtag {} + enum ẕvariants {} + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕtag, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(tag) }, + > for ___ZerocopyRawEnum<'a, { N }, X, Y> { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = ___ZerocopyOuterTag; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).tag + ) + } } - && { - let field_candidate = candidate - .reborrow() - .project::<_, { ::zerocopy::ident_id!(4) }>(); - , - > as ::zerocopy::TryFromBytes>::is_bit_valid(field_candidate) + } + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { + unsafe impl< + 'a: 'static, + const N: usize, + X, + Y: Deref, + > ::zerocopy::HasField< + ẕvariants, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + > for ___ZerocopyRawEnum<'a, { N }, X, Y> { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Type = ___ZerocopyVariants<'a, N, X, Y>; + #[inline(always)] + fn project( + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + let slf = slf.as_ptr(); + unsafe { + ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( + (* slf).variants + ) + } } - } - } - #[allow(non_camel_case_types)] + } + }; + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] const _: () = { - enum ẕ0 {} - enum ẕ1 {} - enum ẕ2 {} - enum ẕ3 {} - enum ẕ4 {} - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ0, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(0) }, - > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + (), + { ::zerocopy::ident_id!(StructLike) }, + { ::zerocopy::ident_id!(a) }, + > for ComplexWithGenerics<'a, { N }, X, Y> where X: Deref, { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = core_reexport::mem::MaybeUninit<___ZerocopyInnerTag>; + type Type = u8; #[inline(always)] fn project( slf: ::zerocopy::pointer::PtrInner<'_, Self>, ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).0 - ) - } + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(1) }, + >, + >() + .as_ptr() } } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ1, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(1) }, - > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + (), + { ::zerocopy::ident_id!(StructLike) }, + { ::zerocopy::ident_id!(b) }, + > for ComplexWithGenerics<'a, { N }, X, Y> where X: Deref, { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = bool; + type Type = X; #[inline(always)] fn project( slf: ::zerocopy::pointer::PtrInner<'_, Self>, ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).1 - ) - } + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(2) }, + >, + >() + .as_ptr() } } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ2, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(2) }, - > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + (), + { ::zerocopy::ident_id!(StructLike) }, + { ::zerocopy::ident_id!(c) }, + > for ComplexWithGenerics<'a, { N }, X, Y> where X: Deref, { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = Y; + type Type = X::Target; #[inline(always)] fn project( slf: ::zerocopy::pointer::PtrInner<'_, Self>, ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).2 - ) - } + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(3) }, + >, + >() + .as_ptr() } } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ3, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(3) }, - > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + (), + { ::zerocopy::ident_id!(StructLike) }, + { ::zerocopy::ident_id!(d) }, + > for ComplexWithGenerics<'a, { N }, X, Y> where X: Deref, { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = PhantomData<&'a [(X, Y); N]>; + type Type = Y::Target; #[inline(always)] fn project( slf: ::zerocopy::pointer::PtrInner<'_, Self>, ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).3 - ) - } + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(4) }, + >, + >() + .as_ptr() } } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] + }; + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] + #[automatically_derived] + const _: () = { unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ4, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(4) }, - > for ___ZerocopyVariantStruct_TupleLike<'a, { N }, X, Y> + (), + { ::zerocopy::ident_id!(StructLike) }, + { ::zerocopy::ident_id!(e) }, + > for ComplexWithGenerics<'a, { N }, X, Y> where X: Deref, { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = core_reexport::marker::PhantomData< - ComplexWithGenerics<'a, N, X, Y>, - >; + type Type = [(X, Y); N]; #[inline(always)] fn project( slf: ::zerocopy::pointer::PtrInner<'_, Self>, ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).4 - ) - } + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(5) }, + >, + >() + .as_ptr() } } }; - }; - #[repr(C)] - #[allow(non_snake_case)] - union ___ZerocopyVariants<'a: 'static, const N: usize, X, Y: Deref> { - __field_StructLike: core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, - >, - __field_TupleLike: core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, - >, - __nonempty: (), - } - #[allow(non_camel_case_types)] - const _: () = { - enum ẕ__field_StructLike {} - enum ẕ__field_TupleLike {} - enum ẕ__nonempty {} - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] const _: () = { - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ__field_StructLike, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - > for ___ZerocopyVariants<'a, { N }, X, Y> { + (), + { ::zerocopy::ident_id!(TupleLike) }, + { ::zerocopy::ident_id!(0) }, + > for ComplexWithGenerics<'a, { N }, X, Y> + where + X: Deref, + { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, - >; + type Type = bool; #[inline(always)] fn project( slf: ::zerocopy::pointer::PtrInner<'_, Self>, ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).__field_StructLike - ) - } + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_TupleLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(1) }, + >, + >() + .as_ptr() } } - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::pointer::cast::Cast< - ___ZerocopyVariants<'a, N, X, Y>, - core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, - >, - > - for ::zerocopy::pointer::cast::Projection< - ẕ__field_StructLike, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - > {} }; - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] const _: () = { - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ__field_TupleLike, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_TupleLike) }, - > for ___ZerocopyVariants<'a, { N }, X, Y> { + (), + { ::zerocopy::ident_id!(TupleLike) }, + { ::zerocopy::ident_id!(1) }, + > for ComplexWithGenerics<'a, { N }, X, Y> + where + X: Deref, + { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, - >; + type Type = Y; #[inline(always)] fn project( slf: ::zerocopy::pointer::PtrInner<'_, Self>, ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).__field_TupleLike - ) - } + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_TupleLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(2) }, + >, + >() + .as_ptr() } } - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::pointer::cast::Cast< - ___ZerocopyVariants<'a, N, X, Y>, - core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, - >, - > - for ::zerocopy::pointer::cast::Projection< - ẕ__field_TupleLike, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_TupleLike) }, - > {} }; - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] const _: () = { - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] unsafe impl< 'a: 'static, const N: usize, X, Y: Deref, > ::zerocopy::HasField< - ẕ__nonempty, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__nonempty) }, - > for ___ZerocopyVariants<'a, { N }, X, Y> { + (), + { ::zerocopy::ident_id!(TupleLike) }, + { ::zerocopy::ident_id!(2) }, + > for ComplexWithGenerics<'a, { N }, X, Y> + where + X: Deref, + { fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = (); + type Type = PhantomData<&'a [(X, Y); N]>; #[inline(always)] fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).__nonempty - ) - } - } - } - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::pointer::cast::Cast<___ZerocopyVariants<'a, N, X, Y>, ()> - for ::zerocopy::pointer::cast::Projection< - ẕ__nonempty, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__nonempty) }, - > {} - }; - }; - #[repr(C)] - struct ___ZerocopyRawEnum<'a: 'static, const N: usize, X, Y: Deref> { - tag: ___ZerocopyOuterTag, - variants: ___ZerocopyVariants<'a, N, X, Y>, - } - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::pointer::InvariantsEq<___ZerocopyRawEnum<'a, N, X, Y>> - for ComplexWithGenerics<'a, N, X, Y> - where - X: Deref, - {} - #[allow(non_camel_case_types)] - const _: () = { - enum ẕtag {} - enum ẕvariants {} - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕtag, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(tag) }, - > for ___ZerocopyRawEnum<'a, { N }, X, Y> { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = ___ZerocopyOuterTag; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).tag - ) - } - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - ẕvariants, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - > for ___ZerocopyRawEnum<'a, { N }, X, Y> { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = ___ZerocopyVariants<'a, N, X, Y>; - #[inline(always)] - fn project( - slf: ::zerocopy::pointer::PtrInner<'_, Self>, - ) -> *mut Self::Type { - let slf = slf.as_ptr(); - unsafe { - ::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!( - (* slf).variants - ) + slf: ::zerocopy::pointer::PtrInner<'_, Self>, + ) -> *mut Self::Type { + use ::zerocopy::pointer::cast::{CastSized, Projection}; + slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(variants) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_TupleLike) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(value) }, + >, + >() + .project::< + _, + Projection< + _, + { ::zerocopy::STRUCT_VARIANT_ID }, + { ::zerocopy::ident_id!(3) }, + >, + >() + .as_ptr() } } - } - }; - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(StructLike) }, - { ::zerocopy::ident_id!(a) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = u8; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(1) }, - >, - >() - .as_ptr() - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(StructLike) }, - { ::zerocopy::ident_id!(b) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = X; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(2) }, - >, - >() - .as_ptr() - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(StructLike) }, - { ::zerocopy::ident_id!(c) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = X::Target; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(3) }, - >, - >() - .as_ptr() - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(StructLike) }, - { ::zerocopy::ident_id!(d) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = Y::Target; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(4) }, - >, - >() - .as_ptr() - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(StructLike) }, - { ::zerocopy::ident_id!(e) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = [(X, Y); N]; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(5) }, - >, - >() - .as_ptr() - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(TupleLike) }, - { ::zerocopy::ident_id!(0) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = bool; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_TupleLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(1) }, - >, - >() - .as_ptr() - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(TupleLike) }, - { ::zerocopy::ident_id!(1) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = Y; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_TupleLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(2) }, - >, - >() - .as_ptr() - } - } - #[allow(deprecated, non_local_definitions)] - #[automatically_derived] - unsafe impl< - 'a: 'static, - const N: usize, - X, - Y: Deref, - > ::zerocopy::HasField< - (), - { ::zerocopy::ident_id!(TupleLike) }, - { ::zerocopy::ident_id!(2) }, - > for ComplexWithGenerics<'a, { N }, X, Y> - where - X: Deref, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Type = PhantomData<&'a [(X, Y); N]>; - #[inline(always)] - fn project(slf: ::zerocopy::pointer::PtrInner<'_, Self>) -> *mut Self::Type { - use ::zerocopy::pointer::cast::{CastSized, Projection}; - slf.project::<___ZerocopyRawEnum<'a, N, X, Y>, CastSized>() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(variants) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_TupleLike) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(value) }, - >, - >() - .project::< - _, - Projection< - _, - { ::zerocopy::STRUCT_VARIANT_ID }, - { ::zerocopy::ident_id!(3) }, - >, - >() - .as_ptr() - } - } - let mut raw_enum = candidate - .cast::< - ___ZerocopyRawEnum<'a, N, X, Y>, - ::zerocopy::pointer::cast::CastSized, - ::zerocopy::pointer::BecauseInvariantsEq, - >(); - let tag = { - let tag_ptr = raw_enum - .reborrow() - .project::<(), { ::zerocopy::ident_id!(tag) }>() + }; + let mut raw_enum = candidate .cast::< - ___ZerocopyTagPrimitive, + ___ZerocopyRawEnum<'a, N, X, Y>, ::zerocopy::pointer::cast::CastSized, - _, + ::zerocopy::pointer::BecauseInvariantsEq, >(); - tag_ptr - .recall_validity::<_, (_, (_, _))>() - .read_unaligned::<::zerocopy::BecauseImmutable>() - }; - let variants = raw_enum.project::<_, { ::zerocopy::ident_id!(variants) }>(); - #[allow(non_upper_case_globals)] - match tag { - ___ZEROCOPY_TAG_UnitLike => true, - ___ZEROCOPY_TAG_StructLike => { - let variant_md = unsafe { - variants - .cast_unchecked::< - core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, - >, - ::zerocopy::pointer::cast::Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_StructLike) }, - >, - >() - }; - let variant = variant_md - .cast::< - ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, - ::zerocopy::pointer::cast::CastSized, - ::zerocopy::pointer::BecauseInvariantsEq, - >(); - <___ZerocopyVariantStruct_StructLike< - 'a, - N, - X, - Y, - > as ::zerocopy::TryFromBytes>::is_bit_valid(variant) - } - ___ZEROCOPY_TAG_TupleLike => { - let variant_md = unsafe { - variants - .cast_unchecked::< - core_reexport::mem::ManuallyDrop< - ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, - >, - ::zerocopy::pointer::cast::Projection< - _, - { ::zerocopy::UNION_VARIANT_ID }, - { ::zerocopy::ident_id!(__field_TupleLike) }, - >, - >() - }; - let variant = variant_md + let tag = { + let tag_ptr = raw_enum + .reborrow() + .project::<(), { ::zerocopy::ident_id!(tag) }>() .cast::< - ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, + ___ZerocopyTagPrimitive, ::zerocopy::pointer::cast::CastSized, - ::zerocopy::pointer::BecauseInvariantsEq, + _, >(); - <___ZerocopyVariantStruct_TupleLike< - 'a, - N, - X, - Y, - > as ::zerocopy::TryFromBytes>::is_bit_valid(variant) + tag_ptr + .recall_validity::<_, (_, (_, _))>() + .read_unaligned::<::zerocopy::BecauseImmutable>() + }; + let variants = raw_enum.project::<_, { ::zerocopy::ident_id!(variants) }>(); + match tag { + ___ZEROCOPY_TAG_UnitLike => true, + ___ZEROCOPY_TAG_StructLike => { + let variant_md = unsafe { + variants + .cast_unchecked::< + core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, + >, + ::zerocopy::pointer::cast::Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_StructLike) }, + >, + >() + }; + let variant = variant_md + .cast::< + ___ZerocopyVariantStruct_StructLike<'a, N, X, Y>, + ::zerocopy::pointer::cast::CastSized, + ::zerocopy::pointer::BecauseInvariantsEq, + >(); + <___ZerocopyVariantStruct_StructLike< + 'a, + N, + X, + Y, + > as ::zerocopy::TryFromBytes>::is_bit_valid(variant) + } + ___ZEROCOPY_TAG_TupleLike => { + let variant_md = unsafe { + variants + .cast_unchecked::< + core_reexport::mem::ManuallyDrop< + ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, + >, + ::zerocopy::pointer::cast::Projection< + _, + { ::zerocopy::UNION_VARIANT_ID }, + { ::zerocopy::ident_id!(__field_TupleLike) }, + >, + >() + }; + let variant = variant_md + .cast::< + ___ZerocopyVariantStruct_TupleLike<'a, N, X, Y>, + ::zerocopy::pointer::cast::CastSized, + ::zerocopy::pointer::BecauseInvariantsEq, + >(); + <___ZerocopyVariantStruct_TupleLike< + 'a, + N, + X, + Y, + > as ::zerocopy::TryFromBytes>::is_bit_valid(variant) + } + _ => false, } - _ => false, } } - } + }; } no_build } } @@ -5103,41 +6373,74 @@ fn test_from_bytes_enum() { Variant255, } } expands to { - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::TryFromBytes for Foo { - fn only_derive_is_allowed_to_implement_this_trait() {} + const _: () = { + unsafe impl ::zerocopy::TryFromBytes for Foo { + fn only_derive_is_allowed_to_implement_this_trait() {} - fn is_bit_valid<___ZerocopyAliasing>( - _candidate: ::zerocopy::Maybe, - ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool - where - ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, - { - if false { - fn assert_is_from_bytes() - where - T: ::zerocopy::FromBytes, - T: ?::zerocopy::util::macro_util::core_reexport::marker::Sized, - {} - assert_is_from_bytes::(); - } + fn is_bit_valid<___ZerocopyAliasing>( + _candidate: ::zerocopy::Maybe, + ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool + where + ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, + { + if false { + fn assert_is_from_bytes() + where + T: ::zerocopy::FromBytes, + T: ?::zerocopy::util::macro_util::core_reexport::marker::Sized, + {} + assert_is_from_bytes::(); + } - true + true + } } - } + }; - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::FromZeros for Foo { - fn only_derive_is_allowed_to_implement_this_trait() {} - } + const _: () = { + unsafe impl ::zerocopy::FromZeros for Foo { + fn only_derive_is_allowed_to_implement_this_trait() {} + } + }; - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::FromBytes for Foo { - fn only_derive_is_allowed_to_implement_this_trait() {} - } + const _: () = { + unsafe impl ::zerocopy::FromBytes for Foo { + fn only_derive_is_allowed_to_implement_this_trait() {} + } + }; } no_build } } @@ -5410,20 +6713,31 @@ fn test_try_from_bytes_trivial_is_bit_valid_enum() { Variant255, } } expands to { - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::TryFromBytes for Foo { - fn only_derive_is_allowed_to_implement_this_trait() {} + const _: () = { + unsafe impl ::zerocopy::TryFromBytes for Foo { + fn only_derive_is_allowed_to_implement_this_trait() {} - fn is_bit_valid<___ZerocopyAliasing>( - _candidate: ::zerocopy::Maybe, - ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool - where - ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, - { - true + fn is_bit_valid<___ZerocopyAliasing>( + _candidate: ::zerocopy::Maybe, + ) -> ::zerocopy::util::macro_util::core_reexport::primitive::bool + where + ___ZerocopyAliasing: ::zerocopy::pointer::invariant::Reference, + { + true + } } - } + }; } no_build } } @@ -5434,8 +6748,7 @@ fn test_hash() { ByteHash { struct Foo(T) where Self: Sized; } expands to { - #[allow(deprecated)] - #[automatically_derived] + impl ::zerocopy::util::macro_util::core_reexport::hash::Hash for Foo where Self: ::zerocopy::IntoBytes + ::zerocopy::Immutable, @@ -5471,8 +6784,7 @@ fn test_eq() { ByteEq { struct Foo(T) where Self: Sized; } expands to { - #[allow(deprecated)] - #[automatically_derived] + impl ::zerocopy::util::macro_util::core_reexport::cmp::PartialEq for Foo where Self: ::zerocopy::IntoBytes + ::zerocopy::Immutable, @@ -5486,8 +6798,7 @@ fn test_eq() { } } - #[allow(deprecated)] - #[automatically_derived] + impl ::zerocopy::util::macro_util::core_reexport::cmp::Eq for Foo where Self: ::zerocopy::IntoBytes + ::zerocopy::Immutable, @@ -5505,16 +6816,27 @@ fn test_split_at() { #[repr(C)] struct Foo(T) where Self: Copy; } expands to { - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::SplitAt for Foo - where - Self: Copy, - T: ::zerocopy::SplitAt, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Elem = ::Elem; - } + const _: () = { + unsafe impl ::zerocopy::SplitAt for Foo + where + Self: Copy, + T: ::zerocopy::SplitAt, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Elem = ::Elem; + } + }; } no_build } @@ -5523,16 +6845,27 @@ fn test_split_at() { #[repr(transparent)] struct Foo(T) where Self: Copy; } expands to { - #[allow(deprecated, non_local_definitions)] + #[allow( + deprecated, + private_bounds, + non_local_definitions, + non_camel_case_types, + non_upper_case_globals, + non_snake_case, + non_ascii_idents, + clippy::missing_inline_in_public_items, + )] #[automatically_derived] - unsafe impl ::zerocopy::SplitAt for Foo - where - Self: Copy, - T: ::zerocopy::SplitAt, - { - fn only_derive_is_allowed_to_implement_this_trait() {} - type Elem = ::Elem; - } + const _: () = { + unsafe impl ::zerocopy::SplitAt for Foo + where + Self: Copy, + T: ::zerocopy::SplitAt, + { + fn only_derive_is_allowed_to_implement_this_trait() {} + type Elem = ::Elem; + } + }; } no_build } diff --git a/zerocopy-derive/tests/issue_2880.rs b/zerocopy-derive/tests/issue_2880.rs new file mode 100644 index 0000000000..f713870f14 --- /dev/null +++ b/zerocopy-derive/tests/issue_2880.rs @@ -0,0 +1,289 @@ +// Copyright 2026 The Fuchsia Authors +// +// Licensed under a BSD-style license , Apache License, Version 2.0 +// , or the MIT +// license , at your option. +// This file may not be copied, modified, or distributed except according to +// those terms. + +#![no_implicit_prelude] +#![deny(non_ascii_idents)] +#![allow(dead_code)] + +include!("include.rs"); + +// FIXME(#2880): Derive `FromBytes` in all types once we support non-ASCII +// idents. + +#[derive(imp::KnownLayout, imp::IntoBytes, imp::Immutable)] +#[repr(C)] +struct TestStruct { + a: u8, +} + +#[derive(imp::KnownLayout, imp::IntoBytes, imp::Immutable)] +#[repr(C)] +union TestUnion { + a: u8, +} + +#[derive(imp::KnownLayout, imp::FromBytes, imp::IntoBytes, imp::Immutable)] +#[repr(u8)] +enum FooU8 { + Variant0, + Variant1, + Variant2, + Variant3, + Variant4, + Variant5, + Variant6, + Variant7, + Variant8, + Variant9, + Variant10, + Variant11, + Variant12, + Variant13, + Variant14, + Variant15, + Variant16, + Variant17, + Variant18, + Variant19, + Variant20, + Variant21, + Variant22, + Variant23, + Variant24, + Variant25, + Variant26, + Variant27, + Variant28, + Variant29, + Variant30, + Variant31, + Variant32, + Variant33, + Variant34, + Variant35, + Variant36, + Variant37, + Variant38, + Variant39, + Variant40, + Variant41, + Variant42, + Variant43, + Variant44, + Variant45, + Variant46, + Variant47, + Variant48, + Variant49, + Variant50, + Variant51, + Variant52, + Variant53, + Variant54, + Variant55, + Variant56, + Variant57, + Variant58, + Variant59, + Variant60, + Variant61, + Variant62, + Variant63, + Variant64, + Variant65, + Variant66, + Variant67, + Variant68, + Variant69, + Variant70, + Variant71, + Variant72, + Variant73, + Variant74, + Variant75, + Variant76, + Variant77, + Variant78, + Variant79, + Variant80, + Variant81, + Variant82, + Variant83, + Variant84, + Variant85, + Variant86, + Variant87, + Variant88, + Variant89, + Variant90, + Variant91, + Variant92, + Variant93, + Variant94, + Variant95, + Variant96, + Variant97, + Variant98, + Variant99, + Variant100, + Variant101, + Variant102, + Variant103, + Variant104, + Variant105, + Variant106, + Variant107, + Variant108, + Variant109, + Variant110, + Variant111, + Variant112, + Variant113, + Variant114, + Variant115, + Variant116, + Variant117, + Variant118, + Variant119, + Variant120, + Variant121, + Variant122, + Variant123, + Variant124, + Variant125, + Variant126, + Variant127, + Variant128, + Variant129, + Variant130, + Variant131, + Variant132, + Variant133, + Variant134, + Variant135, + Variant136, + Variant137, + Variant138, + Variant139, + Variant140, + Variant141, + Variant142, + Variant143, + Variant144, + Variant145, + Variant146, + Variant147, + Variant148, + Variant149, + Variant150, + Variant151, + Variant152, + Variant153, + Variant154, + Variant155, + Variant156, + Variant157, + Variant158, + Variant159, + Variant160, + Variant161, + Variant162, + Variant163, + Variant164, + Variant165, + Variant166, + Variant167, + Variant168, + Variant169, + Variant170, + Variant171, + Variant172, + Variant173, + Variant174, + Variant175, + Variant176, + Variant177, + Variant178, + Variant179, + Variant180, + Variant181, + Variant182, + Variant183, + Variant184, + Variant185, + Variant186, + Variant187, + Variant188, + Variant189, + Variant190, + Variant191, + Variant192, + Variant193, + Variant194, + Variant195, + Variant196, + Variant197, + Variant198, + Variant199, + Variant200, + Variant201, + Variant202, + Variant203, + Variant204, + Variant205, + Variant206, + Variant207, + Variant208, + Variant209, + Variant210, + Variant211, + Variant212, + Variant213, + Variant214, + Variant215, + Variant216, + Variant217, + Variant218, + Variant219, + Variant220, + Variant221, + Variant222, + Variant223, + Variant224, + Variant225, + Variant226, + Variant227, + Variant228, + Variant229, + Variant230, + Variant231, + Variant232, + Variant233, + Variant234, + Variant235, + Variant236, + Variant237, + Variant238, + Variant239, + Variant240, + Variant241, + Variant242, + Variant243, + Variant244, + Variant245, + Variant246, + Variant247, + Variant248, + Variant249, + Variant250, + Variant251, + Variant252, + Variant253, + Variant254, + Variant255, +} diff --git a/zerocopy-derive/tests/ui-nightly/late_compile_pass.stderr b/zerocopy-derive/tests/ui-nightly/late_compile_pass.stderr index f06f374f7b..ace5bad366 100644 --- a/zerocopy-derive/tests/ui-nightly/late_compile_pass.stderr +++ b/zerocopy-derive/tests/ui-nightly/late_compile_pass.stderr @@ -323,7 +323,7 @@ note: required for `FromBytes1` to implement `zerocopy::FromBytes` | 47 | #[derive(FromBytes)] | ^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro -note: required by a bound in `_::::is_bit_valid::assert_is_from_bytes` +note: required by a bound in `_::_::::is_bit_valid::assert_is_from_bytes` --> tests/ui-nightly/late_compile_pass.rs:47:10 | 47 | #[derive(FromBytes)] diff --git a/zerocopy-derive/tests/ui-nightly/privacy.stderr b/zerocopy-derive/tests/ui-nightly/privacy.stderr index b67d4be385..eeb765f902 100644 --- a/zerocopy-derive/tests/ui-nightly/privacy.stderr +++ b/zerocopy-derive/tests/ui-nightly/privacy.stderr @@ -1,16 +1,16 @@ -error: type `private::_::_::ẕb` is private +error: type `private::_::_::_::ẕb` is private --> tests/ui-nightly/privacy.rs:76:57 | 76 | let _: >::Type = | ^ private type -error: type `private::_::_::ẕ1` is private +error: type `private::_::_::_::ẕ1` is private --> tests/ui-nightly/privacy.rs:83:56 | 83 | let _: >::Type = | ^ private type -error: type `private::_::_::ẕb` is private +error: type `private::_::_::_::ẕb` is private --> tests/ui-nightly/privacy.rs:89:41 | 89 | let _: >::Type = 0u16; diff --git a/zerocopy-derive/tests/ui-stable/late_compile_pass.stderr b/zerocopy-derive/tests/ui-stable/late_compile_pass.stderr index 4bd2390ac5..5138c9e73e 100644 --- a/zerocopy-derive/tests/ui-stable/late_compile_pass.stderr +++ b/zerocopy-derive/tests/ui-stable/late_compile_pass.stderr @@ -283,7 +283,7 @@ note: required for `FromBytes1` to implement `zerocopy::FromBytes` | 47 | #[derive(FromBytes)] | ^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro -note: required by a bound in `_::::is_bit_valid::assert_is_from_bytes` +note: required by a bound in `_::_::::is_bit_valid::assert_is_from_bytes` --> tests/ui-stable/late_compile_pass.rs:47:10 | 47 | #[derive(FromBytes)] diff --git a/zerocopy-derive/tests/ui-stable/privacy.stderr b/zerocopy-derive/tests/ui-stable/privacy.stderr index 862a970e3e..4635e1913c 100644 --- a/zerocopy-derive/tests/ui-stable/privacy.stderr +++ b/zerocopy-derive/tests/ui-stable/privacy.stderr @@ -1,16 +1,16 @@ -error: type `private::_::_::ẕb` is private +error: type `private::_::_::_::ẕb` is private --> tests/ui-stable/privacy.rs:76:57 | 76 | let _: >::Type = | ^ private type -error: type `private::_::_::ẕ1` is private +error: type `private::_::_::_::ẕ1` is private --> tests/ui-stable/privacy.rs:83:56 | 83 | let _: >::Type = | ^ private type -error: type `private::_::_::ẕb` is private +error: type `private::_::_::_::ẕb` is private --> tests/ui-stable/privacy.rs:89:41 | 89 | let _: >::Type = 0u16;