fix(clippy): Fix new lints in nightly clippy (#5959)
* Derive default using #[default] * Implement PartialEq manually to satisfy clippy * Allow a manual derive in test-only code * Fix some missing docs warnings in the Docker build
This commit is contained in:
parent
7e5253e27f
commit
256b1c0008
|
|
@ -10,8 +10,6 @@
|
||||||
//!
|
//!
|
||||||
//! A root of a note commitment tree is associated with each treestate.
|
//! A root of a note commitment tree is associated with each treestate.
|
||||||
|
|
||||||
#![allow(clippy::derive_hash_xor_eq)]
|
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
fmt,
|
fmt,
|
||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
|
|
@ -99,7 +97,7 @@ lazy_static! {
|
||||||
/// The root hash in LEBS2OSP256(rt) encoding of the Orchard note commitment
|
/// The root hash in LEBS2OSP256(rt) encoding of the Orchard note commitment
|
||||||
/// tree corresponding to the final Orchard treestate of this block. A root of a
|
/// tree corresponding to the final Orchard treestate of this block. A root of a
|
||||||
/// note commitment tree is associated with each treestate.
|
/// note commitment tree is associated with each treestate.
|
||||||
#[derive(Clone, Copy, Default, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Default, Eq, Serialize, Deserialize)]
|
||||||
pub struct Root(#[serde(with = "serde_helpers::Base")] pub(crate) pallas::Base);
|
pub struct Root(#[serde(with = "serde_helpers::Base")] pub(crate) pallas::Base);
|
||||||
|
|
||||||
impl fmt::Debug for Root {
|
impl fmt::Debug for Root {
|
||||||
|
|
@ -128,6 +126,13 @@ impl Hash for Root {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PartialEq for Root {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
// TODO: should we compare canonical forms here using `.to_repr()`?
|
||||||
|
self.0 == other.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl TryFrom<[u8; 32]> for Root {
|
impl TryFrom<[u8; 32]> for Root {
|
||||||
type Error = SerializationError;
|
type Error = SerializationError;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
use std::{convert::From, fmt, str::FromStr};
|
//! Consensus parameters for each Zcash network.
|
||||||
|
|
||||||
|
use std::{fmt, str::FromStr};
|
||||||
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
|
|
@ -47,11 +49,13 @@ mod tests;
|
||||||
const ZIP_212_GRACE_PERIOD_DURATION: i32 = 32_256;
|
const ZIP_212_GRACE_PERIOD_DURATION: i32 = 32_256;
|
||||||
|
|
||||||
/// An enum describing the possible network choices.
|
/// An enum describing the possible network choices.
|
||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
|
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Hash, Serialize, Deserialize)]
|
||||||
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
|
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
|
||||||
pub enum Network {
|
pub enum Network {
|
||||||
/// The production mainnet.
|
/// The production mainnet.
|
||||||
|
#[default]
|
||||||
Mainnet,
|
Mainnet,
|
||||||
|
|
||||||
/// The testnet.
|
/// The testnet.
|
||||||
Testnet,
|
Testnet,
|
||||||
}
|
}
|
||||||
|
|
@ -114,12 +118,6 @@ impl Network {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Network {
|
|
||||||
fn default() -> Self {
|
|
||||||
Network::Mainnet
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FromStr for Network {
|
impl FromStr for Network {
|
||||||
type Err = InvalidNetworkError;
|
type Err = InvalidNetworkError;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
cmp::{Ord, Ordering},
|
cmp::{Ord, Ordering},
|
||||||
convert::TryInto,
|
|
||||||
net::SocketAddr,
|
net::SocketAddr,
|
||||||
time::Instant,
|
time::Instant,
|
||||||
};
|
};
|
||||||
|
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
|
|
||||||
use zebra_chain::{parameters::Network, serialization::DateTime32};
|
use zebra_chain::{parameters::Network, serialization::DateTime32};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
@ -80,6 +80,7 @@ impl PeerAddrState {
|
||||||
|
|
||||||
// non-test code should explicitly specify the peer address state
|
// non-test code should explicitly specify the peer address state
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(clippy::derivable_impls)]
|
||||||
impl Default for PeerAddrState {
|
impl Default for PeerAddrState {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
NeverAttemptedGossiped
|
NeverAttemptedGossiped
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
//! Tests for the [`zebra_test::command`] module.
|
||||||
|
|
||||||
use std::{process::Command, time::Duration};
|
use std::{process::Command, time::Duration};
|
||||||
|
|
||||||
use color_eyre::eyre::{eyre, Result};
|
use color_eyre::eyre::{eyre, Result};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
//! Tests for the [`zebra_test::transcript`] module.
|
||||||
|
|
||||||
use tower::{Service, ServiceExt};
|
use tower::{Service, ServiceExt};
|
||||||
use zebra_test::transcript::ExpectedTranscriptError;
|
|
||||||
use zebra_test::transcript::Transcript;
|
use zebra_test::transcript::{ExpectedTranscriptError, Transcript};
|
||||||
|
|
||||||
const TRANSCRIPT_DATA: [(&str, Result<&str, ExpectedTranscriptError>); 4] = [
|
const TRANSCRIPT_DATA: [(&str, Result<&str, ExpectedTranscriptError>); 4] = [
|
||||||
("req1", Ok("rsp1")),
|
("req1", Ok("rsp1")),
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ fn cmd_output(cmd: &mut std::process::Command) -> Result<String> {
|
||||||
Ok(s)
|
Ok(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Process entry point for `zebra-checkpoints`
|
||||||
#[allow(clippy::print_stdout)]
|
#[allow(clippy::print_stdout)]
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
// initialise
|
// initialise
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ fn disable_non_reproducible(_config: &mut Config) {
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Process entry point for `zebrad`'s build script
|
||||||
#[allow(clippy::print_stderr)]
|
#[allow(clippy::print_stderr)]
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut config = Config::default();
|
let mut config = Config::default();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use zebrad::application::APPLICATION;
|
use zebrad::application::APPLICATION;
|
||||||
|
|
||||||
/// Boot Zebrad
|
/// Process entry point for `zebrad`
|
||||||
fn main() {
|
fn main() {
|
||||||
abscissa_core::boot(&APPLICATION);
|
abscissa_core::boot(&APPLICATION);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,27 +86,27 @@ type InboundTxDownloads = TxDownloads<Timeout<Outbound>, Timeout<TxVerifier>, St
|
||||||
//
|
//
|
||||||
// Zebra only has one mempool, so the enum variant size difference doesn't matter.
|
// Zebra only has one mempool, so the enum variant size difference doesn't matter.
|
||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
|
#[derive(Default)]
|
||||||
enum ActiveState {
|
enum ActiveState {
|
||||||
/// The Mempool is disabled.
|
/// The Mempool is disabled.
|
||||||
|
#[default]
|
||||||
Disabled,
|
Disabled,
|
||||||
|
|
||||||
/// The Mempool is enabled.
|
/// The Mempool is enabled.
|
||||||
Enabled {
|
Enabled {
|
||||||
/// The Mempool storage itself.
|
/// The Mempool storage itself.
|
||||||
///
|
///
|
||||||
/// ##: Correctness: only components internal to the [`Mempool`] struct are allowed to
|
/// # Correctness
|
||||||
|
///
|
||||||
|
/// Only components internal to the [`Mempool`] struct are allowed to
|
||||||
/// inject transactions into `storage`, as transactions must be verified beforehand.
|
/// inject transactions into `storage`, as transactions must be verified beforehand.
|
||||||
storage: storage::Storage,
|
storage: storage::Storage,
|
||||||
|
|
||||||
/// The transaction download and verify stream.
|
/// The transaction download and verify stream.
|
||||||
tx_downloads: Pin<Box<InboundTxDownloads>>,
|
tx_downloads: Pin<Box<InboundTxDownloads>>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ActiveState {
|
|
||||||
fn default() -> Self {
|
|
||||||
ActiveState::Disabled
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ActiveState {
|
impl ActiveState {
|
||||||
/// Returns the current state, leaving [`Self::Disabled`] in its place.
|
/// Returns the current state, leaving [`Self::Disabled`] in its place.
|
||||||
fn take(&mut self) -> Self {
|
fn take(&mut self) -> Self {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue