hashes: Add explicit None return impl for std::error::Error
What changed, and why it matters
This commit is a minor code cleanup with no security impact. It changes two Rust error types to explicitly state that they do not wrap another underlying error, instead of relying on the programming language's default behavior. The actual program behavior is unchanged.
No action required. This is a non-functional readability improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch replaces default implementations of std::error::Error for MaxLengthError and MidstateError with explicit source() methods that return None. This is semantically equivalent to the default trait implementation and does not alter runtime behavior, error chaining, or any security-relevant logic.
Changed components
hashes/src/hkdf/mod.rshashes/src/sha256/mod.rsInspect captured patch +6 / −2
diff --git a/hashes/src/hkdf/mod.rs b/hashes/src/hkdf/mod.rs
index 9e7fbf12..12be32b9 100644
--- a/hashes/src/hkdf/mod.rs
+++ b/hashes/src/hkdf/mod.rs
@@ -156,7 +156,9 @@ pub mod error {
}
#[cfg(feature = "std")]
- impl std::error::Error for MaxLengthError {}
+ impl std::error::Error for MaxLengthError {
+ fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None }
+ }
}
#[cfg(test)]
diff --git a/hashes/src/sha256/mod.rs b/hashes/src/sha256/mod.rs
index 57d7a001..0ae970d0 100644
--- a/hashes/src/sha256/mod.rs
+++ b/hashes/src/sha256/mod.rs
@@ -304,5 +304,7 @@ pub mod error {
}
#[cfg(feature = "std")]
- impl std::error::Error for MidstateError {}
+ impl std::error::Error for MidstateError {
+ fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None }
+ }
}
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.