bip32: add missing From<Infallible> to errors
What changed, and why it matters
This commit adds two small Rust trait implementations that allow certain error types to be automatically converted from the 'Infallible' type. 'Infallible' is a type that can never actually exist, so these conversions are purely for making the error types easier to use in generic code. There is no security issue here.
No security action required. This is a routine API ergonomics improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds impl From<Infallible> for DerivationError and impl From<Infallible> for InvalidBase58PayloadLengthError in key_expression/src/bip32.rs. Infallible is Rust’s uninhabited error type used in APIs that cannot fail. Implementing From<Infallible> for an error type is a standard, safe pattern that enables ergonomic use with ? and generic error handling. The implementations are exhaustive empty match expressions on the uninhabited value, which is idiomatic and cannot introduce runtime failure modes.
Changed components
key_expression/src/bip32.rsInspect captured patch +8 / −0
diff --git a/key_expression/src/bip32.rs b/key_expression/src/bip32.rs
index fd840bdc..10b50683 100644
--- a/key_expression/src/bip32.rs
+++ b/key_expression/src/bip32.rs
@@ -1176,6 +1176,10 @@ pub mod error {
MaximumDepthExceeded,
}
+ impl From<Infallible> for DerivationError {
+ fn from(never: Infallible) -> Self { match never {} }
+ }
+
#[cfg(feature = "std")]
impl std::error::Error for DerivationError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
@@ -1267,6 +1271,10 @@ pub mod error {
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!(
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.