Skip to content

Commit

Permalink
[derive] Test TryFromBytes output on dataful enums (#1665)
Browse files Browse the repository at this point in the history
Makes progress on #367, #1634
  • Loading branch information
joshlf committed Sep 17, 2024
1 parent 6e78c01 commit 3c9f204
Show file tree
Hide file tree
Showing 3 changed files with 389 additions and 8 deletions.
8 changes: 4 additions & 4 deletions zerocopy-derive/src/enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub(crate) fn generate_tag_enum(repr: &EnumRepr, data: &DataEnum) -> TokenStream
#[repr(#repr)]
#[allow(dead_code)]
enum ___ZerocopyTag {
#(#variants),*
#(#variants,)*
}
}
}
Expand Down Expand Up @@ -305,9 +305,9 @@ pub(crate) fn derive_is_bit_valid(

#tag_enum

type ___ZerocopyTagPrimitive = ::zerocopy::util::macro_util::SizeToTag<{
core_reexport::mem::size_of::<___ZerocopyTag>()
}>;
type ___ZerocopyTagPrimitive = ::zerocopy::util::macro_util::SizeToTag<
{ core_reexport::mem::size_of::<___ZerocopyTag>() },
>;

#tag_consts

Expand Down
2 changes: 1 addition & 1 deletion zerocopy-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ fn derive_try_from_bytes_struct(ast: &DeriveInput, strct: &DataStruct) -> proc_m
// validities of its fields, so this is a sound implementation of
// `is_bit_valid`.
fn is_bit_valid<A: ::zerocopy::pointer::invariant::Aliasing + ::zerocopy::pointer::invariant::AtLeast<::zerocopy::pointer::invariant::Shared> >(
mut candidate: ::zerocopy::Maybe<Self, A>
mut candidate: ::zerocopy::Maybe<Self, A>,
) -> bool {
true #(&& {
// SAFETY:
Expand Down
Loading

0 comments on commit 3c9f204

Please sign in to comment.