What changed, and why it matters
This commit removes an unused code path from the deserialization logic for a 256-bit unsigned integer type (U256). The removed code handled raw byte input, but the surrounding code only ever asks serde for a string, so the byte path was unreachable. There is no security fix here—just cleanup of dead code.
No security action required. Treat as normal code-cleanup/refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch deletes the visit_bytes method from the HexVisitor helper inside U256’s serde::Deserialize implementation in units/src/pow.rs. The visitor is only used via d.deserialize_str(HexVisitor), which means serde will call visit_str, not visit_bytes. The removed method attempted to interpret raw bytes as UTF-8 hex and forward to visit_str, but it could never be invoked in this code path. The change is purely a code-quality refactor with no behavioral or security impact.
Changed components
units/src/pow.rsU256 serde Deserialize implementationInspect captured patch +0 / −11
diff --git a/units/src/pow.rs b/units/src/pow.rs
index 9d7d5b47..3c58b8ed 100644
--- a/units/src/pow.rs
+++ b/units/src/pow.rs
@@ -526,17 +526,6 @@ impl<'de> serde::Deserialize<'de> for U256 {
Ok(U256(upper, lower))
}
-
- fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
- where
- E: de::Error,
- {
- if let Ok(hex) = core::str::from_utf8(v) {
- self.visit_str(hex)
- } else {
- Err(E::invalid_value(::serde::de::Unexpected::Bytes(v), &self))
- }
- }
}
d.deserialize_str(HexVisitor)
} else {
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.