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 31, 2025
1 parent 32cc376 commit 0fa362f
Show file tree
Hide file tree
Showing 21 changed files with 34 additions and 35 deletions.
2 changes: 1 addition & 1 deletion components/zcash_protocol/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ pub trait Parameters: Clone {
/// Determines whether the specified network upgrade is active as of the
/// provided block height on the network to which this Parameters value applies.
fn is_nu_active(&self, nu: NetworkUpgrade, height: BlockHeight) -> bool {
self.activation_height(nu).map_or(false, |h| h <= height)
self.activation_height(nu).is_some_and(|h| h <= height)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pczt/src/roles/creator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl Creator {
// Spends and outputs not modifiable.
let mut tx_modifiable = 0b0000_0000;
// Check if any input is using `SIGHASH_SINGLE` (with or without `ANYONECANPAY`).
if parts.transparent.as_ref().map_or(false, |bundle| {
if parts.transparent.as_ref().is_some_and(|bundle| {

Check warning on line 123 in pczt/src/roles/creator/mod.rs

View check run for this annotation

Codecov / codecov/patch

pczt/src/roles/creator/mod.rs#L123

Added line #L123 was not covered by tests
bundle.inputs().iter().any(|input| {
(input.sighash_type().encode() & !SIGHASH_ANYONECANPAY) == SIGHASH_SINGLE
})
Expand Down
2 changes: 1 addition & 1 deletion pczt/src/roles/redactor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Redactor {
/// An Redactor for the global transaction details.
pub struct GlobalRedactor<'a>(&'a mut Global);

impl<'a> GlobalRedactor<'a> {
impl GlobalRedactor<'_> {
/// Redacts the proprietary value at the given key.
pub fn redact_proprietary(&mut self, key: &str) {
self.0.proprietary.remove(key);
Expand Down
4 changes: 2 additions & 2 deletions pczt/src/roles/redactor/orchard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl super::Redactor {
/// A Redactor for the Orchard bundle.
pub struct OrchardRedactor<'a>(&'a mut Bundle);

impl<'a> OrchardRedactor<'a> {
impl OrchardRedactor<'_> {
/// Redacts all actions in the same way.
pub fn redact_actions<F>(&mut self, f: F)
where
Expand Down Expand Up @@ -54,7 +54,7 @@ enum Actions<'a> {
One(&'a mut Action),
}

impl<'a> ActionRedactor<'a> {
impl ActionRedactor<'_> {
fn redact<F>(&mut self, f: F)
where
F: Fn(&mut Action),
Expand Down
6 changes: 3 additions & 3 deletions pczt/src/roles/redactor/sapling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl super::Redactor {
/// A Redactor for the Sapling bundle.
pub struct SaplingRedactor<'a>(&'a mut Bundle);

impl<'a> SaplingRedactor<'a> {
impl SaplingRedactor<'_> {
/// Redacts all spends in the same way.
pub fn redact_spends<F>(&mut self, f: F)
where
Expand Down Expand Up @@ -69,7 +69,7 @@ enum Spends<'a> {
One(&'a mut Spend),
}

impl<'a> SpendRedactor<'a> {
impl SpendRedactor<'_> {
fn redact<F>(&mut self, f: F)
where
F: Fn(&mut Spend),
Expand Down Expand Up @@ -194,7 +194,7 @@ enum Outputs<'a> {
One(&'a mut Output),
}

impl<'a> OutputRedactor<'a> {
impl OutputRedactor<'_> {
fn redact<F>(&mut self, f: F)
where
F: Fn(&mut Output),
Expand Down
6 changes: 3 additions & 3 deletions pczt/src/roles/redactor/transparent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl super::Redactor {
/// A Redactor for the transparent bundle.
pub struct TransparentRedactor<'a>(&'a mut Bundle);

impl<'a> TransparentRedactor<'a> {
impl TransparentRedactor<'_> {
/// Redacts all inputs in the same way.
pub fn redact_inputs<F>(&mut self, f: F)
where
Expand Down Expand Up @@ -64,7 +64,7 @@ enum Inputs<'a> {
One(&'a mut Input),
}

impl<'a> InputRedactor<'a> {
impl InputRedactor<'_> {
fn redact<F>(&mut self, f: F)
where
F: Fn(&mut Input),
Expand Down Expand Up @@ -202,7 +202,7 @@ enum Outputs<'a> {
One(&'a mut Output),
}

impl<'a> OutputRedactor<'a> {
impl OutputRedactor<'_> {
fn redact<F>(&mut self, f: F)
where
F: Fn(&mut Output),
Expand Down
2 changes: 1 addition & 1 deletion pczt/src/roles/updater/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl Updater {
/// An updater for a transparent PCZT output.
pub struct GlobalUpdater<'a>(&'a mut Global);

impl<'a> GlobalUpdater<'a> {
impl GlobalUpdater<'_> {
/// Stores the given proprietary value at the given key.
pub fn set_proprietary(&mut self, key: String, value: Vec<u8>) {
self.0.proprietary.insert(key, value);
Expand Down
2 changes: 1 addition & 1 deletion zcash_client_backend/src/data_api/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1745,7 +1745,7 @@ pub trait TestFvk: Clone {
) -> Self::Nullifier;
}

impl<'a, A: TestFvk> TestFvk for &'a A {
impl<A: TestFvk> TestFvk for &A {
type Nullifier = A::Nullifier;

fn sapling_ovk(&self) -> Option<::sapling::keys::OutgoingViewingKey> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ impl<DbT: InputSource> InputSelector for GreedyInputSelector<DbT> {
.expect("cannot fail because memo is None"),
);
total_ephemeral = (total_ephemeral + payment.amount())
.ok_or_else(|| GreedyInputSelectorError::Balance(BalanceError::Overflow))?;
.ok_or(GreedyInputSelectorError::Balance(BalanceError::Overflow))?;
}
#[cfg(not(feature = "transparent-inputs"))]
Address::Tex(_) => {
Expand Down
4 changes: 2 additions & 2 deletions zcash_client_backend/src/fees/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,8 @@ pub(crate) fn check_for_uneconomic_inputs<NoteRefT: Clone, E>(
}

let (t_inputs_len, t_outputs_len) = (
transparent_inputs.len() + usize::from(ephemeral_balance.map_or(false, |b| b.is_input())),
transparent_outputs.len() + usize::from(ephemeral_balance.map_or(false, |b| b.is_output())),
transparent_inputs.len() + usize::from(ephemeral_balance.is_some_and(|b| b.is_input())),
transparent_outputs.len() + usize::from(ephemeral_balance.is_some_and(|b| b.is_output())),

Check warning on line 645 in zcash_client_backend/src/fees/common.rs

View check run for this annotation

Codecov / codecov/patch

zcash_client_backend/src/fees/common.rs#L645

Added line #L645 was not covered by tests
);
let (s_inputs_len, s_outputs_len) = (sapling.inputs().len(), sapling.outputs().len());
#[cfg(feature = "orchard")]
Expand Down
2 changes: 1 addition & 1 deletion zcash_client_backend/src/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl<IvkTag, D: Domain, M> DynamicUsage for BatchReceiver<IvkTag, D, M> {
// linked list. `crossbeam_channel` allocates memory for the linked list in blocks
// of 31 items.
const ITEMS_PER_BLOCK: usize = 31;
let num_blocks = (num_items + ITEMS_PER_BLOCK - 1) / ITEMS_PER_BLOCK;
let num_blocks = num_items.div_ceil(ITEMS_PER_BLOCK);

Check warning on line 148 in zcash_client_backend/src/scan.rs

View check run for this annotation

Codecov / codecov/patch

zcash_client_backend/src/scan.rs#L148

Added line #L148 was not covered by tests

// The structure of a block is:
// - A pointer to the next block.
Expand Down
5 changes: 2 additions & 3 deletions zcash_client_sqlite/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ impl<C: Borrow<rusqlite::Connection>, P: consensus::Parameters> WalletRead for W
}

fn get_account_birthday(&self, account: Self::AccountId) -> Result<BlockHeight, Self::Error> {
wallet::account_birthday(self.conn.borrow(), account).map_err(SqliteClientError::from)
wallet::account_birthday(self.conn.borrow(), account)

Check warning on line 621 in zcash_client_sqlite/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

zcash_client_sqlite/src/lib.rs#L621

Added line #L621 was not covered by tests
}

fn get_wallet_birthday(&self) -> Result<Option<BlockHeight>, Self::Error> {
Expand Down Expand Up @@ -665,7 +665,6 @@ impl<C: Borrow<rusqlite::Connection>, P: consensus::Parameters> WalletRead for W

fn suggest_scan_ranges(&self) -> Result<Vec<ScanRange>, Self::Error> {
wallet::scanning::suggest_scan_ranges(self.conn.borrow(), ScanPriority::Historic)
.map_err(SqliteClientError::from)
}

fn get_target_and_anchor_heights(
Expand Down Expand Up @@ -1780,7 +1779,7 @@ impl<C: BorrowMut<rusqlite::Connection>, P: consensus::Parameters> WalletCommitm
}
}

impl<'conn, P: consensus::Parameters> WalletCommitmentTrees for WalletDb<SqlTransaction<'conn>, P> {
impl<P: consensus::Parameters> WalletCommitmentTrees for WalletDb<SqlTransaction<'_>, P> {
type Error = commitment_tree::Error;
type SaplingShardStore<'a> =
SqliteShardStore<&'a rusqlite::Transaction<'a>, sapling::Node, SAPLING_SHARD_HEIGHT>;
Expand Down
1 change: 1 addition & 0 deletions zcash_client_sqlite/src/wallet/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ pub(super) const INDEX_HD_ACCOUNT: &str =
/// sequential transparent addresses.
/// - Transparent change addresses.
/// - ZIP 320 ephemeral addresses.
///
/// This column exists because the diversifier index is stored as a byte array, meaning that we
/// cannot use SQL integer operations on it for gap limit calculations, and thus need it as an
/// integer as well.
Expand Down
2 changes: 1 addition & 1 deletion zcash_history/src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ pub struct IndexedNode<'a, V: Version> {
link: EntryLink,
}

impl<'a, V: Version> IndexedNode<'a, V> {
impl<V: Version> IndexedNode<'_, V> {
fn left(&self) -> Result<EntryLink, Error> {
self.node.left().map_err(|e| e.augment(self.link))
}
Expand Down
6 changes: 3 additions & 3 deletions zcash_primitives/src/transaction/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ pub struct Builder<'a, P, U: sapling::builder::ProverProgress> {
_progress_notifier: U,
}

impl<'a, P, U: sapling::builder::ProverProgress> Builder<'a, P, U> {
impl<P, U: sapling::builder::ProverProgress> Builder<'_, P, U> {
/// Returns the network parameters that the builder has been configured for.
pub fn params(&self) -> &P {
&self.params
Expand Down Expand Up @@ -424,7 +424,7 @@ impl<'a, P: consensus::Parameters> Builder<'a, P, ()> {
}
}

impl<'a, P: consensus::Parameters, U: sapling::builder::ProverProgress> Builder<'a, P, U> {
impl<P: consensus::Parameters, U: sapling::builder::ProverProgress> Builder<'_, P, U> {
/// Adds an Orchard note to be spent in this bundle.
///
/// Returns an error if the given Merkle path does not have the required anchor for
Expand Down Expand Up @@ -1011,7 +1011,7 @@ mod testing {
use super::{BuildResult, Builder, Error};
use crate::transaction::fees::zip317;

impl<'a, P: consensus::Parameters, U: sapling::builder::ProverProgress> Builder<'a, P, U> {
impl<P: consensus::Parameters, U: sapling::builder::ProverProgress> Builder<'_, P, U> {
/// Build the transaction using mocked randomness and proving capabilities.
/// DO NOT USE EXCEPT FOR UNIT TESTING.
pub fn mock_build<R: RngCore>(
Expand Down
2 changes: 1 addition & 1 deletion zcash_primitives/src/transaction/fees/zip317.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl super::FeeRule for FeeRule {

let t_out_total_size = transparent_output_sizes.into_iter().sum();

let ceildiv = |num: usize, den: usize| (num + den - 1) / den;
let ceildiv = |num: usize, den: usize| num.div_ceil(den);

let logical_actions = max(
ceildiv(t_in_total_size, self.p2pkh_standard_input_size),
Expand Down
2 changes: 1 addition & 1 deletion zcash_primitives/src/transaction/sighash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub enum SignableInput<'a> {
},
}

impl<'a> SignableInput<'a> {
impl SignableInput<'_> {
pub fn hash_type(&self) -> u8 {
match self {
SignableInput::Shielded => ::transparent::sighash::SIGHASH_ALL,
Expand Down
2 changes: 1 addition & 1 deletion zcash_proofs/src/circuit/sprout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ where
let mut tmp = vec![];
for b in value
.iter()
.flat_map(|&m| (0..8).rev().map(move |i| m >> i & 1 == 1))
.flat_map(|&m| (0..8).rev().map(move |i| (m >> i) & 1 == 1))

Check warning on line 297 in zcash_proofs/src/circuit/sprout/mod.rs

View check run for this annotation

Codecov / codecov/patch

zcash_proofs/src/circuit/sprout/mod.rs#L297

Added line #L297 was not covered by tests
.skip(skip_bits)
{
tmp.push(Some(b));
Expand Down
2 changes: 1 addition & 1 deletion zcash_transparent/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ pub struct Script(pub Vec<u8>);
impl fmt::Debug for Script {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
struct ScriptPrinter<'s>(&'s [u8]);
impl<'s> fmt::Debug for ScriptPrinter<'s> {
impl fmt::Debug for ScriptPrinter<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut l = f.debug_list();
let mut unknown: Option<String> = None;
Expand Down
7 changes: 3 additions & 4 deletions zcash_transparent/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,14 @@ impl TransparentAuthorizingContext for Unauthorized {
#[cfg(feature = "transparent-inputs")]
impl TransparentAuthorizingContext for Unauthorized {
fn input_amounts(&self) -> Vec<Zatoshis> {
return self.inputs.iter().map(|txin| txin.coin.value).collect();
self.inputs.iter().map(|txin| txin.coin.value).collect()
}

fn input_scriptpubkeys(&self) -> Vec<Script> {
return self
.inputs
self.inputs
.iter()
.map(|txin| txin.coin.script_pubkey.clone())
.collect();
.collect()
}
}

Expand Down
6 changes: 3 additions & 3 deletions zcash_transparent/src/pczt/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl Bundle {
/// An updater for a transparent PCZT bundle.
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 Down Expand Up @@ -58,7 +58,7 @@ impl<'a> Updater<'a> {
/// An updater for a transparent PCZT input.
pub struct InputUpdater<'a>(&'a mut Input);

impl<'a> InputUpdater<'a> {
impl InputUpdater<'_> {
/// Sets the redeem script for this input.
///
/// Returns an error if the input is not P2SH, or the given `redeem_script` does not
Expand Down Expand Up @@ -114,7 +114,7 @@ impl<'a> InputUpdater<'a> {
/// An updater for a transparent PCZT output.
pub struct OutputUpdater<'a>(&'a mut Output);

impl<'a> OutputUpdater<'a> {
impl OutputUpdater<'_> {
/// Sets the redeem script for this output.
///
/// Returns an error if the output is not P2SH, or the given `redeem_script` does not
Expand Down

0 comments on commit 0fa362f

Please sign in to comment.