diff --git a/bitcoin/src/blockdata/opcodes.rs b/bitcoin/src/blockdata/opcodes.rs index 39c86245..fbf4d592 100644 --- a/bitcoin/src/blockdata/opcodes.rs +++ b/bitcoin/src/blockdata/opcodes.rs @@ -67,10 +67,10 @@ macro_rules! all_opcodes { pub static OP_NOP3: Opcode = OP_CSV; impl fmt::Display for Opcode { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { match *self { $( - $op => fmt::Display::fmt(stringify!($op), f), + $op => core::fmt::Display::fmt(stringify!($op), f), )+ } } @@ -484,7 +484,7 @@ macro_rules! ordinary_opcode { } impl fmt::Display for Ordinary { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter) -> core::fmt::Result { match *self { $(Ordinary::$op => { f.pad(stringify!($op)) }),* } diff --git a/bitcoin/src/consensus/encode.rs b/bitcoin/src/consensus/encode.rs index 6017300c..c4be9725 100644 --- a/bitcoin/src/consensus/encode.rs +++ b/bitcoin/src/consensus/encode.rs @@ -193,7 +193,7 @@ pub trait ReadExt: Read { macro_rules! encoder_fn { ($name:ident, $val_type:ty) => { #[inline] - fn $name(&mut self, v: $val_type) -> Result<(), io::Error> { + fn $name(&mut self, v: $val_type) -> core::result::Result<(), io::Error> { self.write_all(&v.to_le_bytes()) } }; @@ -202,7 +202,7 @@ macro_rules! encoder_fn { macro_rules! decoder_fn { ($name:ident, $val_type:ty, $byte_len: expr) => { #[inline] - fn $name(&mut self) -> Result<$val_type, Error> { + fn $name(&mut self) -> core::result::Result<$val_type, Error> { let mut val = [0; $byte_len]; self.read_exact(&mut val[..]).map_err(Error::Io)?; Ok(<$val_type>::from_le_bytes(val)) @@ -357,13 +357,13 @@ macro_rules! impl_int_encodable { ($ty:ident, $meth_dec:ident, $meth_enc:ident) => { impl Decodable for $ty { #[inline] - fn consensus_decode(r: &mut R) -> Result { + fn consensus_decode(r: &mut R) -> core::result::Result { ReadExt::$meth_dec(r) } } impl Encodable for $ty { #[inline] - fn consensus_encode(&self, w: &mut W) -> Result { + fn consensus_encode(&self, w: &mut W) -> core::result::Result { w.$meth_enc(*self)?; Ok(mem::size_of::<$ty>()) } @@ -531,7 +531,7 @@ macro_rules! impl_array { fn consensus_encode( &self, w: &mut W, - ) -> Result { + ) -> core::result::Result { w.emit_slice(&self[..])?; Ok(self.len()) } @@ -539,7 +539,7 @@ macro_rules! impl_array { impl Decodable for [u8; $size] { #[inline] - fn consensus_decode(r: &mut R) -> Result { + fn consensus_decode(r: &mut R) -> core::result::Result { let mut ret = [0; $size]; r.read_slice(&mut ret)?; Ok(ret) @@ -583,7 +583,7 @@ macro_rules! impl_vec { ($type: ty) => { impl Encodable for Vec<$type> { #[inline] - fn consensus_encode(&self, w: &mut W) -> Result { + fn consensus_encode(&self, w: &mut W) -> core::result::Result { let mut len = 0; len += VarInt(self.len() as u64).consensus_encode(w)?; for c in self.iter() { @@ -597,7 +597,7 @@ macro_rules! impl_vec { #[inline] fn consensus_decode_from_finite_reader( r: &mut R, - ) -> Result { + ) -> core::result::Result { let len = VarInt::consensus_decode_from_finite_reader(r)?.0; // Do not allocate upfront more items than if the sequence of type // occupied roughly quarter a block. This should never be the case @@ -776,7 +776,7 @@ macro_rules! tuple_encode { fn consensus_encode( &self, w: &mut W, - ) -> Result { + ) -> core::result::Result { let &($(ref $x),*) = self; let mut len = 0; $(len += $x.consensus_encode(w)?;)* @@ -787,7 +787,7 @@ macro_rules! tuple_encode { impl<$($x: Decodable),*> Decodable for ($($x),*) { #[inline] #[allow(non_snake_case)] - fn consensus_decode(r: &mut R) -> Result { + fn consensus_decode(r: &mut R) -> core::result::Result { Ok(($({let $x = Decodable::consensus_decode(r)?; $x }),*)) } } diff --git a/bitcoin/src/parse.rs b/bitcoin/src/parse.rs index 67b66048..779abad4 100644 --- a/bitcoin/src/parse.rs +++ b/bitcoin/src/parse.rs @@ -107,7 +107,7 @@ macro_rules! impl_tryfrom_str_from_int_infallible { impl core::convert::TryFrom<$from> for $to { type Error = $crate::error::ParseIntError; - fn try_from(s: $from) -> Result { + fn try_from(s: $from) -> core::result::Result { $crate::parse::int::<$inner, $from>(s).map($to::$fn) } } @@ -127,7 +127,7 @@ macro_rules! impl_parse_str_from_int_infallible { impl core::str::FromStr for $to { type Err = $crate::error::ParseIntError; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> core::result::Result { $crate::parse::int::<$inner, &str>(s).map($to::$fn) } } @@ -144,7 +144,7 @@ macro_rules! impl_tryfrom_str_from_int_fallible { impl core::convert::TryFrom<$from> for $to { type Error = $err; - fn try_from(s: $from) -> Result { + fn try_from(s: $from) -> core::result::Result { let u = $crate::parse::int::<$inner, $from>(s)?; $to::$fn(u) } @@ -165,7 +165,7 @@ macro_rules! impl_parse_str_from_int_fallible { impl core::str::FromStr for $to { type Err = $err; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> core::result::Result { let u = $crate::parse::int::<$inner, &str>(s)?; $to::$fn(u) } diff --git a/bitcoin/src/pow.rs b/bitcoin/src/pow.rs index 13579cec..96d78577 100644 --- a/bitcoin/src/pow.rs +++ b/bitcoin/src/pow.rs @@ -44,17 +44,17 @@ macro_rules! do_impl { impl fmt::Display for $ty { #[inline] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&self.0, f) } + fn fmt(&self, f: &mut fmt::Formatter) -> core::fmt::Result { fmt::Display::fmt(&self.0, f) } } impl fmt::LowerHex for $ty { #[inline] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(&self.0, f) } + fn fmt(&self, f: &mut fmt::Formatter) -> core::fmt::Result { fmt::LowerHex::fmt(&self.0, f) } } impl fmt::UpperHex for $ty { #[inline] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::UpperHex::fmt(&self.0, f) } + fn fmt(&self, f: &mut fmt::Formatter) -> core::fmt::Result { fmt::UpperHex::fmt(&self.0, f) } } }; } @@ -810,7 +810,7 @@ impl fmt::Debug for U256 { macro_rules! impl_hex { ($hex:ident, $case:expr) => { impl $hex for U256 { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter) -> core::fmt::Result { hex::fmt_hex_exact!(f, 32, &self.to_be_bytes(), $case) } } diff --git a/bitcoin/src/serde_utils.rs b/bitcoin/src/serde_utils.rs index c0789e0c..7b1c5b7d 100644 --- a/bitcoin/src/serde_utils.rs +++ b/bitcoin/src/serde_utils.rs @@ -309,7 +309,7 @@ pub mod hex_bytes { macro_rules! serde_string_serialize_impl { ($name:ty, $expecting:literal) => { impl $crate::serde::Serialize for $name { - fn serialize(&self, serializer: S) -> Result + fn serialize(&self, serializer: S) -> core::result::Result where S: $crate::serde::Serializer, { @@ -322,21 +322,21 @@ macro_rules! serde_string_serialize_impl { macro_rules! serde_string_deserialize_impl { ($name:ty, $expecting:literal) => { impl<'de> $crate::serde::Deserialize<'de> for $name { - fn deserialize(deserializer: D) -> Result<$name, D::Error> + fn deserialize(deserializer: D) -> core::result::Result<$name, D::Error> where D: $crate::serde::de::Deserializer<'de>, { - use core::fmt::{self, Formatter}; + use core::fmt::Formatter; struct Visitor; impl<'de> $crate::serde::de::Visitor<'de> for Visitor { type Value = $name; - fn expecting(&self, f: &mut Formatter) -> fmt::Result { + fn expecting(&self, f: &mut Formatter) -> core::fmt::Result { f.write_str($expecting) } - fn visit_str(self, v: &str) -> Result + fn visit_str(self, v: &str) -> core::result::Result where E: $crate::serde::de::Error, { @@ -363,23 +363,23 @@ pub(crate) use {serde_string_deserialize_impl, serde_string_impl, serde_string_s macro_rules! serde_struct_human_string_impl { ($name:ident, $expecting:literal, $($fe:ident),*) => ( impl<'de> $crate::serde::Deserialize<'de> for $name { - fn deserialize(deserializer: D) -> Result<$name, D::Error> + fn deserialize(deserializer: D) -> core::result::Result<$name, D::Error> where D: $crate::serde::de::Deserializer<'de>, { if deserializer.is_human_readable() { - use core::fmt::{self, Formatter}; + use core::fmt::Formatter; use core::str::FromStr; struct Visitor; impl<'de> $crate::serde::de::Visitor<'de> for Visitor { type Value = $name; - fn expecting(&self, f: &mut Formatter) -> fmt::Result { + fn expecting(&self, f: &mut Formatter) -> core::fmt::Result { f.write_str($expecting) } - fn visit_str(self, v: &str) -> Result + fn visit_str(self, v: &str) -> core::result::Result where E: $crate::serde::de::Error, { @@ -390,7 +390,7 @@ macro_rules! serde_struct_human_string_impl { deserializer.deserialize_str(Visitor) } else { - use core::fmt::{self, Formatter}; + use core::fmt::Formatter; use $crate::serde::de::IgnoredAny; #[allow(non_camel_case_types)] @@ -400,11 +400,11 @@ macro_rules! serde_struct_human_string_impl { impl<'de> $crate::serde::de::Visitor<'de> for EnumVisitor { type Value = Enum; - fn expecting(&self, f: &mut Formatter) -> fmt::Result { + fn expecting(&self, f: &mut Formatter) -> core::fmt::Result { f.write_str("a field name") } - fn visit_str(self, v: &str) -> Result + fn visit_str(self, v: &str) -> core::result::Result where E: $crate::serde::de::Error, { @@ -418,7 +418,7 @@ macro_rules! serde_struct_human_string_impl { } impl<'de> $crate::serde::Deserialize<'de> for Enum { - fn deserialize(deserializer: D) -> Result + fn deserialize(deserializer: D) -> core::result::Result where D: $crate::serde::de::Deserializer<'de>, { @@ -431,11 +431,11 @@ macro_rules! serde_struct_human_string_impl { impl<'de> $crate::serde::de::Visitor<'de> for Visitor { type Value = $name; - fn expecting(&self, f: &mut Formatter) -> fmt::Result { + fn expecting(&self, f: &mut Formatter) -> core::fmt::Result { f.write_str("a struct") } - fn visit_seq(self, mut seq: V) -> Result + fn visit_seq(self, mut seq: V) -> core::result::Result where V: $crate::serde::de::SeqAccess<'de>, { @@ -457,7 +457,7 @@ macro_rules! serde_struct_human_string_impl { Ok(ret) } - fn visit_map(self, mut map: A) -> Result + fn visit_map(self, mut map: A) -> core::result::Result where A: $crate::serde::de::MapAccess<'de>, { @@ -503,7 +503,7 @@ macro_rules! serde_struct_human_string_impl { } impl $crate::serde::Serialize for $name { - fn serialize(&self, serializer: S) -> Result + fn serialize(&self, serializer: S) -> core::result::Result where S: $crate::serde::Serializer, { diff --git a/hashes/src/util.rs b/hashes/src/util.rs index 393718c9..92fd4855 100644 --- a/hashes/src/util.rs +++ b/hashes/src/util.rs @@ -241,7 +241,7 @@ macro_rules! hash_newtype { } #[inline] - fn from_slice(sl: &[u8]) -> Result<$newtype, $crate::FromSliceError> { + fn from_slice(sl: &[u8]) -> $crate::_export::_core::result::Result<$newtype, $crate::FromSliceError> { Ok($newtype(<$hash as $crate::Hash>::from_slice(sl)?)) } diff --git a/internals/src/parse.rs b/internals/src/parse.rs index 1aed7605..ddf54169 100644 --- a/internals/src/parse.rs +++ b/internals/src/parse.rs @@ -9,7 +9,7 @@ macro_rules! impl_try_from_stringly { impl core::convert::TryFrom<$from> for $to { type Error = $error; - fn try_from(s: $from) -> Result { + fn try_from(s: $from) -> core::result::Result { $func(AsRef::::as_ref(s)).map_err(|source| <$error>::new(s, source)) } } @@ -36,7 +36,7 @@ macro_rules! impl_parse { impl core::str::FromStr for $type { type Err = $error; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> core::result::Result { $func(s).map_err(|source| <$error>::new(s, source)) } } @@ -64,7 +64,7 @@ macro_rules! impl_parse_and_serde { // We don't use `serde_string_impl` because we want to avoid allocating input. #[cfg(feature = "serde")] impl<'de> $crate::serde::Deserialize<'de> for $type { - fn deserialize(deserializer: D) -> Result<$name, D::Error> + fn deserialize(deserializer: D) -> core::result::Result<$name, D::Error> where D: $crate::serde::de::Deserializer<'de>, { @@ -75,11 +75,11 @@ macro_rules! impl_parse_and_serde { impl<'de> $crate::serde::de::Visitor<'de> for Visitor { type Value = $name; - fn expecting(&self, f: &mut Formatter) -> fmt::Result { + fn expecting(&self, f: &mut Formatter) -> core::fmt::Result { f.write_str($descr) } - fn visit_str(self, s: &str) -> Result + fn visit_str(self, s: &str) -> core::result::Result where E: $crate::serde::de::Error, { @@ -96,7 +96,7 @@ macro_rules! impl_parse_and_serde { #[cfg(feature = "serde")] impl $crate::serde::Serialize for $name { - fn serialize(&self, serializer: S) -> Result + fn serialize(&self, serializer: S) -> core::result::Result where S: $crate::serde::Serializer, {