Skip to content

Commit

Permalink
chore(clippy): make clippy happy (foundry-rs#4084)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Jan 13, 2023
1 parent 0cf8f67 commit 3d5f038
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 75 deletions.
9 changes: 2 additions & 7 deletions anvil/src/eth/pool/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ pub fn to_marker(nonce: u64, from: Address) -> TxMarker {
/// Modes that determine the transaction ordering of the mempool
///
/// This type controls the transaction order via the priority metric of a transaction
#[derive(Debug, Clone, Eq, PartialEq, Copy, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, Eq, PartialEq, Copy, serde::Serialize, serde::Deserialize, Default)]
pub enum TransactionOrder {
/// Keep the pool transaction transactions sorted in the order they arrive.
///
/// This will essentially assign every transaction the exact priority so the order is
/// determined by their internal id
Fifo,
/// This means that it prioritizes transactions based on the fees paid to the miner.
#[default]
Fees,
}

Expand Down Expand Up @@ -63,12 +64,6 @@ impl FromStr for TransactionOrder {
}
}

impl Default for TransactionOrder {
fn default() -> Self {
TransactionOrder::Fees
}
}

/// Metric value for the priority of a transaction.
///
/// The `TransactionPriority` determines the ordering of two transactions that have all their
Expand Down
9 changes: 2 additions & 7 deletions anvil/src/hardfork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use ethers::types::BlockNumber;
use foundry_evm::revm::SpecId;
use std::str::FromStr;

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Default)]
pub enum Hardfork {
Frontier,
Homestead,
Expand All @@ -19,6 +19,7 @@ pub enum Hardfork {
London,
ArrowGlacier,
GrayGlacier,
#[default]
Latest,
}

Expand Down Expand Up @@ -114,12 +115,6 @@ impl FromStr for Hardfork {
}
}

impl Default for Hardfork {
fn default() -> Self {
Hardfork::Latest
}
}

impl From<Hardfork> for SpecId {
fn from(fork: Hardfork) -> Self {
match fork {
Expand Down
9 changes: 2 additions & 7 deletions binder/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ impl<'a> GitCheckout<'a> {
}

/// Represents a specific commit in a git repository
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub enum GitReference {
/// Tag, like a release v0.0.1
Tag(String),
Expand All @@ -296,6 +296,7 @@ pub enum GitReference {
/// Specific revision.
Rev(String),
/// Default branch
#[default]
DefaultBranch,
}

Expand Down Expand Up @@ -343,12 +344,6 @@ impl GitReference {
}
}

impl Default for GitReference {
fn default() -> Self {
GitReference::DefaultBranch
}
}

fn reinitialize(repo: &mut git2::Repository) -> eyre::Result<()> {
// Here we want to drop the current repository object pointed to by `repo`,
// so we initialize temporary repository in a sub-folder, blow away the
Expand Down
17 changes: 4 additions & 13 deletions common/src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,14 @@ impl ShellWrite for WriteShellOut {
}

/// A `Write`able object, either with or without color support
#[derive(Default)]
pub enum ShellOut {
/// A plain write object
///
/// Can be used for debug purposes
Write(WriteShellOut),
/// Streams to `stdio`
#[default]
Stream,
}

Expand Down Expand Up @@ -279,18 +281,13 @@ impl ShellOut {
}
}

impl Default for ShellOut {
fn default() -> Self {
ShellOut::Stream
}
}

/// The requested verbosity of output.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Verbosity {
/// only allow json output
Json,
/// print as is
#[default]
Normal,
/// print nothing
Silent,
Expand All @@ -314,9 +311,3 @@ impl Verbosity {
matches!(self, Verbosity::Normal)
}
}

impl Default for Verbosity {
fn default() -> Self {
Verbosity::Normal
}
}
18 changes: 4 additions & 14 deletions config/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ impl StorageCachingConfig {
}

/// What chains to cache
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Default)]
pub enum CachedChains {
/// Cache all chains
#[default]
All,
/// Don't cache anything
None,
Expand Down Expand Up @@ -87,16 +88,11 @@ impl<'de> Deserialize<'de> for CachedChains {
}
}

impl Default for CachedChains {
fn default() -> Self {
CachedChains::All
}
}

/// What endpoints to enable caching for
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub enum CachedEndpoints {
/// Cache all endpoints
#[default]
All,
/// Only cache non-local host endpoints
Remote,
Expand Down Expand Up @@ -131,12 +127,6 @@ impl PartialEq for CachedEndpoints {

impl Eq for CachedEndpoints {}

impl Default for CachedEndpoints {
fn default() -> Self {
CachedEndpoints::All
}
}

impl fmt::Display for CachedEndpoints {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Expand Down
9 changes: 2 additions & 7 deletions config/src/fs_permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ impl fmt::Display for FsAccessKind {
}

/// Determines the status of file system access
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
pub enum FsAccessPermission {
/// FS access is _not_ allowed
#[default]
None,
/// FS access is allowed, this includes `read` + `write`
ReadWrite,
Expand All @@ -162,12 +163,6 @@ impl FsAccessPermission {
}
}

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

impl FromStr for FsAccessPermission {
type Err = String;

Expand Down
8 changes: 2 additions & 6 deletions evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ pub const TEST_CONTRACT_ADDRESS: Address = H160([

#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "UPPERCASE")]
#[derive(Default)]
pub enum CallKind {
#[default]
Call,
StaticCall,
CallCode,
Expand All @@ -59,12 +61,6 @@ pub enum CallKind {
Create2,
}

impl Default for CallKind {
fn default() -> Self {
CallKind::Call
}
}

impl From<CallScheme> for CallKind {
fn from(scheme: CallScheme) -> Self {
match scheme {
Expand Down
9 changes: 2 additions & 7 deletions fmt/src/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,10 @@ impl Comments {
}

/// The state of a character in a string with possible comments
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
pub enum CommentState {
/// character not in a comment
#[default]
None,
/// First `/` in line comment start `"//"`
LineStart1,
Expand All @@ -325,12 +326,6 @@ pub enum CommentState {
BlockEnd2,
}

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

/// An Iterator over characters and indices in a string slice with information about the state of
/// comments
pub struct CommentStateCharIndices<'a> {
Expand Down
9 changes: 2 additions & 7 deletions fmt/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
/// This is a simplified version of the
/// [actual parser](https://docs.soliditylang.org/en/v0.8.15/grammar.html#a4.SolidityLexer.EscapeSequence)
/// as we don't care about hex or other character meanings
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
pub enum QuoteState {
/// Not currently in quoted string
#[default]
None,
/// The opening character of a quoted string
Opening(char),
Expand All @@ -20,12 +21,6 @@ pub enum QuoteState {
Closing(char),
}

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

/// An iterator over characters and indices in a string slice with information about quoted string
/// states
pub struct QuoteStateCharIndices<'a> {
Expand Down

0 comments on commit 3d5f038

Please sign in to comment.