Add From<Infallible> to push_bytes errors
What changed, and why it matters
This commit adds a standard Rust trait implementation that lets two internal error types be created from Rust's Infallible type. Infallible is a type that can never actually exist, so this is a purely mechanical, safe change that makes the library's error types consistent with the project's conventions. It does not fix a vulnerability or change any behavior an attacker could exploit.
No security action needed. Treat as a normal API-consistency improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds impl From<Infallible> for ScriptIntError and impl From<Infallible> for PushBytesError in bitcoin/src/blockdata/script/push_bytes.rs. Because Infallible has no values, the implementation bodies are empty match never {} expressions. This is idiomatic Rust boilerplate that cannot be invoked with real input and has no security implications.
Changed components
bitcoin/src/blockdata/script/push_bytes.rsInspect captured patch +9 / −0
diff --git a/bitcoin/src/blockdata/script/push_bytes.rs b/bitcoin/src/blockdata/script/push_bytes.rs
index 9e0fbe79..9160e4a6 100644
--- a/bitcoin/src/blockdata/script/push_bytes.rs
+++ b/bitcoin/src/blockdata/script/push_bytes.rs
@@ -2,6 +2,7 @@
//! Contains `PushBytes` & co
+use core::convert::Infallible;
use core::fmt;
use core::ops::{Deref, DerefMut};
@@ -465,6 +466,10 @@ pub enum ScriptIntError {
NonMinimal,
}
+impl From<Infallible> for ScriptIntError {
+ fn from(never: Infallible) -> Self { match never {} }
+}
+
#[cfg(feature = "std")]
impl std::error::Error for ScriptIntError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
@@ -551,6 +556,10 @@ mod error {
}
}
+impl From<Infallible> for PushBytesError {
+ fn from(never: Infallible) -> Self { match never {} }
+}
+
#[cfg(feature = "std")]
impl std::error::Error for PushBytesError {
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.