Merge rust-bitcoin/rust-bitcoin#3537: Fix macro feature gate

bafe11d7e4 Correctly feature gate impl_to_hex_from_lower_hex (Tobin C. Harding)
57769f5f28 Fix ugly rustfmt (Tobin C. Harding)

Pull request description:

  Fix macro feature gating.

  - Patch 1 is preparatory fixes to bot introduced formatting changes
  - Patch 2 is the macro fix

  Close: #3152

ACKs for top commit:
  apoelstra:
    ACK bafe11d7e492b12abaac305bda182cd6f820c558; successfully ran local tests

Tree-SHA512: 98709f362ad28c91d6e374ac5e6a8bed54de6b25df841b479732bccaf70d6bbf23be89522fd58cafca62dcf0cff9dbfdc35ff9a12225bb63beb79c55992378f4
This commit is contained in:
merge-script 2024-10-31 19:57:09 +00:00
commit d32bb20e6b
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
4 changed files with 12 additions and 15 deletions

View File

@ -219,7 +219,6 @@ macro_rules! impl_to_hex_from_lower_hex {
($t:ident, $hex_len_fn:expr) => {
impl $t {
/// Gets the hex representation of this type
#[cfg(feature = "alloc")]
pub fn to_hex(&self) -> alloc::string::String {
use core::fmt::Write;

View File

@ -4,8 +4,6 @@
use core::fmt;
use internals::impl_to_hex_from_lower_hex;
/// Encoding of 256-bit target as 32-bit float.
///
/// This is used to encode a target into the block header. Satoshi made this part of consensus code
@ -36,11 +34,10 @@ impl fmt::LowerHex for CompactTarget {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(&self.0, f) }
}
impl_to_hex_from_lower_hex!(CompactTarget, |compact_target: &CompactTarget| 8 - compact_target
.0
.leading_zeros()
as usize
/ 4);
#[cfg(feature = "alloc")]
internals::impl_to_hex_from_lower_hex!(CompactTarget, |compact_target: &CompactTarget| {
8 - compact_target.0.leading_zeros() as usize / 4
});
impl fmt::UpperHex for CompactTarget {
#[inline]

View File

@ -12,7 +12,6 @@ use core::fmt;
use core::ops::{Deref, DerefMut};
use hex::DisplayHex;
use internals::impl_to_hex_from_lower_hex;
use internals::script::{self, PushDataLenLen};
use crate::opcodes::all::*;
@ -231,13 +230,15 @@ impl fmt::LowerHex for Script {
fmt::LowerHex::fmt(&self.as_bytes().as_hex(), f)
}
}
impl_to_hex_from_lower_hex!(Script, |script: &Script| script.len() * 2);
#[cfg(feature = "alloc")]
internals::impl_to_hex_from_lower_hex!(Script, |script: &Script| script.len() * 2);
impl fmt::LowerHex for ScriptBuf {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(self.as_script(), f) }
}
impl_to_hex_from_lower_hex!(ScriptBuf, |script_buf: &ScriptBuf| script_buf.len() * 2);
#[cfg(feature = "alloc")]
internals::impl_to_hex_from_lower_hex!(ScriptBuf, |script_buf: &ScriptBuf| script_buf.len() * 2);
impl fmt::UpperHex for Script {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

View File

@ -19,7 +19,6 @@ use core::fmt;
#[cfg(feature = "arbitrary")]
use arbitrary::{Arbitrary, Unstructured};
use internals::impl_to_hex_from_lower_hex;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[cfg(feature = "alloc")]
@ -231,9 +230,10 @@ impl fmt::Display for Sequence {
impl fmt::LowerHex for Sequence {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(&self.0, f) }
}
impl_to_hex_from_lower_hex!(Sequence, |sequence: &Sequence| 8 - sequence.0.leading_zeros()
as usize
/ 4);
#[cfg(feature = "alloc")]
internals::impl_to_hex_from_lower_hex!(Sequence, |sequence: &Sequence| {
8 - sequence.0.leading_zeros() as usize / 4
});
impl fmt::UpperHex for Sequence {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::UpperHex::fmt(&self.0, f) }