Skip to content

Commit

Permalink
Fix Clippy beta lints
Browse files Browse the repository at this point in the history
  • Loading branch information
nuttycom committed Jan 29, 2025
1 parent 4c2fcc6 commit 11b4b0b
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 21 deletions.
8 changes: 3 additions & 5 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ impl Builder {
.iter()
.map(|output| NoteValue::zero() - output.value),
)
.fold(Some(ValueSum::zero()), |acc, note_value| acc? + note_value)
.try_fold(ValueSum::zero(), |acc, note_value| acc + note_value)
.ok_or(OverflowError)?;
i64::try_from(value_balance).and_then(|i| V::try_from(i).map_err(|_| value::OverflowError))
}
Expand Down Expand Up @@ -813,7 +813,7 @@ fn build_bundle<B, R: RngCore>(
let mut bundle_meta = BundleMetadata::new(num_requested_spends, num_requested_outputs);
let pre_actions = indexed_spends
.into_iter()
.zip(indexed_outputs.into_iter())
.zip(indexed_outputs)
.enumerate()
.map(|(action_idx, ((spend_idx, spend), (out_idx, output)))| {
// Record the post-randomization spend location
Expand All @@ -836,9 +836,7 @@ fn build_bundle<B, R: RngCore>(
// Determine the value balance for this bundle, ensuring it is valid.
let value_balance = pre_actions
.iter()
.fold(Some(ValueSum::zero()), |acc, action| {
acc? + action.value_sum()
})
.try_fold(ValueSum::zero(), |acc, action| acc + action.value_sum())
.ok_or(OverflowError)?;

finisher(pre_actions, flags, value_balance, bundle_meta, rng)
Expand Down
2 changes: 1 addition & 1 deletion src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl<T: Authorization, V: fmt::Debug> fmt::Debug for Bundle<T, V> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// Helper struct for debug-printing actions without exposing `NonEmpty`.
struct Actions<'a, T>(&'a NonEmpty<Action<T>>);
impl<'a, T: fmt::Debug> fmt::Debug for Actions<'a, T> {
impl<T: fmt::Debug> fmt::Debug for Actions<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_list().entries(self.0.iter()).finish()
}
Expand Down
4 changes: 2 additions & 2 deletions src/bundle/commitments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ fn hasher(personal: &[u8; 16]) -> State {
Params::new().hash_length(32).personal(personal).to_state()
}

/// Write disjoint parts of each Orchard shielded action as 3 separate hashes:
/// Write disjoint parts of each Orchard shielded action as 3 separate hashes
/// as defined in [ZIP-244: Transaction Identifier Non-Malleability][zip244]:
/// * \[(nullifier, cmx, ephemeral_key, enc_ciphertext\[..52\])*\] personalized
/// with ZCASH_ORCHARD_ACTIONS_COMPACT_HASH_PERSONALIZATION
/// * \[enc_ciphertext\[52..564\]*\] (memo ciphertexts) personalized
/// with ZCASH_ORCHARD_ACTIONS_MEMOS_HASH_PERSONALIZATION
/// * \[(cv, rk, enc_ciphertext\[564..\], out_ciphertext)*\] personalized
/// with ZCASH_ORCHARD_ACTIONS_NONCOMPACT_HASH_PERSONALIZATION
/// as defined in [ZIP-244: Transaction Identifier Non-Malleability][zip244]
///
/// Then, hash these together along with (flags, value_balance_orchard, anchor_orchard),
/// personalized with ZCASH_ORCHARD_ACTIONS_HASH_PERSONALIZATION
Expand Down
2 changes: 1 addition & 1 deletion src/constants/fixed_bases/commit_ivk_r.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub const Z: [u64; super::NUM_WINDOWS] = [

/// Full-width u-values for GENERATOR.
/// These can be reproduced by [`halo2_gadgets::ecc::chip::constants::find_zs_and_us`].
pub const U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [
pub static U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [
[
[
38, 43, 235, 53, 200, 116, 153, 194, 47, 92, 18, 54, 194, 221, 170, 155, 205, 143, 92,
Expand Down
2 changes: 1 addition & 1 deletion src/constants/fixed_bases/note_commit_r.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub const Z: [u64; super::NUM_WINDOWS] = [

/// Full-width u-values for GENERATOR.
/// These can be reproduced by [`halo2_gadgets::ecc::chip::constants::find_zs_and_us`].
pub const U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [
pub static U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [
[
[
114, 245, 9, 0, 5, 43, 7, 118, 244, 43, 15, 200, 116, 210, 0, 24, 161, 28, 185, 152,
Expand Down
2 changes: 1 addition & 1 deletion src/constants/fixed_bases/nullifier_k.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub const Z: [u64; super::NUM_WINDOWS] = [

/// Full-width u-values for GENERATOR
/// These can be reproduced by [`halo2_gadgets::ecc::chip::constants::find_zs_and_us`].
pub const U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [
pub static U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [
[
[
8, 177, 117, 90, 104, 127, 169, 131, 254, 128, 23, 151, 181, 247, 22, 208, 55, 1, 147,
Expand Down
2 changes: 1 addition & 1 deletion src/constants/fixed_bases/spend_auth_g.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub const Z: [u64; super::NUM_WINDOWS] = [

/// Full-width u-values for GENERATOR.
/// These can be reproduced by [`halo2_gadgets::ecc::chip::constants::find_zs_and_us`].
pub const U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [
pub static U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [
[
[
134, 139, 159, 167, 179, 203, 183, 86, 54, 69, 108, 127, 183, 40, 226, 188, 34, 72,
Expand Down
2 changes: 1 addition & 1 deletion src/constants/fixed_bases/value_commit_r.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub const Z: [u64; super::NUM_WINDOWS] = [

/// Full-width u-values for GENERATOR.
/// These can be reproduced by [`halo2_gadgets::ecc::chip::constants::find_zs_and_us`].
pub const U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [
pub static U: [[[u8; 32]; super::H]; super::NUM_WINDOWS] = [
[
[
139, 239, 3, 113, 200, 111, 72, 118, 105, 23, 186, 243, 234, 10, 173, 186, 53, 143,
Expand Down
2 changes: 1 addition & 1 deletion src/note_encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ impl BatchDomain for OrchardDomain {
let (shared_secrets, ephemeral_keys): (Vec<_>, Vec<_>) = items.unzip();

SharedSecret::batch_to_affine(shared_secrets)
.zip(ephemeral_keys.into_iter())
.zip(ephemeral_keys)
.map(|(secret, ephemeral_key)| {
secret.map(|dhsecret| SharedSecret::kdf_orchard_inner(dhsecret, ephemeral_key))
})
Expand Down
4 changes: 2 additions & 2 deletions src/pczt/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl Bundle {
#[derive(Debug)]
pub struct Updater<'a>(&'a mut Bundle);

impl<'a> Updater<'a> {
impl Updater<'_> {
/// Provides read access to the bundle being updated.
pub fn bundle(&self) -> &Bundle {
self.0
Expand All @@ -42,7 +42,7 @@ impl<'a> Updater<'a> {
#[derive(Debug)]
pub struct ActionUpdater<'a>(&'a mut Action);

impl<'a> ActionUpdater<'a> {
impl ActionUpdater<'_> {
/// Sets the ZIP 32 derivation path for the spent note's signing key.
pub fn set_spend_zip32_derivation(&mut self, derivation: Zip32Derivation) {
self.0.spend.zip32_derivation = Some(derivation);
Expand Down
2 changes: 1 addition & 1 deletion src/primitives/redpallas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl<T: SigType> Eq for VerificationKey<T> {}

impl<T: SigType> PartialOrd for VerificationKey<T> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
<[u8; 32]>::from(self).partial_cmp(&<[u8; 32]>::from(other))
Some(self.cmp(other))
}
}

Expand Down
10 changes: 6 additions & 4 deletions src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,16 @@ impl Add for ValueSum {
}

impl<'a> Sum<&'a ValueSum> for Result<ValueSum, OverflowError> {
fn sum<I: Iterator<Item = &'a ValueSum>>(iter: I) -> Self {
iter.fold(Ok(ValueSum(0)), |acc, v| (acc? + *v).ok_or(OverflowError))
fn sum<I: Iterator<Item = &'a ValueSum>>(mut iter: I) -> Self {
iter.try_fold(ValueSum(0), |acc, v| acc + *v)
.ok_or(OverflowError)
}
}

impl Sum<ValueSum> for Result<ValueSum, OverflowError> {
fn sum<I: Iterator<Item = ValueSum>>(iter: I) -> Self {
iter.fold(Ok(ValueSum(0)), |acc, v| (acc? + v).ok_or(OverflowError))
fn sum<I: Iterator<Item = ValueSum>>(mut iter: I) -> Self {
iter.try_fold(ValueSum(0), |acc, v| acc + v)
.ok_or(OverflowError)
}
}

Expand Down

0 comments on commit 11b4b0b

Please sign in to comment.