Remove stutter for error variants

Error variants should not end with the same identifier as the enum,
i.e., they should not stutter.

Found by clippy after setting:

  avoid-breaking-exported-api = false
This commit is contained in:
Tobin C. Harding 2022-08-02 08:41:52 +10:00
parent 08c4a2204a
commit 5cef2f1a8f
2 changed files with 7 additions and 7 deletions

View File

@ -157,7 +157,7 @@ pub enum Error {
/// Can not find the spent output
UnknownSpentOutput(OutPoint),
/// Can not serialize the spending transaction
SerializationError
Serialization
}
impl fmt::Display for Error {
@ -169,7 +169,7 @@ impl fmt::Display for Error {
#[cfg(feature = "bitcoinconsensus")]
Error::BitcoinConsensus(ref _n) => "bitcoinconsensus verification failed",
Error::UnknownSpentOutput(ref _point) => "unknown spent output Transaction::verify()",
Error::SerializationError => "can not serialize the spending transaction in Transaction::verify()",
Error::Serialization => "can not serialize the spending transaction in Transaction::verify()",
};
f.write_str(str)
}
@ -186,7 +186,7 @@ impl std::error::Error for Error {
| EarlyEndOfScript
| NumericOverflow
| UnknownSpentOutput(_)
| SerializationError => None,
| Serialization => None,
#[cfg(feature = "bitcoinconsensus")]
BitcoinConsensus(_) => None,
}

View File

@ -58,7 +58,7 @@ pub enum Error {
/// Unable to parse as a standard sighash type.
NonStandardSighashType(u32),
/// Parsing errors from bitcoin_hashes
HashParseError(hashes::Error),
HashParse(hashes::Error),
/// The pre-image must hash to the correponding psbt hash
InvalidPreimageHashPair {
/// Hash-type
@ -93,7 +93,7 @@ impl fmt::Display for Error {
Error::NoMorePairs => f.write_str("no more key-value pairs for this psbt map"),
Error::UnexpectedUnsignedTx { expected: ref e, actual: ref a } => write!(f, "different unsigned transaction: expected {}, actual {}", e.txid(), a.txid()),
Error::NonStandardSighashType(ref sht) => write!(f, "non-standard sighash type: {}", sht),
Error::HashParseError(ref e) => write_err!(f, "hash parse error"; e),
Error::HashParse(ref e) => write_err!(f, "hash parse error"; e),
Error::InvalidPreimageHashPair{ref preimage, ref hash, ref hash_type} => {
// directly using debug forms of psbthash enums
write!(f, "Preimage {:?} does not match {:?} hash {:?}", preimage, hash_type, hash )
@ -111,7 +111,7 @@ impl std::error::Error for Error {
use self::Error::*;
match self {
HashParseError(e) => Some(e),
HashParse(e) => Some(e),
| InvalidMagic
| MissingUtxo
| InvalidSeparator
@ -135,7 +135,7 @@ impl std::error::Error for Error {
#[doc(hidden)]
impl From<hashes::Error> for Error {
fn from(e: hashes::Error) -> Error {
Error::HashParseError(e)
Error::HashParse(e)
}
}