Skip to content

Commit

Permalink
Latest clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
kayabaNerve committed Aug 1, 2023
1 parent c338b92 commit 53d86e2
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion coins/monero/src/bin/reserialize_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async fn check_block(rpc: Arc<Rpc<HttpRpc>>, block_i: usize) {
}

let mut batch = BatchVerifier::new(block.txs.len());
for (tx_hash, tx_res) in block.txs.into_iter().zip(all_txs.into_iter()) {
for (tx_hash, tx_res) in block.txs.into_iter().zip(all_txs) {
assert_eq!(
tx_res.tx_hash,
hex::encode(tx_hash),
Expand Down
4 changes: 4 additions & 0 deletions coins/monero/src/ringct/bulletproofs/scalar_vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,23 @@ use multiexp::multiexp;
pub(crate) struct ScalarVector(pub(crate) Vec<Scalar>);
macro_rules! math_op {
($Op: ident, $op: ident, $f: expr) => {
#[allow(clippy::redundant_closure_call)]
impl $Op<Scalar> for ScalarVector {
type Output = ScalarVector;
fn $op(self, b: Scalar) -> ScalarVector {
ScalarVector(self.0.iter().map(|a| $f((a, &b))).collect())
}
}

#[allow(clippy::redundant_closure_call)]
impl $Op<Scalar> for &ScalarVector {
type Output = ScalarVector;
fn $op(self, b: Scalar) -> ScalarVector {
ScalarVector(self.0.iter().map(|a| $f((a, &b))).collect())
}
}

#[allow(clippy::redundant_closure_call)]
impl $Op<ScalarVector> for ScalarVector {
type Output = ScalarVector;
fn $op(self, b: ScalarVector) -> ScalarVector {
Expand All @@ -34,6 +37,7 @@ macro_rules! math_op {
}
}

#[allow(clippy::redundant_closure_call)]
impl $Op<&ScalarVector> for &ScalarVector {
type Output = ScalarVector;
fn $op(self, b: &ScalarVector) -> ScalarVector {
Expand Down
2 changes: 1 addition & 1 deletion coins/monero/tests/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async fn add_inputs(
.await
.unwrap();

let inputs = spendable_outputs.into_iter().zip(decoys.into_iter()).collect::<Vec<_>>();
let inputs = spendable_outputs.into_iter().zip(decoys).collect::<Vec<_>>();

builder.add_inputs(&inputs);
}
Expand Down
6 changes: 3 additions & 3 deletions coordinator/src/substrate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ async fn handle_new_set<
Ok(())
}

async fn handle_key_gen<D: Db, Pro: Processors>(
db: &mut D,
async fn handle_key_gen<Pro: Processors>(
key: &Zeroizing<<Ristretto as Ciphersuite>::F>,
processors: &Pro,
serai: &Serai,
Expand Down Expand Up @@ -215,6 +214,7 @@ async fn handle_batch_and_burns<Pro: Processors>(

// Handle a specific Substrate block, returning an error when it fails to get data
// (not blocking / holding)
#[allow(clippy::needless_pass_by_ref_mut)] // False positive?
async fn handle_block<
D: Db,
Fut: Future<Output = ()>,
Expand Down Expand Up @@ -265,7 +265,7 @@ async fn handle_block<
for key_gen in serai.get_key_gen_events(hash).await? {
if !SubstrateDb::<D>::handled_event(&db.0, hash, event_id) {
if let ValidatorSetsEvent::KeyGen { set, key_pair } = key_gen {
handle_key_gen(&mut db.0, key, processors, serai, &block, set, key_pair).await?;
handle_key_gen(key, processors, serai, &block, set, key_pair).await?;
} else {
panic!("KeyGen event wasn't KeyGen: {key_gen:?}");
}
Expand Down
1 change: 1 addition & 0 deletions coordinator/src/tributary/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub enum RecognizedIdType {
}

// Handle a specific Tributary block
#[allow(clippy::needless_pass_by_ref_mut)] // False positive?
async fn handle_block<D: Db, Pro: Processors>(
db: &mut TributaryDb<D>,
key: &Zeroizing<<Ristretto as Ciphersuite>::F>,
Expand Down
2 changes: 2 additions & 0 deletions crypto/dalek-ff-group/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#![no_std] // Prevents writing new code, in what should be a simple wrapper, which requires std
#![doc = include_str!("../README.md")]

#![allow(clippy::redundant_closure_call)]

use core::{
borrow::Borrow,
ops::{Deref, Add, AddAssign, Sub, SubAssign, Neg, Mul, MulAssign},
Expand Down
2 changes: 2 additions & 0 deletions crypto/ed448/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#![doc = include_str!("../README.md")]
#![no_std]

#![allow(clippy::redundant_closure_call)]

#[macro_use]
mod backend;

Expand Down
2 changes: 1 addition & 1 deletion crypto/frost/src/nonce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl<C: Curve> BindingFactor<C> {
self.0.insert(i, IndividualBinding { commitments, binding_factors: None });
}

pub(crate) fn calculate_binding_factors<T: Clone + Transcript>(&mut self, transcript: &mut T) {
pub(crate) fn calculate_binding_factors<T: Clone + Transcript>(&mut self, transcript: &T) {
for (l, binding) in self.0.iter_mut() {
let mut transcript = transcript.clone();
transcript.append_message(b"participant", C::F::from(u64::from(u16::from(*l))).to_repr());
Expand Down
2 changes: 1 addition & 1 deletion crypto/frost/src/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ impl<C: Curve, A: Algorithm<C>> SignMachine<A::Signature> for AlgorithmSignMachi
);

// Generate the per-signer binding factors
B.calculate_binding_factors(&mut rho_transcript);
B.calculate_binding_factors(&rho_transcript);

// Merge the rho transcript back into the global one to ensure its advanced, while
// simultaneously committing to everything
Expand Down
2 changes: 1 addition & 1 deletion crypto/transcript/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ where
// Attempt to get them marked as read

#[rustversion::since(1.66)]
fn mark_read<D: Send + Clone + SecureDigest>(transcript: &mut DigestTranscript<D>) {
fn mark_read<D: Send + Clone + SecureDigest>(transcript: &DigestTranscript<D>) {
// Just get a challenge from the state
let mut challenge = core::hint::black_box(transcript.0.clone().finalize());
challenge.as_mut().zeroize();
Expand Down
5 changes: 2 additions & 3 deletions processor/src/networks/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ impl Network for Bitcoin {
}

let this_block_hash = block.id();
let this_block_num = (|| async {
let this_block_num = (async {
loop {
match self.rpc.get_block_number(&this_block_hash).await {
Ok(number) => return number,
Expand All @@ -420,8 +420,7 @@ impl Network for Bitcoin {
}
sleep(Duration::from_secs(60)).await;
}
})()
.await;
}).await;

for block_num in (eventualities.block_number + 1) .. this_block_num {
let block = {
Expand Down
4 changes: 2 additions & 2 deletions processor/src/networks/monero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ impl Network for Monero {
.map_err(|_| NetworkError::ConnectionError)
.unwrap();

let inputs = spendable_outputs.into_iter().zip(decoys.into_iter()).collect::<Vec<_>>();
let inputs = spendable_outputs.into_iter().zip(decoys).collect::<Vec<_>>();

let signable = |mut plan: Plan<Self>, tx_fee: Option<_>| {
// Monero requires at least two outputs
Expand Down Expand Up @@ -617,7 +617,7 @@ impl Network for Monero {
.await
.unwrap();

let inputs = outputs.into_iter().zip(decoys.into_iter()).collect::<Vec<_>>();
let inputs = outputs.into_iter().zip(decoys).collect::<Vec<_>>();

let tx = MSignableTransaction::new(
protocol,
Expand Down

0 comments on commit 53d86e2

Please sign in to comment.