Skip to content

Commit

Permalink
fix: Process static assert error string in the macro
Browse files Browse the repository at this point in the history
Hopefully this makes us continue to support 1.81 and current stable (1.83) versions of Rust
  • Loading branch information
GrayJack committed Jan 22, 2025
1 parent 25b9146 commit bd39472
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bitflags-attr-macros/src/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,12 +568,18 @@ impl ToTokens for Bitflag {
});

let pod_impl = (cfg!(feature = "bytemuck") && *impl_pod).then(|| {
let error_str = LitStr::new(
&format!(
"`bitflag` error: type `{name}` not compatible with the `bytemuck::Pod` trait."
),
name.span(),
);
quote! {
/// Extra static check for the Pod implementation
#[doc(hidden)]
const _: () = {
if ::core::mem::size_of::<#name>() != ::core::mem::size_of::<#inner_ty>() {
::core::panic!("`bitflag` error: type `{}` not compatible with the `bytemuck::Pod` trait.", ::core::stringify!(#name));
::core::panic!(#error_str);
}
};
#[automatically_derived]
Expand Down

0 comments on commit bd39472

Please sign in to comment.