Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

chore: fix clippy #2059

Merged
merged 1 commit into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions ethers-contract/ethers-contract-abigen/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ use regex::Regex;
use std::collections::HashSet;

/// Used to filter contracts that should be _included_ in the abigen generation.
#[derive(Debug, Clone)]
#[derive(Debug, Default, Clone)]
pub enum ContractFilter {
/// Include all contracts
#[default]
All,
/// Only include contracts that match the filter
Select(SelectContracts),
Expand All @@ -27,12 +28,6 @@ impl ContractFilter {
}
}

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

impl From<SelectContracts> for ContractFilter {
fn from(f: SelectContracts) -> Self {
ContractFilter::Select(f)
Expand Down
1 change: 0 additions & 1 deletion ethers-contract/ethers-contract-abigen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ impl Abigen {
self
}

#[must_use]
#[deprecated = "Use format instead"]
#[doc(hidden)]
pub fn rustfmt(mut self, rustfmt: bool) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion ethers-contract/src/multicall/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl<M> Clone for Multicall<M> {
contract: self.contract.clone(),
version: self.version,
legacy: self.legacy,
block: self.block.clone(),
block: self.block,
calls: self.calls.clone(),
}
}
Expand Down
18 changes: 4 additions & 14 deletions ethers-etherscan/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,11 @@ pub struct MinedBlock {
}

/// The pre-defined block parameter for balance API endpoints
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Default)]
pub enum Tag {
Earliest,
Pending,
#[default]
Latest,
}

Expand All @@ -372,12 +373,6 @@ impl Display for Tag {
}
}

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

/// The list sorting preference
#[derive(Clone, Copy, Debug)]
pub enum Sort {
Expand Down Expand Up @@ -466,8 +461,9 @@ impl TokenQueryOption {
}

/// The pre-defined block type for retrieving mined blocks
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, Default)]
pub enum BlockType {
#[default]
CanonicalBlocks,
Uncles,
}
Expand All @@ -481,12 +477,6 @@ impl Display for BlockType {
}
}

impl Default for BlockType {
fn default() -> Self {
BlockType::CanonicalBlocks
}
}

impl Client {
/// Returns the Ether balance of a given address.
///
Expand Down
9 changes: 2 additions & 7 deletions ethers-providers/src/transports/quorum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,13 @@ impl<T: JsonRpcClientWrapper> QuorumProvider<T> {
}

/// Determines when the provider reached a quorum
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Default, Copy, Clone)]
pub enum Quorum {
/// The quorum is reached when all providers return the exact value
All,
/// The quorum is reached when the majority of the providers have returned a
/// matching value, taking into account their weight.
#[default]
Majority,
/// The quorum is reached when the cumulative weight of a matching return
/// exceeds the given percentage of the total weight.
Expand Down Expand Up @@ -257,12 +258,6 @@ impl Quorum {
}
}

impl Default for Quorum {
fn default() -> Self {
Quorum::Majority
}
}

// A future that returns the provider's response and it's index within the
// `QuorumProvider` provider set
#[cfg(target_arch = "wasm32")]
Expand Down
36 changes: 8 additions & 28 deletions ethers-solc/src/artifacts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ pub struct YulDetails {
pub optimizer_steps: Option<String>,
}

#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub enum EvmVersion {
Homestead,
TangerineWhistle,
Expand All @@ -687,15 +687,10 @@ pub enum EvmVersion {
Petersburg,
Istanbul,
Berlin,
#[default]
London,
}

impl Default for EvmVersion {
fn default() -> Self {
Self::London
}
}

impl EvmVersion {
/// Checks against the given solidity `semver::Version`
pub fn normalize_version(self, version: &Version) -> Option<EvmVersion> {
Expand Down Expand Up @@ -786,9 +781,10 @@ pub struct DebuggingSettings {
}

/// How to treat revert (and require) reason strings.
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub enum RevertStrings {
/// "default" does not inject compiler-generated revert strings and keeps user-supplied ones.
#[default]
Default,
/// "strip" removes all revert strings (if possible, i.e. if literals are used) keeping
/// side-effects
Expand Down Expand Up @@ -827,12 +823,6 @@ impl FromStr for RevertStrings {
}
}

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

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct SettingsMetadata {
/// Use only literal content and not URLs (false by default)
Expand Down Expand Up @@ -868,19 +858,14 @@ impl From<BytecodeHash> for SettingsMetadata {
/// Determines the hash method for the metadata hash that is appended to the bytecode.
///
/// Solc's default is `Ipfs`, see <https://docs.soliditylang.org/en/latest/using-the-compiler.html#compiler-api>.
#[derive(Clone, Debug, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Clone, Debug, Default, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum BytecodeHash {
#[default]
Ipfs,
None,
Bzzr1,
}

impl Default for BytecodeHash {
fn default() -> Self {
BytecodeHash::Ipfs
}
}

impl FromStr for BytecodeHash {
type Err = String;

Expand Down Expand Up @@ -1036,8 +1021,9 @@ pub struct ModelCheckerSettings {
}

/// Which model checker engine to run.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum ModelCheckerEngine {
#[default]
Default,
All,
BMC,
Expand Down Expand Up @@ -1070,12 +1056,6 @@ impl FromStr for ModelCheckerEngine {
}
}

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

/// Which model checker targets to check.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
Expand Down
8 changes: 2 additions & 6 deletions ethers-solc/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ impl FileFilter for TestFileFilter {

/// A type that can apply a filter to a set of preprocessed [FilteredSources] in order to set sparse
/// output for specific files
#[derive(Default)]
pub enum SparseOutputFilter {
/// Sets the configured [OutputSelection] for dirty files only.
///
/// In other words, we request the output of solc only for files that have been detected as
/// _dirty_.
#[default]
AllDirty,
/// Apply an additional filter to [FilteredSources] to
Custom(Box<dyn FileFilter>),
Expand Down Expand Up @@ -176,12 +178,6 @@ impl From<Box<dyn FileFilter>> for SparseOutputFilter {
}
}

impl Default for SparseOutputFilter {
fn default() -> Self {
SparseOutputFilter::AllDirty
}
}

impl fmt::Debug for SparseOutputFilter {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Expand Down
19 changes: 5 additions & 14 deletions ethers-solc/src/resolver/tree.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
use crate::Graph;
use std::{collections::HashSet, io, io::Write, str::FromStr};

#[derive(Debug, Clone, Copy, Eq, PartialEq)]
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq)]
pub enum Charset {
// when operating in a console on windows non-UTF-8 byte sequences are not supported on
// stdout, See also [`StdoutLock`]
#[cfg_attr(target_os = "windows", default)]
Utf8,
#[cfg_attr(not(target_os = "windows"), default)]
Ascii,
}

impl Default for Charset {
fn default() -> Self {
// when operating in a console on windows non-UTF-8 byte sequences are not supported on
// stdout, See also [`StdoutLock`]
#[cfg(target_os = "windows")]
{
Charset::Ascii
}
#[cfg(not(target_os = "windows"))]
Charset::Utf8
}
}

impl FromStr for Charset {
type Err = String;

Expand Down