Use write_err in Display for error type
What changed, and why it matters
This is a tiny code-quality change in how an error message is formatted. It replaces a debug-style error display with a more conventional human-readable error message. There is no security issue visible in the commit.
No action needed. This is a non-security refactoring change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit changes the Display implementation for ParseHeaderError in primitives/src/block.rs. Previously it delegated to fmt::Debug, which would produce a debug-formatted representation. Now it uses the write_err! macro to print ‘parse header error’ followed by the inner error’s Display representation. This is a standard Rust error-formatting idiom and has no functional or security impact.
Changed components
primitives/src/block.rsInspect captured patch +3 / −1
diff --git a/primitives/src/block.rs b/primitives/src/block.rs
index 4fad3d95..a384cd69 100644
--- a/primitives/src/block.rs
+++ b/primitives/src/block.rs
@@ -554,7 +554,9 @@ impl fmt::Debug for ParseHeaderError {
#[cfg(feature = "hex")]
impl fmt::Display for ParseHeaderError {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&self, f) }
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write_err!(f, "parse header error"; self.0)
+ }
}
#[cfg(all(feature = "hex", feature = "std"))]
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.