From 5e67f7a7cbea26eb229586537fb6bf581654ac70 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 30 Nov 2022 14:41:14 +1100 Subject: [PATCH 1/2] Remove the unnecessary explicit reference Clippy emits various warnings of form: warning: this expression creates a reference which is immediately dereferenced by the compiler As suggested, remove the unnecessary explicit reference. --- hashes/src/ripemd160.rs | 2 +- hashes/src/sha1.rs | 2 +- hashes/src/sha256.rs | 2 +- hashes/src/sha256d.rs | 2 +- hashes/src/sha512.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hashes/src/ripemd160.rs b/hashes/src/ripemd160.rs index 30d24172..4b750978 100644 --- a/hashes/src/ripemd160.rs +++ b/hashes/src/ripemd160.rs @@ -469,7 +469,7 @@ mod tests { for test in tests { // Hash through high-level API, check hex encoding/decoding - let hash = ripemd160::Hash::hash(&test.input.as_bytes()); + let hash = ripemd160::Hash::hash(test.input.as_bytes()); assert_eq!(hash, ripemd160::Hash::from_hex(test.output_str).expect("parse hex")); assert_eq!(&hash[..], &test.output[..]); assert_eq!(&hash.to_hex(), &test.output_str); diff --git a/hashes/src/sha1.rs b/hashes/src/sha1.rs index a342d193..f5cae9a2 100644 --- a/hashes/src/sha1.rs +++ b/hashes/src/sha1.rs @@ -195,7 +195,7 @@ mod tests { for test in tests { // Hash through high-level API, check hex encoding/decoding - let hash = sha1::Hash::hash(&test.input.as_bytes()); + let hash = sha1::Hash::hash(test.input.as_bytes()); assert_eq!(hash, sha1::Hash::from_hex(test.output_str).expect("parse hex")); assert_eq!(&hash[..], &test.output[..]); assert_eq!(&hash.to_hex(), &test.output_str); diff --git a/hashes/src/sha256.rs b/hashes/src/sha256.rs index cc4d5364..b6336fa6 100644 --- a/hashes/src/sha256.rs +++ b/hashes/src/sha256.rs @@ -371,7 +371,7 @@ mod tests { for test in tests { // Hash through high-level API, check hex encoding/decoding - let hash = sha256::Hash::hash(&test.input.as_bytes()); + let hash = sha256::Hash::hash(test.input.as_bytes()); assert_eq!(hash, sha256::Hash::from_hex(test.output_str).expect("parse hex")); assert_eq!(&hash[..], &test.output[..]); assert_eq!(&hash.to_hex(), &test.output_str); diff --git a/hashes/src/sha256d.rs b/hashes/src/sha256d.rs index 6ecccdc4..1a3e75b3 100644 --- a/hashes/src/sha256d.rs +++ b/hashes/src/sha256d.rs @@ -74,7 +74,7 @@ mod tests { for test in tests { // Hash through high-level API, check hex encoding/decoding - let hash = sha256d::Hash::hash(&test.input.as_bytes()); + let hash = sha256d::Hash::hash(test.input.as_bytes()); assert_eq!(hash, sha256d::Hash::from_hex(test.output_str).expect("parse hex")); assert_eq!(&hash[..], &test.output[..]); assert_eq!(&hash.to_hex(), &test.output_str); diff --git a/hashes/src/sha512.rs b/hashes/src/sha512.rs index 3298d4a6..876614a0 100644 --- a/hashes/src/sha512.rs +++ b/hashes/src/sha512.rs @@ -368,7 +368,7 @@ mod tests { for test in tests { // Hash through high-level API, check hex encoding/decoding - let hash = sha512::Hash::hash(&test.input.as_bytes()); + let hash = sha512::Hash::hash(test.input.as_bytes()); assert_eq!(hash, sha512::Hash::from_hex(test.output_str).expect("parse hex")); assert_eq!(&hash[..], &test.output[..]); assert_eq!(&hash.to_hex(), &test.output_str); From b78ba730f25a61900701a317000ffa71894592e4 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 30 Nov 2022 14:43:56 +1100 Subject: [PATCH 2/2] hashes: Run clippy in ci Currently we only run the linter in `bitcoin/contrib/test.sh`, we should do the same in the `hashes` ci script. --- hashes/contrib/test.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hashes/contrib/test.sh b/hashes/contrib/test.sh index 6cf1e764..bb7fe2e8 100755 --- a/hashes/contrib/test.sh +++ b/hashes/contrib/test.sh @@ -22,6 +22,11 @@ export CARGO_TERM_VERBOSE=true cargo build --all cargo test --all +if [ "$DO_LINT" = true ] +then + cargo clippy --all-features --all-targets -- -D warnings +fi + if [ "$DO_FEATURE_MATRIX" = true ]; then cargo build --all --no-default-features cargo test --all --no-default-features