Skip to content

Commit

Permalink
chore: fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Jan 8, 2025
1 parent 1fa973d commit 86a86ea
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion abci/src/server/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl<App: RequestDispatcher> GenericServer<App, UnixListener> {
}
}

impl<'a, App: RequestDispatcher + 'a, L: Listener> Server for GenericServer<App, L>
impl<App: RequestDispatcher, L: Listener> Server for GenericServer<App, L>
where
L: Listener + Send + Sync + 'static,
L::Addr: Send + Debug,
Expand Down
11 changes: 7 additions & 4 deletions proto-compiler/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Tenderdash protobuf implementation
use std::fmt::Display;

// Requirements
pub const DEP_PROTOC_VERSION: f32 = 25.0;

Expand Down Expand Up @@ -30,13 +32,14 @@ impl GenerationMode {
}
}

impl ToString for GenerationMode {
fn to_string(&self) -> String {
match self {
impl Display for GenerationMode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mode = match self {
GenerationMode::GrpcServer => "grpc-client-server".to_string(),
GenerationMode::GrpcClient => "grpc-client".to_string(),
GenerationMode::NoStd => "nostd".to_string(),
}
};
write!(f, "{}", mode)
}
}

Expand Down
4 changes: 2 additions & 2 deletions proto-compiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub fn proto_compile(mode: GenerationMode) {
.compile_protos_with_config(pb, &protos, &proto_includes_paths)
.unwrap();
#[cfg(not(feature = "grpc"))]
panic!("grpc feature is required to compile {}", mode.to_string());
panic!("grpc feature is required to compile {}", mode);
},
GenerationMode::GrpcClient => {
#[cfg(feature = "grpc")]
Expand All @@ -146,7 +146,7 @@ pub fn proto_compile(mode: GenerationMode) {
.compile_protos_with_config(pb, &protos, &proto_includes_paths)
.unwrap();
#[cfg(not(feature = "grpc"))]
panic!("grpc feature is required to compile {}", mode.to_string());
panic!("grpc feature is required to compile {}", mode);
},
GenerationMode::NoStd => {
pb.compile_protos(&protos, &proto_includes_paths).unwrap();
Expand Down
13 changes: 6 additions & 7 deletions proto/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! tenderdash-proto library gives the developer access to the Tenderdash
//! proto-defined structs.
#![cfg_attr(not(feature = "grpc"), no_std)]
#![deny(warnings, trivial_casts, trivial_numeric_casts, unused_import_braces)]
#![allow(clippy::large_enum_variant)]
#![allow(clippy::doc_lazy_continuation)]
#![forbid(unsafe_code)]

extern crate alloc;
Expand Down Expand Up @@ -34,28 +34,27 @@ pub use error::Error;
pub use prost;
use prost::{encoding::encoded_len_varint, Message};

#[cfg(not(any(feature = "server", feature = "client")))]
#[rustfmt::skip]
#[allow(clippy::empty_docs)]
pub mod tenderdash_nostd;


// Depending on feature, add correct module

#[cfg(feature = "server")]
#[rustfmt::skip]
#[allow(clippy::empty_docs)]
pub mod tenderdash_grpc;
#[cfg(feature = "client")]
#[rustfmt::skip]
#[allow(clippy::empty_docs)]
pub mod tenderdash_grpc_client;

// Now, re-export correct module

#[cfg(feature = "server")]
#[rustfmt::skip]
pub use tenderdash_grpc::*;
#[cfg(all(not(feature = "server"), feature = "client"))]
pub use tenderdash_grpc_client::*;
#[cfg(not(feature = "grpc"))]
// Re-export the nostd module only if the std one is not available
#[cfg(all(not(feature = "server"), not(feature = "client")))]
pub use tenderdash_nostd::*;

#[cfg(feature = "serde")]
Expand Down
5 changes: 3 additions & 2 deletions proto/src/time.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
//! Time conversion traits and functions
#[cfg(not(feature = "std"))]
// Most likely we build nostd
#[cfg(not(any(feature = "server", feature = "client")))]
use crate::format;
use crate::{google::protobuf::Timestamp, Error};
pub trait ToMillis {
/// Convert protobuf timestamp into milliseconds since epoch
///
/// Note there is a resolution difference, as timestamp uses nanoseconds
///
/// # Arguments
Expand Down

0 comments on commit 86a86ea

Please sign in to comment.