Skip to content

Commit

Permalink
Fix clippy 0.1.57 lints (backport to 0.23.x) (informalsystems#1042)
Browse files Browse the repository at this point in the history
* Fix trivial lints reported by clippy 0.1.57

* Override lints for large enum variants

No boxing of public members in the v0.23.x release stream to avoid
unnecessary breaking changes.

* abci: fix one more clippy 0.1.57 lint
  • Loading branch information
mzabaluev committed Dec 7, 2021
1 parent 1dedd72 commit c64cbaa
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 61 deletions.
8 changes: 1 addition & 7 deletions abci/src/application/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
use crate::Application;

/// Trivial echo application, mainly for testing purposes.
#[derive(Clone)]
#[derive(Clone, Default)]
pub struct EchoApp;

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

impl Application for EchoApp {}
2 changes: 2 additions & 0 deletions light-client/src/fork_detector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub enum ForkDetection {

/// Types of fork
#[derive(Debug)]
// To be fixed in 0.24
#[allow(clippy::large_enum_variant)]
pub enum Fork {
/// An actual fork was found for this `LightBlock`
Forked {
Expand Down
10 changes: 1 addition & 9 deletions rpc/src/client/transport/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ pub trait MockRequestMatcher: Send + Sync {
/// requests with specific methods to responses.
///
/// [`MockRequestMatcher`]: trait.MockRequestMatcher.html
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct MockRequestMethodMatcher {
mappings: HashMap<Method, Result<String, Error>>,
}
Expand All @@ -216,14 +216,6 @@ impl MockRequestMatcher for MockRequestMethodMatcher {
}
}

impl Default for MockRequestMethodMatcher {
fn default() -> Self {
Self {
mappings: HashMap::new(),
}
}
}

impl MockRequestMethodMatcher {
/// Maps all incoming requests with the given method such that their
/// corresponding response will be `response`.
Expand Down
10 changes: 1 addition & 9 deletions rpc/src/client/transport/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub type SubscriptionIdRef<'a> = &'a str;
///
/// [`Subscription`]: struct.Subscription.html
/// [`Event`]: ./event/struct.Event.html
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct SubscriptionRouter {
/// A map of subscription queries to collections of subscription IDs and
/// their result channels. Used for publishing events relating to a specific
Expand Down Expand Up @@ -128,14 +128,6 @@ impl SubscriptionRouter {
}
}

impl Default for SubscriptionRouter {
fn default() -> Self {
Self {
subscriptions: HashMap::new(),
}
}
}

#[derive(Debug, Clone)]
pub enum PublishResult {
Success,
Expand Down
14 changes: 1 addition & 13 deletions rpc/src/endpoint/validators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use tendermint::{block, validator};
pub const DEFAULT_VALIDATORS_PER_PAGE: u8 = 30;

/// List validators for a specific block
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[non_exhaustive]
pub struct Request {
/// The height at which to retrieve the validator set. If not specified,
Expand Down Expand Up @@ -43,18 +43,6 @@ impl Request {
}
}

impl Default for Request {
fn default() -> Self {
// By default we get the latest validators list, page 1, maximum 30
// items per page (the RPC defaults).
Self {
height: None,
page: None,
per_page: None,
}
}
}

impl crate::Request for Request {
type Response = Response;

Expand Down
2 changes: 2 additions & 0 deletions rpc/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ impl Event {

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(tag = "type", content = "value")]
// To be fixed in 0.24
#[allow(clippy::large_enum_variant)]
pub enum EventData {
#[serde(alias = "tendermint/event/NewBlock")]
NewBlock {
Expand Down
8 changes: 1 addition & 7 deletions tendermint/src/abci/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::fmt::{self, Display};
use serde::{Deserialize, Serialize};

/// ABCI info
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct Info(String);

impl AsRef<str> for Info {
Expand All @@ -17,9 +17,3 @@ impl Display for Info {
write!(f, "{}", self.0)
}
}

impl Default for Info {
fn default() -> Self {
Self(String::new())
}
}
8 changes: 1 addition & 7 deletions tendermint/src/abci/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ where
}

/// Codespace
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct Codespace(String);

impl AsRef<str> for Codespace {
Expand All @@ -144,9 +144,3 @@ impl Display for Codespace {
write!(f, "{}", self.0)
}
}

impl Default for Codespace {
fn default() -> Self {
Self(String::new())
}
}
8 changes: 1 addition & 7 deletions tendermint/src/block/round.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use core::{
use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer};

/// Block round for a particular chain
#[derive(Copy, Clone, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[derive(Copy, Clone, Default, Eq, Hash, PartialEq, PartialOrd, Ord)]
pub struct Round(u32);

impl TryFrom<i32> for Round {
Expand Down Expand Up @@ -72,12 +72,6 @@ impl Debug for Round {
}
}

impl Default for Round {
fn default() -> Self {
Round(0)
}
}

impl Display for Round {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
Expand Down
2 changes: 2 additions & 0 deletions tendermint/src/evidence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ use tendermint_proto::Protobuf;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
//#[serde(tag = "type", content = "value")]
#[serde(try_from = "RawEvidence", into = "RawEvidence")] // Used by RPC /broadcast_evidence endpoint
// To be fixed in 0.24
#[allow(clippy::large_enum_variant)]
pub enum Evidence {
/// Duplicate vote evidence
//#[serde(rename = "tendermint/DuplicateVoteEvidence")]
Expand Down
4 changes: 2 additions & 2 deletions testgen/src/tester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl TestEnv {
pub fn push(&self, child: &str) -> Option<Self> {
let mut path = PathBuf::from(&self.current_dir);
path.push(child);
path.to_str().and_then(|path| TestEnv::new(path))
path.to_str().and_then(TestEnv::new)
}

pub fn current_dir(&self) -> &str {
Expand Down Expand Up @@ -256,7 +256,7 @@ impl Tester {
*result = Failure { message, location };
})
});
let result = panic::catch_unwind(|| test());
let result = panic::catch_unwind(test);
panic::set_hook(old_hook);
match result {
Ok(_) => Success,
Expand Down

0 comments on commit c64cbaa

Please sign in to comment.