From bd39472de7f95ac01c5d7f03ca6d287d04d46718 Mon Sep 17 00:00:00 2001 From: GrayJack Date: Tue, 21 Jan 2025 22:31:21 -0300 Subject: [PATCH] fix: Process static assert error string in the macro Hopefully this makes us continue to support 1.81 and current stable (1.83) versions of Rust --- bitflags-attr-macros/src/typed.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bitflags-attr-macros/src/typed.rs b/bitflags-attr-macros/src/typed.rs index 6bf6ea67..52e9401d 100644 --- a/bitflags-attr-macros/src/typed.rs +++ b/bitflags-attr-macros/src/typed.rs @@ -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]