From b9b8ddafdea286c5ed26abb04b966c77fdfa6d17 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Tue, 10 Dec 2024 10:56:33 +1100 Subject: [PATCH 1/2] hashes: Add lint return_self_must_use Add the lint. No additional clippy warnings are introduced. --- hashes/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hashes/src/lib.rs b/hashes/src/lib.rs index 44b13523d..920ce9973 100644 --- a/hashes/src/lib.rs +++ b/hashes/src/lib.rs @@ -58,6 +58,8 @@ #![warn(missing_docs)] #![warn(deprecated_in_future)] #![doc(test(attr(warn(unused))))] +// Pedantic lints that we enforce. +#![warn(clippy::return_self_not_must_use)] // Instead of littering the codebase for non-fuzzing and bench code just globally allow. #![cfg_attr(hashes_fuzz, allow(dead_code, unused_imports))] #![cfg_attr(bench, allow(dead_code, unused_imports))] From f4b9c06c8bdffccfe997135f7b6ec168978e9bcc Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 9 Dec 2024 17:05:27 +1100 Subject: [PATCH 2/2] hashes: Add additional must_use Run the linter with `must_use_candidate` enabled and check all the warnings. --- hashes/src/sha256.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hashes/src/sha256.rs b/hashes/src/sha256.rs index 98e8ec132..8770b332b 100644 --- a/hashes/src/sha256.rs +++ b/hashes/src/sha256.rs @@ -135,6 +135,7 @@ impl crate::HashEngine for HashEngine { impl Hash { /// Iterate the sha256 algorithm to turn a sha256 hash into a sha256d hash + #[must_use] pub fn hash_again(&self) -> sha256d::Hash { crate::Hash::from_byte_array(::hash(&self.0).0) } @@ -202,6 +203,7 @@ impl Midstate { /// /// Computes non-finalized hash of `sha256(tag) || sha256(tag)` for use in [`sha256t`]. It's /// provided for use with [`sha256t`]. + #[must_use] pub const fn hash_tag(tag: &[u8]) -> Self { let hash = Hash::hash_unoptimized(tag); let mut buf = [0u8; 64];