Skip to content

Commit

Permalink
Fix new Clippy warnings introduced in Rust 1.68 (#1284)
Browse files Browse the repository at this point in the history
  • Loading branch information
romac authored Mar 10, 2023
1 parent 033ed00 commit 60e10ab
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 42 deletions.
9 changes: 2 additions & 7 deletions config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ pub struct TxIndexConfig {
}

/// What indexer to use for transactions
#[derive(Copy, Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
#[derive(Copy, Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize, Default)]
pub enum TxIndexer {
/// "null"
// TODO(tarcieri): use an `Option` type here?
Expand All @@ -621,15 +621,10 @@ pub enum TxIndexer {
/// "kv" (default) - the simplest possible indexer, backed by key-value storage (defaults to
/// levelDB; see DBBackend).
#[serde(rename = "kv")]
#[default]
Kv,
}

impl Default for TxIndexer {
fn default() -> TxIndexer {
TxIndexer::Kv
}
}

/// instrumentation configuration options
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
pub struct InstrumentationConfig {
Expand Down
9 changes: 2 additions & 7 deletions tendermint/src/abci/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,16 @@ use serde::{
/// <https://tendermint.com/docs/spec/abci/abci.html#errors>
///
/// Note that in the future there may potentially be non-zero success codes.
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Default)]
pub enum Code {
/// Success
#[default]
Ok,

/// Error codes
Err(NonZeroU32),
}

impl Default for Code {
fn default() -> Code {
Code::Ok
}
}

impl Code {
/// Was the response OK?
pub fn is_ok(self) -> bool {
Expand Down
8 changes: 2 additions & 6 deletions tendermint/src/abci/request/check_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,15 @@ pub struct CheckTx {
/// to avoid confusion with Rust types.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[repr(i32)]
#[derive(Default)]
pub enum CheckTxKind {
/// A full check is required (the default).
#[default]
New = 0,
/// Indicates that the mempool is initiating a recheck of the transaction.
Recheck = 1,
}

impl Default for CheckTxKind {
fn default() -> Self {
CheckTxKind::New
}
}

// =============================================================================
// Protobuf conversions
// =============================================================================
Expand Down
9 changes: 2 additions & 7 deletions tendermint/src/abci/response/process_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,14 @@ use crate::prelude::*;
#[doc = include_str!("../doc/response-processproposal.md")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(i32)]
#[derive(Default)]
pub enum ProcessProposal {
#[default]
Unknown = 0,
Accept = 1,
Reject = 2,
}

impl Default for ProcessProposal {
#[inline]
fn default() -> Self {
ProcessProposal::Unknown
}
}

// =============================================================================
// Protobuf conversions
// =============================================================================
Expand Down
9 changes: 2 additions & 7 deletions tendermint/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ pub enum Algorithm {
}

/// Hash digests
#[derive(Copy, Clone, Hash, Eq, PartialEq, PartialOrd, Ord)]
#[derive(Copy, Clone, Hash, Eq, PartialEq, PartialOrd, Ord, Default)]
pub enum Hash {
/// SHA-256 hashes
Sha256([u8; SHA256_HASH_SIZE]),
/// Empty hash
#[default]
None,
}

Expand Down Expand Up @@ -144,12 +145,6 @@ impl Debug for Hash {
}
}

impl Default for Hash {
fn default() -> Self {
Hash::None
}
}

impl Display for Hash {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let hex = match self {
Expand Down
2 changes: 1 addition & 1 deletion tendermint/src/node/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{error::Error, prelude::*};
pub const LENGTH: usize = 20;

/// Node IDs
#[allow(clippy::derive_hash_xor_eq)]
#[allow(clippy::derived_hash_with_manual_eq)]
#[derive(Copy, Clone, Eq, Hash, PartialOrd, Ord)]
pub struct Id([u8; LENGTH]);

Expand Down
9 changes: 2 additions & 7 deletions tendermint/src/node/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,18 @@ pub struct OtherInfo {
}

/// Transaction index status
#[derive(Copy, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[derive(Copy, Clone, Debug, Deserialize, Eq, PartialEq, Serialize, Default)]
pub enum TxIndexStatus {
/// Index is on
#[serde(rename = "on")]
#[default]
On,

/// Index is off
#[serde(rename = "off")]
Off,
}

impl Default for TxIndexStatus {
fn default() -> TxIndexStatus {
TxIndexStatus::On
}
}

impl From<TxIndexStatus> for bool {
fn from(status: TxIndexStatus) -> bool {
match status {
Expand Down

0 comments on commit 60e10ab

Please sign in to comment.