From c95b926fbf78b59e45d7bfd3f148104c725d27ab Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Wed, 30 Apr 2025 08:57:59 -0600 Subject: [PATCH] Fix clippy complaints. --- .github/workflows/ci.yml | 3 +++ zcash_client_backend/src/tor/http.rs | 2 +- zcash_client_sqlite/CHANGELOG.md | 5 +++++ zcash_client_sqlite/src/wallet/init.rs | 16 +++++++++------- zcash_primitives/src/merkle_tree.rs | 3 --- zcash_proofs/src/downloadreader.rs | 4 ++-- zcash_proofs/src/lib.rs | 5 ++--- 7 files changed, 22 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5ea6d2212d..c6b1449b2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -410,7 +410,10 @@ jobs: uses: ./.github/actions/prepare - uses: dtolnay/rust-toolchain@beta id: toolchain + with: + components: clippy - run: rustup override set "${TOOLCHAIN}" + shell: sh env: TOOLCHAIN: ${{steps.toolchain.outputs.name}} - name: Run Clippy (beta) diff --git a/zcash_client_backend/src/tor/http.rs b/zcash_client_backend/src/tor/http.rs index 33d2abb647..ca6306ec08 100644 --- a/zcash_client_backend/src/tor/http.rs +++ b/zcash_client_backend/src/tor/http.rs @@ -62,7 +62,7 @@ impl Client { // // https://gitlab.torproject.org/tpo/core/arti/-/issues/715 let root_store = RootCertStore { - roots: webpki_roots::TLS_SERVER_ROOTS.iter().cloned().collect(), + roots: webpki_roots::TLS_SERVER_ROOTS.to_vec(), }; let config = ClientConfig::builder() .with_root_certificates(root_store) diff --git a/zcash_client_sqlite/CHANGELOG.md b/zcash_client_sqlite/CHANGELOG.md index dacb1cef9b..f46d4de6d2 100644 --- a/zcash_client_sqlite/CHANGELOG.md +++ b/zcash_client_sqlite/CHANGELOG.md @@ -11,6 +11,11 @@ and this library adheres to Rust's notion of - `zcash_client_sqlite::wallet::init::WalletMigrator` - `zcash_client_sqlite::wallet::init::migrations` +### Changed +- `zcash_client_sqlite::wallet::init::WalletMigrationError::` + - Variants `WalletMigrationError::CommitmentTree` and + `WalletMigrationError::Other` now `Box` their contents. + ## [0.16.2] - 2025-04-02 ### Fixed diff --git a/zcash_client_sqlite/src/wallet/init.rs b/zcash_client_sqlite/src/wallet/init.rs index 1132f3d36e..21171c0e94 100644 --- a/zcash_client_sqlite/src/wallet/init.rs +++ b/zcash_client_sqlite/src/wallet/init.rs @@ -61,13 +61,13 @@ pub enum WalletMigrationError { BalanceError(BalanceError), /// Wrapper for commitment tree invariant violations - CommitmentTree(ShardTreeError), + CommitmentTree(Box>), /// Reverting the specified migration is not supported. CannotRevert(Uuid), /// Some other unexpected violation of database business rules occurred - Other(SqliteClientError), + Other(Box), } impl From for WalletMigrationError { @@ -84,7 +84,7 @@ impl From for WalletMigrationError { impl From> for WalletMigrationError { fn from(e: ShardTreeError) -> Self { - WalletMigrationError::CommitmentTree(e) + WalletMigrationError::CommitmentTree(Box::new(e)) } } @@ -99,12 +99,14 @@ impl From for WalletMigrationError { match value { SqliteClientError::CorruptedData(err) => WalletMigrationError::CorruptedData(err), SqliteClientError::DbError(err) => WalletMigrationError::DbError(err), - SqliteClientError::CommitmentTree(err) => WalletMigrationError::CommitmentTree(err), + SqliteClientError::CommitmentTree(err) => { + WalletMigrationError::CommitmentTree(Box::new(err)) + } SqliteClientError::BalanceError(err) => WalletMigrationError::BalanceError(err), SqliteClientError::AddressGeneration(err) => { WalletMigrationError::AddressGeneration(err) } - other => WalletMigrationError::Other(other), + other => WalletMigrationError::Other(Box::new(other)), } } } @@ -193,7 +195,7 @@ fn sqlite_client_error_to_wallet_migration_error(e: SqliteClientError) -> Wallet SqliteClientError::InvalidMemo(e) => WalletMigrationError::CorruptedData(e.to_string()), SqliteClientError::AddressGeneration(e) => WalletMigrationError::AddressGeneration(e), SqliteClientError::BadAccountData(e) => WalletMigrationError::CorruptedData(e), - SqliteClientError::CommitmentTree(e) => WalletMigrationError::CommitmentTree(e), + SqliteClientError::CommitmentTree(e) => WalletMigrationError::CommitmentTree(Box::new(e)), SqliteClientError::UnsupportedPoolType(pool) => WalletMigrationError::CorruptedData( format!("Wallet DB contains unsupported pool type {}", pool), ), @@ -239,7 +241,7 @@ fn sqlite_client_error_to_wallet_migration_error(e: SqliteClientError) -> Wallet } #[cfg(feature = "transparent-inputs")] SqliteClientError::Scheduling(e) => { - WalletMigrationError::Other(SqliteClientError::Scheduling(e)) + WalletMigrationError::Other(Box::new(SqliteClientError::Scheduling(e))) } } } diff --git a/zcash_primitives/src/merkle_tree.rs b/zcash_primitives/src/merkle_tree.rs index f712634fb1..2a57409c6d 100644 --- a/zcash_primitives/src/merkle_tree.rs +++ b/zcash_primitives/src/merkle_tree.rs @@ -137,7 +137,6 @@ pub fn write_nonempty_frontier_v1( Ok(()) } -#[allow(clippy::redundant_closure)] pub fn read_nonempty_frontier_v1( mut reader: R, ) -> io::Result> { @@ -169,7 +168,6 @@ pub fn write_frontier_v1( Optional::write(writer, frontier.value(), write_nonempty_frontier_v1) } -#[allow(clippy::redundant_closure)] pub fn read_frontier_v1(reader: R) -> io::Result> { match Optional::read(reader, read_nonempty_frontier_v1)? { None => Ok(Frontier::empty()), @@ -211,7 +209,6 @@ pub fn write_commitment_tree( } /// Reads an `IncrementalWitness` from its serialized form. -#[allow(clippy::redundant_closure)] pub fn read_incremental_witness( mut reader: R, ) -> io::Result> { diff --git a/zcash_proofs/src/downloadreader.rs b/zcash_proofs/src/downloadreader.rs index 04f46d1bf4..5e72acdc5e 100644 --- a/zcash_proofs/src/downloadreader.rs +++ b/zcash_proofs/src/downloadreader.rs @@ -62,7 +62,7 @@ impl io::Read for ResponseLazyReader { let error = format!("download response failed: {:?}", error); *self = Complete(Err(error.clone())); - return Err(io::Error::new(io::ErrorKind::Other, error)); + return Err(io::Error::other(error)); } } } @@ -75,7 +75,7 @@ impl io::Read for ResponseLazyReader { // Return a zero-byte read for download success and EOF. Ok(()) => Ok(0), // Keep returning the download error, - Err(error) => Err(io::Error::new(io::ErrorKind::Other, error.clone())), + Err(error) => Err(io::Error::other(error.clone())), }; } } diff --git a/zcash_proofs/src/lib.rs b/zcash_proofs/src/lib.rs index e9d63255cc..bfbacc0fcf 100644 --- a/zcash_proofs/src/lib.rs +++ b/zcash_proofs/src/lib.rs @@ -164,9 +164,8 @@ fn fetch_params( timeout: Option, ) -> Result { // Ensure that the default Zcash parameters location exists. - let params_dir = default_params_folder().ok_or_else(|| { - io::Error::new(io::ErrorKind::Other, "Could not load default params folder") - })?; + let params_dir = default_params_folder() + .ok_or_else(|| io::Error::other("Could not load default params folder"))?; std::fs::create_dir_all(¶ms_dir)?; let params_path = params_dir.join(name);