diff --git a/src/blockdata/script.rs b/src/blockdata/script.rs index a9b32fcd..e0a46315 100644 --- a/src/blockdata/script.rs +++ b/src/blockdata/script.rs @@ -657,7 +657,7 @@ impl Script { pub fn bytes_to_asm_fmt(script: &[u8], f: &mut dyn fmt::Write) -> fmt::Result { // This has to be a macro because it needs to break the loop macro_rules! read_push_data_len { - ($iter:expr, $len:expr, $formatter:expr) => { + ($iter:expr, $len:literal, $formatter:expr) => { match read_uint_iter($iter, $len) { Ok(n) => { n diff --git a/src/consensus/encode.rs b/src/consensus/encode.rs index 97043e5d..b2316a96 100644 --- a/src/consensus/encode.rs +++ b/src/consensus/encode.rs @@ -547,7 +547,7 @@ impl Decodable for Cow<'static, str> { // Arrays macro_rules! impl_array { - ( $size:expr ) => { + ( $size:literal ) => { impl Encodable for [u8; $size] { #[inline] fn consensus_encode(&self, w: &mut W) -> Result { diff --git a/src/internal_macros.rs b/src/internal_macros.rs index 12fc77a2..b71515d3 100644 --- a/src/internal_macros.rs +++ b/src/internal_macros.rs @@ -58,7 +58,7 @@ macro_rules! impl_consensus_encoding { /// Implements standard array methods for a given wrapper type macro_rules! impl_array_newtype { - ($thing:ident, $ty:ty, $len:expr) => { + ($thing:ident, $ty:ty, $len:literal) => { impl $thing { /// Converts the object to a raw pointer #[inline] @@ -138,7 +138,7 @@ macro_rules! hex_hash (($h:ident, $s:expr) => ($h::from_slice(&<$crate::prelude: macro_rules! hex_decode (($h:ident, $s:expr) => (deserialize::<$h>(&<$crate::prelude::Vec as $crate::hashes::hex::FromHex>::from_hex($s).unwrap()).unwrap())); macro_rules! serde_string_impl { - ($name:ident, $expecting:expr) => { + ($name:ident, $expecting:literal) => { #[cfg(feature = "serde")] #[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl<'de> $crate::serde::Deserialize<'de> for $name { @@ -185,7 +185,7 @@ macro_rules! serde_string_impl { /// A combination macro where the human-readable serialization is done like /// serde_string_impl and the non-human-readable impl is done as a struct. macro_rules! serde_struct_human_string_impl { - ($name:ident, $expecting:expr, $($fe:ident),*) => ( + ($name:ident, $expecting:literal, $($fe:ident),*) => ( #[cfg(feature = "serde")] #[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl<'de> $crate::serde::Deserialize<'de> for $name { @@ -363,7 +363,7 @@ macro_rules! serde_struct_human_string_impl { /// - core::str::FromStr /// - hashes::hex::FromHex macro_rules! impl_bytes_newtype { - ($t:ident, $len:expr) => ( + ($t:ident, $len:literal) => ( impl ::core::fmt::LowerHex for $t { fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { @@ -494,7 +494,7 @@ macro_rules! user_enum { $(#[$attr:meta])* pub enum $name:ident { $(#[$doc:meta] - $elem:ident <-> $txt:expr),* + $elem:ident <-> $txt:literal),* } ) => ( $(#[$attr])* diff --git a/src/util/address.rs b/src/util/address.rs index f7df48f2..f7be7f9a 100644 --- a/src/util/address.rs +++ b/src/util/address.rs @@ -1019,11 +1019,11 @@ mod tests { use super::*; - macro_rules! hex (($hex:expr) => (Vec::from_hex($hex).unwrap())); - macro_rules! hex_key (($hex:expr) => (PublicKey::from_slice(&hex!($hex)).unwrap())); - macro_rules! hex_script (($hex:expr) => (Script::from(hex!($hex)))); - macro_rules! hex_pubkeyhash (($hex:expr) => (PubkeyHash::from_hex(&$hex).unwrap())); - macro_rules! hex_scripthash (($hex:expr) => (ScriptHash::from_hex($hex).unwrap())); + macro_rules! hex (($hex:literal) => (Vec::from_hex($hex).unwrap())); + macro_rules! hex_key (($hex:literal) => (PublicKey::from_slice(&hex!($hex)).unwrap())); + macro_rules! hex_script (($hex:literal) => (Script::from(hex!($hex)))); + macro_rules! hex_pubkeyhash (($hex:literal) => (PubkeyHash::from_hex(&$hex).unwrap())); + macro_rules! hex_scripthash (($hex:literal) => (ScriptHash::from_hex($hex).unwrap())); fn roundtrips(addr: &Address) { assert_eq!( diff --git a/src/util/amount.rs b/src/util/amount.rs index ce7757c6..1397abb4 100644 --- a/src/util/amount.rs +++ b/src/util/amount.rs @@ -1678,7 +1678,7 @@ mod tests { // Creates individual test functions to make it easier to find which check failed. macro_rules! check_format_non_negative { - ($denom:ident; $($test_name:ident, $val:expr, $format_string:expr, $expected:expr);* $(;)?) => { + ($denom:ident; $($test_name:ident, $val:literal, $format_string:literal, $expected:literal);* $(;)?) => { $( #[test] fn $test_name() { @@ -1690,7 +1690,7 @@ mod tests { } macro_rules! check_format_non_negative_show_denom { - ($denom:ident, $denom_suffix:expr; $($test_name:ident, $val:expr, $format_string:expr, $expected:expr);* $(;)?) => { + ($denom:ident, $denom_suffix:literal; $($test_name:ident, $val:literal, $format_string:literal, $expected:literal);* $(;)?) => { $( #[test] fn $test_name() { diff --git a/src/util/uint.rs b/src/util/uint.rs index ca9e4ed3..dd56aaa0 100644 --- a/src/util/uint.rs +++ b/src/util/uint.rs @@ -19,7 +19,7 @@ //! macro_rules! construct_uint { - ($name:ident, $n_words:expr) => { + ($name:ident, $n_words:literal) => { /// Little-endian large integer type #[derive(Copy, Clone, PartialEq, Eq, Hash, Default)] pub struct $name(pub [u64; $n_words]);