diff --git a/tower-fallback/tests/fallback.rs b/tower-fallback/tests/fallback.rs index 8b60481d7b8..486dfb4a47e 100644 --- a/tower-fallback/tests/fallback.rs +++ b/tower-fallback/tests/fallback.rs @@ -1,3 +1,5 @@ +//! Tests for tower-fallback + use tower::{service_fn, Service, ServiceExt}; use tower_fallback::Fallback; diff --git a/zebra-chain/src/chain_tip.rs b/zebra-chain/src/chain_tip.rs index 04e98ecbff7..5428ec58d13 100644 --- a/zebra-chain/src/chain_tip.rs +++ b/zebra-chain/src/chain_tip.rs @@ -139,7 +139,7 @@ impl<'f> BestTipChanged<'f> { } } -impl<'f> Future for BestTipChanged<'f> { +impl Future for BestTipChanged<'_> { type Output = Result<(), BoxError>; fn poll( diff --git a/zebra-chain/src/orchard/shielded_data.rs b/zebra-chain/src/orchard/shielded_data.rs index 5347919cd01..6dc7f38784a 100644 --- a/zebra-chain/src/orchard/shielded_data.rs +++ b/zebra-chain/src/orchard/shielded_data.rs @@ -270,6 +270,6 @@ impl ZcashDeserialize for Flags { // the reserved bits 2..7 of the flagsOrchard field MUST be zero." // https://zips.z.cash/protocol/protocol.pdf#txnencodingandconsensus Flags::from_bits(reader.read_u8()?) - .ok_or_else(|| SerializationError::Parse("invalid reserved orchard flags")) + .ok_or(SerializationError::Parse("invalid reserved orchard flags")) } } diff --git a/zebra-chain/src/serialization/tests.rs b/zebra-chain/src/serialization/tests.rs index a7ac2ac35a7..762df3c751b 100644 --- a/zebra-chain/src/serialization/tests.rs +++ b/zebra-chain/src/serialization/tests.rs @@ -1,2 +1,4 @@ +//! Serialization tests. + mod preallocate; mod prop; diff --git a/zebra-chain/src/transaction.rs b/zebra-chain/src/transaction.rs index 3df3edc8d53..96b2378e273 100644 --- a/zebra-chain/src/transaction.rs +++ b/zebra-chain/src/transaction.rs @@ -231,7 +231,7 @@ impl Transaction { &'a self, branch_id: ConsensusBranchId, all_previous_outputs: &'a [transparent::Output], - ) -> sighash::SigHasher { + ) -> sighash::SigHasher<'a> { sighash::SigHasher::new(self, branch_id, all_previous_outputs) } diff --git a/zebra-chain/src/transaction/serialize.rs b/zebra-chain/src/transaction/serialize.rs index 0e583efc5bf..47d1a4e4ad8 100644 --- a/zebra-chain/src/transaction/serialize.rs +++ b/zebra-chain/src/transaction/serialize.rs @@ -889,7 +889,7 @@ impl ZcashDeserialize for Transaction { // Convert it to a NetworkUpgrade let network_upgrade = NetworkUpgrade::from_branch_id(limited_reader.read_u32::()?) - .ok_or_else(|| { + .ok_or({ SerializationError::Parse( "expected a valid network upgrade from the consensus branch id", ) diff --git a/zebra-network/src/protocol/external/codec.rs b/zebra-network/src/protocol/external/codec.rs index 1c99b33621f..1df72aecaef 100644 --- a/zebra-network/src/protocol/external/codec.rs +++ b/zebra-network/src/protocol/external/codec.rs @@ -508,7 +508,9 @@ impl Codec { timestamp: Utc .timestamp_opt(reader.read_i64::()?, 0) .single() - .ok_or_else(|| Error::Parse("version timestamp is out of range for DateTime"))?, + .ok_or(Error::Parse( + "version timestamp is out of range for DateTime", + ))?, address_recv: AddrInVersion::zcash_deserialize(&mut reader)?, address_from: AddrInVersion::zcash_deserialize(&mut reader)?, nonce: Nonce(reader.read_u64::()?), diff --git a/zebra-scan/src/service.rs b/zebra-scan/src/service.rs index 200160ab3ae..ad4318b72b2 100644 --- a/zebra-scan/src/service.rs +++ b/zebra-scan/src/service.rs @@ -93,18 +93,18 @@ impl Service for ScanService { Request::Info => { let db = self.db.clone(); - return async move { + async move { Ok(Response::Info { min_sapling_birthday_height: db.network().sapling_activation_height(), }) } - .boxed(); + .boxed() } Request::RegisterKeys(keys) => { let mut scan_task = self.scan_task.clone(); - return async move { + async move { let newly_registered_keys = scan_task.register_keys(keys)?.await?; if !newly_registered_keys.is_empty() { Ok(Response::RegisteredKeys(newly_registered_keys)) @@ -113,14 +113,14 @@ impl Service for ScanService { are valid Sapling extended full viewing keys".into()) } } - .boxed(); + .boxed() } Request::DeleteKeys(keys) => { let mut db = self.db.clone(); let mut scan_task = self.scan_task.clone(); - return async move { + async move { // Wait for a message to confirm that the scan task has removed the key up to `DELETE_KEY_TIMEOUT` let remove_keys_result = tokio::time::timeout( DELETE_KEY_TIMEOUT, @@ -141,13 +141,13 @@ impl Service for ScanService { Ok(Response::DeletedKeys) } - .boxed(); + .boxed() } Request::Results(keys) => { let db = self.db.clone(); - return async move { + async move { let mut final_result = BTreeMap::new(); for key in keys { let db = db.clone(); @@ -168,26 +168,26 @@ impl Service for ScanService { Ok(Response::Results(final_result)) } - .boxed(); + .boxed() } Request::SubscribeResults(keys) => { let mut scan_task = self.scan_task.clone(); - return async move { + async move { let results_receiver = scan_task.subscribe(keys)?.await.map_err(|_| { "scan task dropped responder, check that keys are registered" })?; Ok(Response::SubscribeResults(results_receiver)) } - .boxed(); + .boxed() } Request::ClearResults(keys) => { let mut db = self.db.clone(); - return async move { + async move { // Clear results from db for the provided `keys` tokio::task::spawn_blocking(move || { db.delete_sapling_results(keys); @@ -196,7 +196,7 @@ impl Service for ScanService { Ok(Response::ClearedResults) } - .boxed(); + .boxed() } } } diff --git a/zebra-scan/src/storage/db/sapling.rs b/zebra-scan/src/storage/db/sapling.rs index b3c7b870b42..a51ea861eab 100644 --- a/zebra-scan/src/storage/db/sapling.rs +++ b/zebra-scan/src/storage/db/sapling.rs @@ -265,7 +265,7 @@ trait InsertSaplingHeight { fn insert_sapling_height(self, sapling_key: &SaplingScanningKey, height: Height) -> Self; } -impl<'cf> InsertSaplingHeight for WriteSaplingTxIdsBatch<'cf> { +impl InsertSaplingHeight for WriteSaplingTxIdsBatch<'_> { /// Insert sapling height with no results. /// /// If a result already exists for the coinbase transaction at that height, @@ -283,7 +283,7 @@ trait DeleteSaplingKeys { fn delete_sapling_keys(self, sapling_key: Vec) -> Self; } -impl<'cf> DeleteSaplingKeys for WriteSaplingTxIdsBatch<'cf> { +impl DeleteSaplingKeys for WriteSaplingTxIdsBatch<'_> { /// Delete sapling keys and their results. fn delete_sapling_keys(mut self, sapling_keys: Vec) -> Self { for key in &sapling_keys { diff --git a/zebra-scan/tests/scan_task_commands.rs b/zebra-scan/tests/scan_task_commands.rs index 20bbcca190d..20c4edfe757 100644 --- a/zebra-scan/tests/scan_task_commands.rs +++ b/zebra-scan/tests/scan_task_commands.rs @@ -5,7 +5,7 @@ //! //! export ZEBRA_CACHED_STATE_DIR="/path/to/zebra/state" //! cargo test scan_task_commands --features="shielded-scan" -- --ignored --nocapture -#![allow(dead_code)] +#![allow(dead_code, non_local_definitions)] use std::{fs, time::Duration}; @@ -26,6 +26,7 @@ use zebra_scan::{ use zebra_state::{ChainTipChange, LatestChainTip}; +/// Boxed state service. pub type BoxStateService = BoxService; @@ -162,6 +163,7 @@ pub(crate) async fn run() -> Result<()> { Ok(()) } +/// Starts the state service with the provided cache directory. pub async fn start_state_service_with_cache_dir( network: &Network, cache_dir: impl Into, diff --git a/zebra-state/src/service/finalized_state/column_family.rs b/zebra-state/src/service/finalized_state/column_family.rs index 2befbf131e2..dbd017835fb 100644 --- a/zebra-state/src/service/finalized_state/column_family.rs +++ b/zebra-state/src/service/finalized_state/column_family.rs @@ -63,7 +63,7 @@ where batch: Batch, } -impl<'cf, Key, Value> Debug for TypedColumnFamily<'cf, Key, Value> +impl Debug for TypedColumnFamily<'_, Key, Value> where Key: IntoDisk + FromDisk + Debug, Value: IntoDisk + FromDisk, @@ -80,7 +80,7 @@ where } } -impl<'cf, Key, Value> PartialEq for TypedColumnFamily<'cf, Key, Value> +impl PartialEq for TypedColumnFamily<'_, Key, Value> where Key: IntoDisk + FromDisk + Debug, Value: IntoDisk + FromDisk, @@ -90,7 +90,7 @@ where } } -impl<'cf, Key, Value> Eq for TypedColumnFamily<'cf, Key, Value> +impl Eq for TypedColumnFamily<'_, Key, Value> where Key: IntoDisk + FromDisk + Debug, Value: IntoDisk + FromDisk, @@ -243,7 +243,7 @@ where } } -impl<'cf, Key, Value> TypedColumnFamily<'cf, Key, Value> +impl TypedColumnFamily<'_, Key, Value> where Key: IntoDisk + FromDisk + Debug + Ord, Value: IntoDisk + FromDisk, @@ -259,7 +259,7 @@ where } } -impl<'cf, Key, Value> TypedColumnFamily<'cf, Key, Value> +impl TypedColumnFamily<'_, Key, Value> where Key: IntoDisk + FromDisk + Debug + Hash + Eq, Value: IntoDisk + FromDisk, @@ -275,7 +275,7 @@ where } } -impl<'cf, Key, Value, Batch> WriteTypedBatch<'cf, Key, Value, Batch> +impl WriteTypedBatch<'_, Key, Value, Batch> where Key: IntoDisk + FromDisk + Debug, Value: IntoDisk + FromDisk, @@ -312,7 +312,7 @@ where } // Writing a batch to the database requires an owned batch. -impl<'cf, Key, Value> WriteTypedBatch<'cf, Key, Value, DiskWriteBatch> +impl WriteTypedBatch<'_, Key, Value, DiskWriteBatch> where Key: IntoDisk + FromDisk + Debug, Value: IntoDisk + FromDisk, diff --git a/zebra-state/src/service/finalized_state/disk_format.rs b/zebra-state/src/service/finalized_state/disk_format.rs index 0ce04431e54..459c370aaed 100644 --- a/zebra-state/src/service/finalized_state/disk_format.rs +++ b/zebra-state/src/service/finalized_state/disk_format.rs @@ -68,7 +68,7 @@ pub trait FromDisk: Sized { // Generic serialization impls -impl<'a, T> IntoDisk for &'a T +impl IntoDisk for &T where T: IntoDisk, { diff --git a/zebra-state/src/service/non_finalized_state/chain.rs b/zebra-state/src/service/non_finalized_state/chain.rs index 12ee0528776..eb00fbda3a5 100644 --- a/zebra-state/src/service/non_finalized_state/chain.rs +++ b/zebra-state/src/service/non_finalized_state/chain.rs @@ -1272,7 +1272,7 @@ impl Chain { pub fn partial_transparent_indexes<'a>( &'a self, addresses: &'a HashSet, - ) -> impl Iterator { + ) -> impl Iterator { addresses .iter() .flat_map(|address| self.partial_transparent_transfers.get(address)) diff --git a/zebrad/src/commands.rs b/zebrad/src/commands.rs index 9751f8693e1..92c0619e6d3 100644 --- a/zebrad/src/commands.rs +++ b/zebrad/src/commands.rs @@ -1,5 +1,7 @@ //! Zebrad Subcommands +#![allow(non_local_definitions)] + use std::path::PathBuf; use abscissa_core::{config::Override, Command, Configurable, FrameworkError, Runnable}; diff --git a/zebrad/src/components/metrics.rs b/zebrad/src/components/metrics.rs index 5527d37747c..462eeb335d2 100644 --- a/zebrad/src/components/metrics.rs +++ b/zebrad/src/components/metrics.rs @@ -1,5 +1,7 @@ //! An HTTP endpoint for metrics collection. +#![allow(non_local_definitions)] + use std::net::SocketAddr; use abscissa_core::{Component, FrameworkError}; diff --git a/zebrad/src/components/tokio.rs b/zebrad/src/components/tokio.rs index 7478022dda1..dab20d5352f 100644 --- a/zebrad/src/components/tokio.rs +++ b/zebrad/src/components/tokio.rs @@ -7,6 +7,8 @@ //! The rayon thread pool is used for: //! - long-running CPU-bound tasks like cryptography, via [`rayon::spawn_fifo`]. +#![allow(non_local_definitions)] + use std::{future::Future, time::Duration}; use abscissa_core::{Component, FrameworkError, Shutdown}; diff --git a/zebrad/src/components/tracing/endpoint.rs b/zebrad/src/components/tracing/endpoint.rs index b5cb4a9da37..80631ac41bb 100644 --- a/zebrad/src/components/tracing/endpoint.rs +++ b/zebrad/src/components/tracing/endpoint.rs @@ -1,5 +1,7 @@ //! An HTTP endpoint for dynamically setting tracing filters. +#![allow(non_local_definitions)] + use std::net::SocketAddr; use abscissa_core::{Component, FrameworkError};