Use full path in all macro usage of Result

If a user has defined their own alias for Result and tries to use a macro,
relative paths cause an issue. Use full paths to fix this.
This commit is contained in:
josibake 2024-01-18 16:39:09 +01:00
parent 9eec1082ec
commit 61bf462806
No known key found for this signature in database
GPG Key ID: 8ADCB558C4F33D65
7 changed files with 45 additions and 45 deletions

View File

@ -67,10 +67,10 @@ macro_rules! all_opcodes {
pub static OP_NOP3: Opcode = OP_CSV; pub static OP_NOP3: Opcode = OP_CSV;
impl fmt::Display for Opcode { 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 { 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 { 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 { match *self {
$(Ordinary::$op => { f.pad(stringify!($op)) }),* $(Ordinary::$op => { f.pad(stringify!($op)) }),*
} }

View File

@ -193,7 +193,7 @@ pub trait ReadExt: Read {
macro_rules! encoder_fn { macro_rules! encoder_fn {
($name:ident, $val_type:ty) => { ($name:ident, $val_type:ty) => {
#[inline] #[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()) self.write_all(&v.to_le_bytes())
} }
}; };
@ -202,7 +202,7 @@ macro_rules! encoder_fn {
macro_rules! decoder_fn { macro_rules! decoder_fn {
($name:ident, $val_type:ty, $byte_len: expr) => { ($name:ident, $val_type:ty, $byte_len: expr) => {
#[inline] #[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]; let mut val = [0; $byte_len];
self.read_exact(&mut val[..]).map_err(Error::Io)?; self.read_exact(&mut val[..]).map_err(Error::Io)?;
Ok(<$val_type>::from_le_bytes(val)) Ok(<$val_type>::from_le_bytes(val))
@ -357,13 +357,13 @@ macro_rules! impl_int_encodable {
($ty:ident, $meth_dec:ident, $meth_enc:ident) => { ($ty:ident, $meth_dec:ident, $meth_enc:ident) => {
impl Decodable for $ty { impl Decodable for $ty {
#[inline] #[inline]
fn consensus_decode<R: BufRead + ?Sized>(r: &mut R) -> Result<Self, Error> { fn consensus_decode<R: BufRead + ?Sized>(r: &mut R) -> core::result::Result<Self, Error> {
ReadExt::$meth_dec(r) ReadExt::$meth_dec(r)
} }
} }
impl Encodable for $ty { impl Encodable for $ty {
#[inline] #[inline]
fn consensus_encode<W: Write + ?Sized>(&self, w: &mut W) -> Result<usize, io::Error> { fn consensus_encode<W: Write + ?Sized>(&self, w: &mut W) -> core::result::Result<usize, io::Error> {
w.$meth_enc(*self)?; w.$meth_enc(*self)?;
Ok(mem::size_of::<$ty>()) Ok(mem::size_of::<$ty>())
} }
@ -531,7 +531,7 @@ macro_rules! impl_array {
fn consensus_encode<W: WriteExt + ?Sized>( fn consensus_encode<W: WriteExt + ?Sized>(
&self, &self,
w: &mut W, w: &mut W,
) -> Result<usize, io::Error> { ) -> core::result::Result<usize, io::Error> {
w.emit_slice(&self[..])?; w.emit_slice(&self[..])?;
Ok(self.len()) Ok(self.len())
} }
@ -539,7 +539,7 @@ macro_rules! impl_array {
impl Decodable for [u8; $size] { impl Decodable for [u8; $size] {
#[inline] #[inline]
fn consensus_decode<R: BufRead + ?Sized>(r: &mut R) -> Result<Self, Error> { fn consensus_decode<R: BufRead + ?Sized>(r: &mut R) -> core::result::Result<Self, Error> {
let mut ret = [0; $size]; let mut ret = [0; $size];
r.read_slice(&mut ret)?; r.read_slice(&mut ret)?;
Ok(ret) Ok(ret)
@ -583,7 +583,7 @@ macro_rules! impl_vec {
($type: ty) => { ($type: ty) => {
impl Encodable for Vec<$type> { impl Encodable for Vec<$type> {
#[inline] #[inline]
fn consensus_encode<W: Write + ?Sized>(&self, w: &mut W) -> Result<usize, io::Error> { fn consensus_encode<W: Write + ?Sized>(&self, w: &mut W) -> core::result::Result<usize, io::Error> {
let mut len = 0; let mut len = 0;
len += VarInt(self.len() as u64).consensus_encode(w)?; len += VarInt(self.len() as u64).consensus_encode(w)?;
for c in self.iter() { for c in self.iter() {
@ -597,7 +597,7 @@ macro_rules! impl_vec {
#[inline] #[inline]
fn consensus_decode_from_finite_reader<R: BufRead + ?Sized>( fn consensus_decode_from_finite_reader<R: BufRead + ?Sized>(
r: &mut R, r: &mut R,
) -> Result<Self, Error> { ) -> core::result::Result<Self, Error> {
let len = VarInt::consensus_decode_from_finite_reader(r)?.0; let len = VarInt::consensus_decode_from_finite_reader(r)?.0;
// Do not allocate upfront more items than if the sequence of type // Do not allocate upfront more items than if the sequence of type
// occupied roughly quarter a block. This should never be the case // occupied roughly quarter a block. This should never be the case
@ -776,7 +776,7 @@ macro_rules! tuple_encode {
fn consensus_encode<W: Write + ?Sized>( fn consensus_encode<W: Write + ?Sized>(
&self, &self,
w: &mut W, w: &mut W,
) -> Result<usize, io::Error> { ) -> core::result::Result<usize, io::Error> {
let &($(ref $x),*) = self; let &($(ref $x),*) = self;
let mut len = 0; let mut len = 0;
$(len += $x.consensus_encode(w)?;)* $(len += $x.consensus_encode(w)?;)*
@ -787,7 +787,7 @@ macro_rules! tuple_encode {
impl<$($x: Decodable),*> Decodable for ($($x),*) { impl<$($x: Decodable),*> Decodable for ($($x),*) {
#[inline] #[inline]
#[allow(non_snake_case)] #[allow(non_snake_case)]
fn consensus_decode<R: BufRead + ?Sized>(r: &mut R) -> Result<Self, Error> { fn consensus_decode<R: BufRead + ?Sized>(r: &mut R) -> core::result::Result<Self, Error> {
Ok(($({let $x = Decodable::consensus_decode(r)?; $x }),*)) Ok(($({let $x = Decodable::consensus_decode(r)?; $x }),*))
} }
} }

View File

@ -107,7 +107,7 @@ macro_rules! impl_tryfrom_str_from_int_infallible {
impl core::convert::TryFrom<$from> for $to { impl core::convert::TryFrom<$from> for $to {
type Error = $crate::error::ParseIntError; type Error = $crate::error::ParseIntError;
fn try_from(s: $from) -> Result<Self, Self::Error> { fn try_from(s: $from) -> core::result::Result<Self, Self::Error> {
$crate::parse::int::<$inner, $from>(s).map($to::$fn) $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 { impl core::str::FromStr for $to {
type Err = $crate::error::ParseIntError; type Err = $crate::error::ParseIntError;
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> core::result::Result<Self, Self::Err> {
$crate::parse::int::<$inner, &str>(s).map($to::$fn) $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 { impl core::convert::TryFrom<$from> for $to {
type Error = $err; type Error = $err;
fn try_from(s: $from) -> Result<Self, Self::Error> { fn try_from(s: $from) -> core::result::Result<Self, Self::Error> {
let u = $crate::parse::int::<$inner, $from>(s)?; let u = $crate::parse::int::<$inner, $from>(s)?;
$to::$fn(u) $to::$fn(u)
} }
@ -165,7 +165,7 @@ macro_rules! impl_parse_str_from_int_fallible {
impl core::str::FromStr for $to { impl core::str::FromStr for $to {
type Err = $err; type Err = $err;
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> core::result::Result<Self, Self::Err> {
let u = $crate::parse::int::<$inner, &str>(s)?; let u = $crate::parse::int::<$inner, &str>(s)?;
$to::$fn(u) $to::$fn(u)
} }

View File

@ -44,17 +44,17 @@ macro_rules! do_impl {
impl fmt::Display for $ty { impl fmt::Display for $ty {
#[inline] #[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 { impl fmt::LowerHex for $ty {
#[inline] #[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 { impl fmt::UpperHex for $ty {
#[inline] #[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 { macro_rules! impl_hex {
($hex:ident, $case:expr) => { ($hex:ident, $case:expr) => {
impl $hex for U256 { 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) hex::fmt_hex_exact!(f, 32, &self.to_be_bytes(), $case)
} }
} }

View File

@ -309,7 +309,7 @@ pub mod hex_bytes {
macro_rules! serde_string_serialize_impl { macro_rules! serde_string_serialize_impl {
($name:ty, $expecting:literal) => { ($name:ty, $expecting:literal) => {
impl $crate::serde::Serialize for $name { impl $crate::serde::Serialize for $name {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> fn serialize<S>(&self, serializer: S) -> core::result::Result<S::Ok, S::Error>
where where
S: $crate::serde::Serializer, S: $crate::serde::Serializer,
{ {
@ -322,21 +322,21 @@ macro_rules! serde_string_serialize_impl {
macro_rules! serde_string_deserialize_impl { macro_rules! serde_string_deserialize_impl {
($name:ty, $expecting:literal) => { ($name:ty, $expecting:literal) => {
impl<'de> $crate::serde::Deserialize<'de> for $name { impl<'de> $crate::serde::Deserialize<'de> for $name {
fn deserialize<D>(deserializer: D) -> Result<$name, D::Error> fn deserialize<D>(deserializer: D) -> core::result::Result<$name, D::Error>
where where
D: $crate::serde::de::Deserializer<'de>, D: $crate::serde::de::Deserializer<'de>,
{ {
use core::fmt::{self, Formatter}; use core::fmt::Formatter;
struct Visitor; struct Visitor;
impl<'de> $crate::serde::de::Visitor<'de> for Visitor { impl<'de> $crate::serde::de::Visitor<'de> for Visitor {
type Value = $name; type Value = $name;
fn expecting(&self, f: &mut Formatter) -> fmt::Result { fn expecting(&self, f: &mut Formatter) -> core::fmt::Result {
f.write_str($expecting) f.write_str($expecting)
} }
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> fn visit_str<E>(self, v: &str) -> core::result::Result<Self::Value, E>
where where
E: $crate::serde::de::Error, 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 { macro_rules! serde_struct_human_string_impl {
($name:ident, $expecting:literal, $($fe:ident),*) => ( ($name:ident, $expecting:literal, $($fe:ident),*) => (
impl<'de> $crate::serde::Deserialize<'de> for $name { impl<'de> $crate::serde::Deserialize<'de> for $name {
fn deserialize<D>(deserializer: D) -> Result<$name, D::Error> fn deserialize<D>(deserializer: D) -> core::result::Result<$name, D::Error>
where where
D: $crate::serde::de::Deserializer<'de>, D: $crate::serde::de::Deserializer<'de>,
{ {
if deserializer.is_human_readable() { if deserializer.is_human_readable() {
use core::fmt::{self, Formatter}; use core::fmt::Formatter;
use core::str::FromStr; use core::str::FromStr;
struct Visitor; struct Visitor;
impl<'de> $crate::serde::de::Visitor<'de> for Visitor { impl<'de> $crate::serde::de::Visitor<'de> for Visitor {
type Value = $name; type Value = $name;
fn expecting(&self, f: &mut Formatter) -> fmt::Result { fn expecting(&self, f: &mut Formatter) -> core::fmt::Result {
f.write_str($expecting) f.write_str($expecting)
} }
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> fn visit_str<E>(self, v: &str) -> core::result::Result<Self::Value, E>
where where
E: $crate::serde::de::Error, E: $crate::serde::de::Error,
{ {
@ -390,7 +390,7 @@ macro_rules! serde_struct_human_string_impl {
deserializer.deserialize_str(Visitor) deserializer.deserialize_str(Visitor)
} else { } else {
use core::fmt::{self, Formatter}; use core::fmt::Formatter;
use $crate::serde::de::IgnoredAny; use $crate::serde::de::IgnoredAny;
#[allow(non_camel_case_types)] #[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 { impl<'de> $crate::serde::de::Visitor<'de> for EnumVisitor {
type Value = Enum; 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") f.write_str("a field name")
} }
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> fn visit_str<E>(self, v: &str) -> core::result::Result<Self::Value, E>
where where
E: $crate::serde::de::Error, E: $crate::serde::de::Error,
{ {
@ -418,7 +418,7 @@ macro_rules! serde_struct_human_string_impl {
} }
impl<'de> $crate::serde::Deserialize<'de> for Enum { impl<'de> $crate::serde::Deserialize<'de> for Enum {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> fn deserialize<D>(deserializer: D) -> core::result::Result<Self, D::Error>
where where
D: $crate::serde::de::Deserializer<'de>, 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 { impl<'de> $crate::serde::de::Visitor<'de> for Visitor {
type Value = $name; 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") f.write_str("a struct")
} }
fn visit_seq<V>(self, mut seq: V) -> Result<Self::Value, V::Error> fn visit_seq<V>(self, mut seq: V) -> core::result::Result<Self::Value, V::Error>
where where
V: $crate::serde::de::SeqAccess<'de>, V: $crate::serde::de::SeqAccess<'de>,
{ {
@ -457,7 +457,7 @@ macro_rules! serde_struct_human_string_impl {
Ok(ret) Ok(ret)
} }
fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> fn visit_map<A>(self, mut map: A) -> core::result::Result<Self::Value, A::Error>
where where
A: $crate::serde::de::MapAccess<'de>, A: $crate::serde::de::MapAccess<'de>,
{ {
@ -503,7 +503,7 @@ macro_rules! serde_struct_human_string_impl {
} }
impl $crate::serde::Serialize for $name { impl $crate::serde::Serialize for $name {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> fn serialize<S>(&self, serializer: S) -> core::result::Result<S::Ok, S::Error>
where where
S: $crate::serde::Serializer, S: $crate::serde::Serializer,
{ {

View File

@ -241,7 +241,7 @@ macro_rules! hash_newtype {
} }
#[inline] #[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)?)) Ok($newtype(<$hash as $crate::Hash>::from_slice(sl)?))
} }

View File

@ -9,7 +9,7 @@ macro_rules! impl_try_from_stringly {
impl core::convert::TryFrom<$from> for $to { impl core::convert::TryFrom<$from> for $to {
type Error = $error; type Error = $error;
fn try_from(s: $from) -> Result<Self, Self::Error> { fn try_from(s: $from) -> core::result::Result<Self, Self::Error> {
$func(AsRef::<str>::as_ref(s)).map_err(|source| <$error>::new(s, source)) $func(AsRef::<str>::as_ref(s)).map_err(|source| <$error>::new(s, source))
} }
} }
@ -36,7 +36,7 @@ macro_rules! impl_parse {
impl core::str::FromStr for $type { impl core::str::FromStr for $type {
type Err = $error; type Err = $error;
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> core::result::Result<Self, Self::Err> {
$func(s).map_err(|source| <$error>::new(s, source)) $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. // We don't use `serde_string_impl` because we want to avoid allocating input.
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
impl<'de> $crate::serde::Deserialize<'de> for $type { impl<'de> $crate::serde::Deserialize<'de> for $type {
fn deserialize<D>(deserializer: D) -> Result<$name, D::Error> fn deserialize<D>(deserializer: D) -> core::result::Result<$name, D::Error>
where where
D: $crate::serde::de::Deserializer<'de>, 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 { impl<'de> $crate::serde::de::Visitor<'de> for Visitor {
type Value = $name; type Value = $name;
fn expecting(&self, f: &mut Formatter) -> fmt::Result { fn expecting(&self, f: &mut Formatter) -> core::fmt::Result {
f.write_str($descr) f.write_str($descr)
} }
fn visit_str<E>(self, s: &str) -> Result<Self::Value, E> fn visit_str<E>(self, s: &str) -> core::result::Result<Self::Value, E>
where where
E: $crate::serde::de::Error, E: $crate::serde::de::Error,
{ {
@ -96,7 +96,7 @@ macro_rules! impl_parse_and_serde {
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
impl $crate::serde::Serialize for $name { impl $crate::serde::Serialize for $name {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> fn serialize<S>(&self, serializer: S) -> core::result::Result<S::Ok, S::Error>
where where
S: $crate::serde::Serializer, S: $crate::serde::Serializer,
{ {