What changed, and why it matters
This commit is a pure code-style change. It reorders the implementation blocks for several error types in a Bitcoin-related Rust library so that the order of traits (From, std::error::Error, Display, helper methods) is consistent. No logic, behavior, or security properties of the code are changed.
No action required. This is a non-functional style/refactoring commit with no security relevance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff in key_expression/src/bip32.rs only moves existing impl blocks for IndexOutOfRangeError, ParseChildNumberError, InvalidBase58PayloadLengthError, and InvalidSeedLengthError. The bodies of every impl are identical before and after; only their source-file order changes. There are no functional modifications, no new trait implementations beyond reordering, and no changes to public APIs or error messages.
Changed components
key_expression/src/bip32.rsInspect captured patch +38 / −38
diff --git a/key_expression/src/bip32.rs b/key_expression/src/bip32.rs
index 8f5ecf7b..0d80ee40 100644
--- a/key_expression/src/bip32.rs
+++ b/key_expression/src/bip32.rs
@@ -1468,12 +1468,6 @@ pub mod error {
fn from(never: Infallible) -> Self { match never {} }
}
- impl fmt::Display for IndexOutOfRangeError {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "index {} out of range [0, 2^31 - 1] (do you have a hardened child number, rather than an index?)", self.index)
- }
- }
-
#[cfg(feature = "std")]
impl std::error::Error for IndexOutOfRangeError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
@@ -1482,6 +1476,12 @@ pub mod error {
}
}
+ impl fmt::Display for IndexOutOfRangeError {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ write!(f, "index {} out of range [0, 2^31 - 1] (do you have a hardened child number, rather than an index?)", self.index)
+ }
+ }
+
/// Error parsing a child number.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ParseChildNumberError {
@@ -1495,15 +1495,6 @@ pub mod error {
fn from(never: Infallible) -> Self { match never {} }
}
- impl fmt::Display for ParseChildNumberError {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- match *self {
- Self::IndexOutOfRange(ref e) => e.fmt(f),
- Self::ParseInt(ref e) => e.fmt(f),
- }
- }
- }
-
#[cfg(feature = "std")]
impl std::error::Error for ParseChildNumberError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
@@ -1514,6 +1505,15 @@ pub mod error {
}
}
+ impl fmt::Display for ParseChildNumberError {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ match *self {
+ Self::IndexOutOfRange(ref e) => e.fmt(f),
+ Self::ParseInt(ref e) => e.fmt(f),
+ }
+ }
+ }
+
/// Error parsing a relative derivation path.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
@@ -1595,15 +1595,23 @@ pub mod error {
pub(crate) length: usize,
}
+ impl From<Infallible> for InvalidBase58PayloadLengthError {
+ fn from(never: Infallible) -> Self { match never {} }
+ }
+
+ #[cfg(feature = "std")]
+ impl std::error::Error for InvalidBase58PayloadLengthError {
+ fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
+ let Self { length: _ } = self;
+ None
+ }
+ }
+
impl InvalidBase58PayloadLengthError {
/// Returns the invalid payload length.
pub fn invalid_base58_payload_length(&self) -> usize { self.length }
}
- impl From<Infallible> for InvalidBase58PayloadLengthError {
- fn from(never: Infallible) -> Self { match never {} }
- }
-
impl fmt::Display for InvalidBase58PayloadLengthError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
@@ -1614,29 +1622,29 @@ pub mod error {
}
}
+ /// Master seed had an invalid length.
+ #[derive(Debug, Copy, Clone, PartialEq, Eq)]
+ pub struct InvalidSeedLengthError {
+ pub(crate) length: usize,
+ }
+
+ impl From<Infallible> for InvalidSeedLengthError {
+ fn from(never: Infallible) -> Self { match never {} }
+ }
+
#[cfg(feature = "std")]
- impl std::error::Error for InvalidBase58PayloadLengthError {
+ impl std::error::Error for InvalidSeedLengthError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
let Self { length: _ } = self;
None
}
}
- /// Master seed had an invalid length.
- #[derive(Debug, Copy, Clone, PartialEq, Eq)]
- pub struct InvalidSeedLengthError {
- pub(crate) length: usize,
- }
-
impl InvalidSeedLengthError {
/// Returns the invalid seed length.
pub fn invalid_seed_length(&self) -> usize { self.length }
}
- impl From<Infallible> for InvalidSeedLengthError {
- fn from(never: Infallible) -> Self { match never {} }
- }
-
impl fmt::Display for InvalidSeedLengthError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
@@ -1646,14 +1654,6 @@ pub mod error {
)
}
}
-
- #[cfg(feature = "std")]
- impl std::error::Error for InvalidSeedLengthError {
- fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
- let Self { length: _ } = self;
- None
- }
- }
}
#[cfg(feature = "arbitrary")]
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.