Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for impl mode structs to be repr(packed) #388

Merged
merged 2 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ macro_rules! __impl_public_bitflags_ops {
&self,
f: &mut $crate::__private::core::fmt::Formatter,
) -> $crate::__private::core::fmt::Result {
$crate::__private::core::fmt::Binary::fmt(&self.0, f)
let inner = self.0;
$crate::__private::core::fmt::Binary::fmt(&inner, f)
}
}

Expand All @@ -330,7 +331,8 @@ macro_rules! __impl_public_bitflags_ops {
&self,
f: &mut $crate::__private::core::fmt::Formatter,
) -> $crate::__private::core::fmt::Result {
$crate::__private::core::fmt::Octal::fmt(&self.0, f)
let inner = self.0;
$crate::__private::core::fmt::Octal::fmt(&inner, f)
}
}

Expand All @@ -339,7 +341,8 @@ macro_rules! __impl_public_bitflags_ops {
&self,
f: &mut $crate::__private::core::fmt::Formatter,
) -> $crate::__private::core::fmt::Result {
$crate::__private::core::fmt::LowerHex::fmt(&self.0, f)
let inner = self.0;
$crate::__private::core::fmt::LowerHex::fmt(&inner, f)
}
}

Expand All @@ -348,7 +351,8 @@ macro_rules! __impl_public_bitflags_ops {
&self,
f: &mut $crate::__private::core::fmt::Formatter,
) -> $crate::__private::core::fmt::Result {
$crate::__private::core::fmt::UpperHex::fmt(&self.0, f)
let inner = self.0;
$crate::__private::core::fmt::UpperHex::fmt(&inner, f)
}
}

Expand Down
13 changes: 13 additions & 0 deletions tests/compile-pass/bitflags_impl_repr_packed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
extern crate bitflags;

#[repr(packed)]
struct Example(u64);

bitflags::bitflags! {
impl Example: u64 {
const FLAG_1 = 0b01;
const FLAG_2 = 0b10;
}
}

fn main() {}