Skip to content

Commit 4d4106b

Browse files
committed
fix deriving CheckedBitPattern on packed struct
When a field in a packed struct is not sufficiently aligned, it's illegal to create a reference to it. Consequently, our Debug implementation should not create references. This does not affect enums because enums can't be packed. Fixes: 5f9ce73
1 parent 621848f commit 4d4106b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

derive/src/traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ fn generate_checked_bit_pattern_struct(
623623
impl ::core::fmt::Debug for #bits_ty {
624624
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
625625
let mut debug_struct = ::core::fmt::Formatter::debug_struct(f, ::core::stringify!(#bits_ty));
626-
#(::core::fmt::DebugStruct::field(&mut debug_struct, ::core::stringify!(#field_name), &self.#field_name);)*
626+
#(::core::fmt::DebugStruct::field(&mut debug_struct, ::core::stringify!(#field_name), &{ self.#field_name });)*
627627
::core::fmt::DebugStruct::finish(&mut debug_struct)
628628
}
629629
}

0 commit comments

Comments
 (0)