From 514cc5500f47d78e3b708a6a6a9c7aeea37d1728 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 4 Sep 2024 16:00:31 +1000 Subject: [PATCH] internals: Fix lint warnings on macro The new `impl_to_hex_from_lower_hex` macro causes build warnings when `internals` is built without the `alloc` feature. There are two macro implementations depending on feature gates, improve the docs and duplicate them ont both macro definitions. --- internals/src/macros.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internals/src/macros.rs b/internals/src/macros.rs index cdee1ab69..8c0ca1a51 100644 --- a/internals/src/macros.rs +++ b/internals/src/macros.rs @@ -205,7 +205,10 @@ macro_rules! impl_from_infallible { } } -/// Implements `to_hex` for functions that have implemented [`core::fmt::LowerHex`] +/// Adds an implementation of `pub fn to_hex(&self) -> String` if `alloc` feature is enabled. +/// +/// The added function allocates a `String` then calls through to [`core::fmt::LowerHex`]. +/// Calling this macro without the `alloc` feature enabled is a noop. #[macro_export] #[cfg(feature = "alloc")] macro_rules! impl_to_hex_from_lower_hex { @@ -224,6 +227,10 @@ macro_rules! impl_to_hex_from_lower_hex { }; } +/// Adds an implementation of `pub fn to_hex(&self) -> String` if `alloc` feature is enabled. +/// +/// The added function allocates a `String` then calls through to [`core::fmt::LowerHex`]. +/// Calling this macro without the `alloc` feature enabled is a noop. #[macro_export] #[cfg(not(feature = "alloc"))] macro_rules! impl_to_hex_from_lower_hex {