diff --git a/bitcoin/src/internal_macros.rs b/bitcoin/src/internal_macros.rs index 62b67aa3..875a2a6f 100644 --- a/bitcoin/src/internal_macros.rs +++ b/bitcoin/src/internal_macros.rs @@ -12,7 +12,7 @@ macro_rules! impl_consensus_encoding { fn consensus_encode( &self, r: &mut R, - ) -> Result { + ) -> core::result::Result { let mut len = 0; $(len += self.$field.consensus_encode(r)?;)+ Ok(len) @@ -24,7 +24,7 @@ macro_rules! impl_consensus_encoding { #[inline] fn consensus_decode_from_finite_reader( r: &mut R, - ) -> Result<$thing, $crate::consensus::encode::Error> { + ) -> core::result::Result<$thing, $crate::consensus::encode::Error> { Ok($thing { $($field: $crate::consensus::Decodable::consensus_decode_from_finite_reader(r)?),+ }) @@ -33,7 +33,7 @@ macro_rules! impl_consensus_encoding { #[inline] fn consensus_decode( r: &mut R, - ) -> Result<$thing, $crate::consensus::encode::Error> { + ) -> core::result::Result<$thing, $crate::consensus::encode::Error> { let mut r = r.take($crate::consensus::encode::MAX_VEC_SIZE as u64); Ok($thing { $($field: $crate::consensus::Decodable::consensus_decode(&mut r)?),+ @@ -99,9 +99,9 @@ macro_rules! impl_bytes_newtype { impl $crate::hex::FromHex for $t { type Err = $crate::hex::HexToArrayError; - fn from_byte_iter(iter: I) -> Result + fn from_byte_iter(iter: I) -> core::result::Result where - I: core::iter::Iterator> + I: core::iter::Iterator> + core::iter::ExactSizeIterator + core::iter::DoubleEndedIterator, { @@ -111,12 +111,12 @@ macro_rules! impl_bytes_newtype { impl core::str::FromStr for $t { type Err = $crate::hex::HexToArrayError; - fn from_str(s: &str) -> Result { $crate::hex::FromHex::from_hex(s) } + fn from_str(s: &str) -> core::result::Result { $crate::hex::FromHex::from_hex(s) } } #[cfg(feature = "serde")] impl $crate::serde::Serialize for $t { - fn serialize(&self, s: S) -> Result { + fn serialize(&self, s: S) -> core::result::Result { if s.is_human_readable() { s.collect_str(self) } else { @@ -127,7 +127,7 @@ macro_rules! impl_bytes_newtype { #[cfg(feature = "serde")] impl<'de> $crate::serde::Deserialize<'de> for $t { - fn deserialize>(d: D) -> Result<$t, D::Error> { + fn deserialize>(d: D) -> core::result::Result<$t, D::Error> { if d.is_human_readable() { struct HexVisitor; @@ -138,7 +138,7 @@ macro_rules! impl_bytes_newtype { f.write_str("an ASCII hex string") } - fn visit_bytes(self, v: &[u8]) -> Result + fn visit_bytes(self, v: &[u8]) -> core::result::Result where E: $crate::serde::de::Error, { @@ -151,7 +151,7 @@ macro_rules! impl_bytes_newtype { } } - fn visit_str(self, v: &str) -> Result + fn visit_str(self, v: &str) -> core::result::Result where E: $crate::serde::de::Error, { @@ -170,7 +170,7 @@ macro_rules! impl_bytes_newtype { f.write_str("a bytestring") } - fn visit_bytes(self, v: &[u8]) -> Result + fn visit_bytes(self, v: &[u8]) -> core::result::Result where E: $crate::serde::de::Error, { @@ -196,13 +196,13 @@ pub(crate) use impl_bytes_newtype; macro_rules! impl_hashencode { ($hashtype:ident) => { impl $crate::consensus::Encodable for $hashtype { - fn consensus_encode(&self, w: &mut W) -> Result { + fn consensus_encode(&self, w: &mut W) -> core::result::Result { self.0.consensus_encode(w) } } impl $crate::consensus::Decodable for $hashtype { - fn consensus_decode(r: &mut R) -> Result { + fn consensus_decode(r: &mut R) -> core::result::Result { use $crate::hashes::Hash; Ok(Self::from_byte_array(<<$hashtype as $crate::hashes::Hash>::Bytes>::consensus_decode(r)?)) } diff --git a/bitcoin/src/psbt/macros.rs b/bitcoin/src/psbt/macros.rs index 33deb634..556c83a7 100644 --- a/bitcoin/src/psbt/macros.rs +++ b/bitcoin/src/psbt/macros.rs @@ -19,7 +19,7 @@ macro_rules! impl_psbt_de_serialize { macro_rules! impl_psbt_deserialize { ($thing:ty) => { impl $crate::psbt::serialize::Deserialize for $thing { - fn deserialize(bytes: &[u8]) -> Result { + fn deserialize(bytes: &[u8]) -> core::result::Result { $crate::consensus::deserialize(&bytes[..]).map_err(|e| $crate::psbt::Error::from(e)) } } @@ -45,7 +45,7 @@ macro_rules! impl_psbtmap_serialize { macro_rules! impl_psbtmap_deserialize { ($thing:ty) => { impl $crate::psbt::serialize::Deserialize for $thing { - fn deserialize(bytes: &[u8]) -> Result { + fn deserialize(bytes: &[u8]) -> core::result::Result { let mut decoder = bytes; Self::decode(&mut decoder) } @@ -58,7 +58,7 @@ macro_rules! impl_psbtmap_decoding { impl $thing { pub(crate) fn decode( r: &mut R, - ) -> Result { + ) -> core::result::Result { let mut rv: Self = core::default::Default::default(); loop { @@ -148,7 +148,7 @@ macro_rules! impl_psbt_hash_de_serialize { macro_rules! impl_psbt_hash_deserialize { ($hash_type:ty) => { impl $crate::psbt::serialize::Deserialize for $hash_type { - fn deserialize(bytes: &[u8]) -> Result { + fn deserialize(bytes: &[u8]) -> core::result::Result { <$hash_type>::from_slice(&bytes[..]).map_err(|e| $crate::psbt::Error::from(e)) } } diff --git a/hashes/src/internal_macros.rs b/hashes/src/internal_macros.rs index bb99febc..9352cde5 100644 --- a/hashes/src/internal_macros.rs +++ b/hashes/src/internal_macros.rs @@ -104,7 +104,7 @@ macro_rules! hash_trait_impls { impl<$($gen: $gent),*> str::FromStr for Hash<$($gen),*> { type Err = $crate::hex::HexToArrayError; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> $crate::_export::_core::result::Result { use $crate::hex::{FromHex, HexToBytesIter}; use $crate::Hash; @@ -151,7 +151,7 @@ macro_rules! hash_trait_impls { from_engine(e) } - fn from_slice(sl: &[u8]) -> Result, FromSliceError> { + fn from_slice(sl: &[u8]) -> $crate::_export::_core::result::Result, FromSliceError> { if sl.len() != $bits / 8 { Err(FromSliceError{expected: Self::LEN, got: sl.len()}) } else { diff --git a/hashes/src/serde_macros.rs b/hashes/src/serde_macros.rs index ded28b2f..3646af39 100644 --- a/hashes/src/serde_macros.rs +++ b/hashes/src/serde_macros.rs @@ -25,7 +25,7 @@ pub mod serde_details { formatter.write_str("an ASCII hex string") } - fn visit_bytes(self, v: &[u8]) -> Result + fn visit_bytes(self, v: &[u8]) -> core::result::Result where E: de::Error, { @@ -36,7 +36,7 @@ pub mod serde_details { } } - fn visit_str(self, v: &str) -> Result + fn visit_str(self, v: &str) -> core::result::Result where E: de::Error, { @@ -57,7 +57,7 @@ pub mod serde_details { formatter.write_str("a bytestring") } - fn visit_bytes(self, v: &[u8]) -> Result + fn visit_bytes(self, v: &[u8]) -> core::result::Result where E: de::Error, { @@ -82,10 +82,10 @@ pub mod serde_details { const N: usize; /// Helper function to turn a deserialized slice into the correct hash type. - fn from_slice_delegated(sl: &[u8]) -> Result; + fn from_slice_delegated(sl: &[u8]) -> core::result::Result; /// Do serde serialization. - fn serialize(&self, s: S) -> Result { + fn serialize(&self, s: S) -> core::result::Result { if s.is_human_readable() { s.collect_str(self) } else { @@ -94,7 +94,7 @@ pub mod serde_details { } /// Do serde deserialization. - fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result { + fn deserialize<'de, D: Deserializer<'de>>(d: D) -> core::result::Result { if d.is_human_readable() { d.deserialize_str(HexVisitor::(PhantomData)) } else { @@ -112,7 +112,7 @@ macro_rules! serde_impl( ($t:ident, $len:expr $(, $gen:ident: $gent:ident)*) => ( impl<$($gen: $gent),*> $crate::serde_macros::serde_details::SerdeHash for $t<$($gen),*> { const N : usize = $len; - fn from_slice_delegated(sl: &[u8]) -> Result { + fn from_slice_delegated(sl: &[u8]) -> core::result::Result { #[allow(unused_imports)] use $crate::Hash as _; $t::from_slice(sl) @@ -120,13 +120,13 @@ macro_rules! serde_impl( } impl<$($gen: $gent),*> $crate::serde::Serialize for $t<$($gen),*> { - fn serialize(&self, s: S) -> Result { + fn serialize(&self, s: S) -> core::result::Result { $crate::serde_macros::serde_details::SerdeHash::serialize(self, s) } } impl<'de $(, $gen: $gent)*> $crate::serde::Deserialize<'de> for $t<$($gen),*> { - fn deserialize>(d: D) -> Result<$t<$($gen),*>, D::Error> { + fn deserialize>(d: D) -> core::result::Result<$t<$($gen),*>, D::Error> { $crate::serde_macros::serde_details::SerdeHash::deserialize(d) } } diff --git a/internals/src/macros.rs b/internals/src/macros.rs index 799730f0..91e60a1c 100644 --- a/internals/src/macros.rs +++ b/internals/src/macros.rs @@ -42,7 +42,7 @@ macro_rules! impl_array_newtype { impl<'a> core::convert::TryFrom<&'a [$ty]> for $thing { type Error = core::array::TryFromSliceError; - fn try_from(data: &'a [$ty]) -> Result { + fn try_from(data: &'a [$ty]) -> core::result::Result { use core::convert::TryInto; Ok($thing(data.try_into()?)) @@ -99,7 +99,7 @@ macro_rules! impl_array_newtype { macro_rules! debug_from_display { ($thing:ident) => { impl core::fmt::Debug for $thing { - fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::result::Result<(), core::fmt::Error> { core::fmt::Display::fmt(self, f) } }