From 6e98ec0475fa1ba29c774f7b90467730b473eea8 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 12 Aug 2022 08:20:15 +1000 Subject: [PATCH] Fix clippy warnings Clippy default settings seemed to have changed introducing a few new warnings. warning: variable does not need to be mutable warning: deref on an immutable reference warning: returning the result of a `let` binding from a block Fix them all in a single patch because CI has to pass for each patch. --- src/context.rs | 3 +++ src/ecdsa/serialized_signature.rs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/context.rs b/src/context.rs index fca1dc4..2248ccd 100644 --- a/src/context.rs +++ b/src/context.rs @@ -196,6 +196,8 @@ mod alloc_only { let size = unsafe { ffi::secp256k1_context_preallocated_size(C::FLAGS) }; let layout = alloc::Layout::from_size_align(size, ALIGN_TO).unwrap(); let ptr = unsafe {alloc::alloc(layout)}; + + #[allow(unused_mut)] // ctx is not mutated under some feature combinations. let mut ctx = Secp256k1 { ctx: unsafe { ffi::secp256k1_context_preallocated_create(ptr as *mut c_void, C::FLAGS) }, phantom: PhantomData, @@ -207,6 +209,7 @@ mod alloc_only { ctx.randomize(&mut rand::thread_rng()); } + #[allow(clippy::let_and_return)] // as for unusted_mut ctx } } diff --git a/src/ecdsa/serialized_signature.rs b/src/ecdsa/serialized_signature.rs index cbc3d00..79ef92d 100644 --- a/src/ecdsa/serialized_signature.rs +++ b/src/ecdsa/serialized_signature.rs @@ -45,7 +45,7 @@ impl PartialEq for SerializedSignature { impl AsRef<[u8]> for SerializedSignature { #[inline] fn as_ref(&self) -> &[u8] { - &*self + self } }