Skip to content

Commit 78ffb56

Browse files
committed
nits from cargo test and cargo clippy on latest nightly
The newest nightly has a new "unused mut" warning which is causing CI to fail. Fix that, and while we're at it, run clippy. And while we're at that, remove some `#[deny]` conditions from the crate root since these properly belong in CI (via -D warnings) rather than in the source.
1 parent 8d1942f commit 78ffb56

File tree

6 files changed

+31
-10
lines changed

6 files changed

+31
-10
lines changed

secp256k1-zkp-sys/src/zkp.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,12 @@ impl PartialEq for SurjectionProof {
426426

427427
impl Eq for SurjectionProof {}
428428

429+
impl Default for SurjectionProof {
430+
fn default() -> Self {
431+
SurjectionProof::new()
432+
}
433+
}
434+
429435
impl hash::Hash for SurjectionProof {
430436
fn hash<H: hash::Hasher>(&self, state: &mut H) {
431437
self.n_inputs.hash(state);
@@ -527,7 +533,7 @@ impl Default for PedersenCommitment {
527533
#[cfg(not(fuzzing))]
528534
impl PartialEq for PedersenCommitment {
529535
fn eq(&self, other: &Self) -> bool {
530-
&self.0[..] == &other.0[..]
536+
self.0[..] == other.0[..]
531537
}
532538
}
533539

@@ -594,6 +600,12 @@ pub struct EcdsaAdaptorSignature([u8; ECDSA_ADAPTOR_SIGNATURE_LENGTH]);
594600
impl_array_newtype!(EcdsaAdaptorSignature, u8, ECDSA_ADAPTOR_SIGNATURE_LENGTH);
595601
impl_raw_debug!(EcdsaAdaptorSignature);
596602

603+
impl Default for EcdsaAdaptorSignature {
604+
fn default() -> EcdsaAdaptorSignature {
605+
EcdsaAdaptorSignature::new()
606+
}
607+
}
608+
597609
impl EcdsaAdaptorSignature {
598610
/// Create a new (zeroed) ecdsa adaptor signature usable for the FFI interface
599611
pub fn new() -> Self {
@@ -617,7 +629,7 @@ impl EcdsaAdaptorSignature {
617629
#[cfg(not(fuzzing))]
618630
impl PartialEq for EcdsaAdaptorSignature {
619631
fn eq(&self, other: &Self) -> bool {
620-
&self.0[..] == &other.0[..]
632+
self.0[..] == other.0[..]
621633
}
622634
}
623635

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,14 @@
2929
//!
3030
3131
// Coding conventions
32-
#![deny(non_upper_case_globals)]
33-
#![deny(non_camel_case_types)]
34-
#![deny(non_snake_case)]
35-
#![deny(unused_mut)]
3632
#![warn(missing_docs)]
3733
#![cfg_attr(all(not(test), not(feature = "std")), no_std)]
3834
#![cfg_attr(all(test, feature = "unstable"), feature(test))]
3935

4036
#[macro_use]
37+
/// Re-export of the internal FFI bindings crate
4138
pub extern crate secp256k1_zkp_sys;
39+
/// Re-export of the internal FFI bindings crate under the alternate name `ffi`
4240
pub use secp256k1_zkp_sys as ffi;
4341

4442
extern crate secp256k1;
@@ -47,10 +45,12 @@ extern crate secp256k1;
4745
pub use secp256k1::hashes;
4846
#[cfg(any(test, feature = "std"))]
4947
extern crate core;
48+
/// Re-export of the `rand` crate
5049
#[cfg(any(test, feature = "rand"))]
5150
pub extern crate rand;
52-
#[cfg(any(test))]
51+
#[cfg(test)]
5352
extern crate rand_core;
53+
/// Re-export of the `serde` crate
5454
#[cfg(feature = "serde")]
5555
pub extern crate serde;
5656
#[cfg(all(test, feature = "serde"))]

src/zkp/generator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub const ZERO_TWEAK: Tweak = Tweak([
2121
impl fmt::Debug for Tweak {
2222
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2323
write!(f, "Tweak(")?;
24-
for i in self[..].iter().cloned() {
24+
for i in self[..].iter() {
2525
write!(f, "{:02x}", i)?;
2626
}
2727
write!(f, ")")

src/zkp/rangeproof.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ impl RangeProof {
6565
}
6666

6767
/// Prove that `commitment` hides a value within a range, with the lower bound set to `min_value`.
68+
#[allow(clippy::too_many_arguments)]
6869
pub fn new<C: Signing>(
6970
secp: &Secp256k1<C>,
7071
min_value: u64,

src/zkp/surjection_proof.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ impl SurjectionProof {
152152
}
153153
}
154154

155+
/// Whether the proof has zero length
156+
///
157+
/// Always returns `false` since a surjection proof must contain at least
158+
/// one 32-byte hash.
159+
pub fn is_empty(&self) -> bool {
160+
false
161+
}
162+
155163
/// Verify a surjection proof.
156164
#[must_use]
157165
pub fn verify<C: Verification>(

src/zkp/whitelist.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub struct WhitelistSignature(ffi::WhitelistSignature);
1818
impl WhitelistSignature {
1919
/// Number of keys in the whitelist.
2020
pub fn n_keys(&self) -> usize {
21-
self.0.n_keys as usize
21+
self.0.n_keys
2222
}
2323

2424
/// Serialize to bytes.
@@ -339,7 +339,7 @@ mod tests {
339339
// wrong n_keys
340340
let sig = unsafe {
341341
let sig = correct_signature.clone();
342-
let mut ptr = sig.as_c_ptr() as *mut ffi::WhitelistSignature;
342+
let ptr = sig.as_c_ptr() as *mut ffi::WhitelistSignature;
343343
(*ptr).n_keys -= 1;
344344
sig
345345
};

0 commit comments

Comments
 (0)