Add #[track_caller] to sha256::Midstate::new()
What changed, and why it matters
This commit adds a Rust compiler annotation called #[track_caller] to a single function. It does not change what the program does, how it validates inputs, or how it handles errors. It only improves the quality of panic messages so that if the function panics, the reported error location points to the caller's code rather than inside this library function. There is no security fix here.
No security action needed. Treat as a normal code-quality/diagnostics improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change annotates sha256::Midstate::new() with #[track_caller]. In Rust, this attribute preserves the caller’s location for panic reporting and is purely a diagnostics/QoL improvement. The function still panics on the same invariant violation (bytes_hashed not a multiple of 64). No logic, validation, or API contract changed.
Changed components
hashes/src/sha256/mod.rsInspect captured patch +1 / −0
diff --git a/hashes/src/sha256/mod.rs b/hashes/src/sha256/mod.rs
index 6633c673..e0fe318d 100644
--- a/hashes/src/sha256/mod.rs
+++ b/hashes/src/sha256/mod.rs
@@ -182,6 +182,7 @@ impl Midstate {
/// # Panics
///
/// Panics if `bytes_hashed` is not a multiple of 64.
+ #[track_caller]
pub const fn new(state: [u8; 32], bytes_hashed: u64) -> Self {
if bytes_hashed % 64 != 0 {
panic!("bytes hashed is not a multiple of 64");
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.