From 1a4755f50657c120727ffddd2854e6790d9754a9 Mon Sep 17 00:00:00 2001 From: Dmitry Demin Date: Fri, 15 Sep 2023 14:14:42 +0200 Subject: [PATCH] Address' cargo clippy' errors following the update to Rust 1.65 --- src/builder.rs | 8 +++++--- src/circuit.rs | 6 +++--- src/issuance.rs | 2 +- src/supply_info.rs | 2 +- tests/zsa.rs | 8 ++++---- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index 36fdd0db7..fe3857904 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -464,9 +464,11 @@ impl Builder { .max() .cloned() .unwrap(); - (num_actions < MIN_ACTIONS) - .then_some(MIN_ACTIONS - num_actions) - .unwrap_or(0) + if num_actions < MIN_ACTIONS { + MIN_ACTIONS - num_actions + } else { + 0 + } } /// Builds a bundle containing the given spent notes and recipients. diff --git a/src/circuit.rs b/src/circuit.rs index d88bfa2a8..0bf473ac7 100644 --- a/src/circuit.rs +++ b/src/circuit.rs @@ -1333,9 +1333,9 @@ mod tests { w.write_all(&<[u8; 32]>::from(instance.rk.clone()))?; w.write_all(&instance.cmx.to_bytes())?; w.write_all(&[ - if instance.enable_spend { 1 } else { 0 }, - if instance.enable_output { 1 } else { 0 }, - if instance.enable_zsa { 1 } else { 0 }, + u8::from(instance.enable_spend), + u8::from(instance.enable_output), + u8::from(instance.enable_zsa), ])?; w.write_all(proof.as_ref())?; diff --git a/src/issuance.rs b/src/issuance.rs index 968a45e48..47bd12ded 100644 --- a/src/issuance.rs +++ b/src/issuance.rs @@ -181,7 +181,7 @@ impl IssueAction { /// Serialize `finalize` flag to a byte pub fn flags(&self) -> u8 { - self.finalize.then_some(0b0000_0001).unwrap_or(0b0000_0000) + u8::from(self.finalize) } } diff --git a/src/supply_info.rs b/src/supply_info.rs index e0f0a20fe..1c2f346b1 100644 --- a/src/supply_info.rs +++ b/src/supply_info.rs @@ -6,7 +6,7 @@ use crate::{issuance::Error, note::AssetBase, value::ValueSum}; /// Represents the amount of an asset and its finalization status. #[derive(Debug, Clone, Copy)] -#[cfg_attr(test, derive(PartialEq))] +#[cfg_attr(test, derive(PartialEq, Eq))] pub struct AssetSupply { /// The amount of the asset. pub amount: ValueSum, diff --git a/tests/zsa.rs b/tests/zsa.rs index 584b25b5b..d3dd1b922 100644 --- a/tests/zsa.rs +++ b/tests/zsa.rs @@ -77,12 +77,12 @@ fn prepare_keys() -> Keychain { fn sign_issue_bundle( unauthorized: IssueBundle, - mut rng: OsRng, + rng: OsRng, isk: &IssuanceAuthorizingKey, ) -> IssueBundle { let sighash = unauthorized.commitment().into(); let proven = unauthorized.prepare(sighash); - proven.sign(&mut rng, isk).unwrap() + proven.sign(rng, isk).unwrap() } fn build_and_sign_bundle( @@ -95,7 +95,7 @@ fn build_and_sign_bundle( let sighash = unauthorized.commitment().into(); let proven = unauthorized.create_proof(pk, &mut rng).unwrap(); proven - .apply_signatures(&mut rng, sighash, &[SpendAuthorizingKey::from(sk)]) + .apply_signatures(rng, sighash, &[SpendAuthorizingKey::from(sk)]) .unwrap() } @@ -203,7 +203,7 @@ fn create_native_note(keys: &Keychain) -> Note { let unauthorized = builder.build(&mut rng).unwrap(); let sighash = unauthorized.commitment().into(); let proven = unauthorized.create_proof(keys.pk(), &mut rng).unwrap(); - proven.apply_signatures(&mut rng, sighash, &[]).unwrap() + proven.apply_signatures(rng, sighash, &[]).unwrap() }; let ivk = keys.fvk().to_ivk(Scope::External); let (native_note, _, _) = shielding_bundle