From 2d61fe296f874b17433c75b5a4c179b20f74ed25 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Tue, 7 Dec 2021 02:13:42 +1100 Subject: [PATCH] *: Fix clippy errors from upgrade to Rust 1.57 (#2365) * core: Mark "unused" field with "_" We need to keep this marker type to ensure that the type continues to be required to be pinned. * tranports/noise: Derive `Default` for `Config` `false` is the default for `bool`, we can derive this. * protocols/request-response: Remove unused fields These are already included the `RequestResponseMessage::Request` variant. * *: Allow clippy's large-enum-variant lint Tackling these suggestions would require performance measurement which we don't want to do at this stage. Co-authored-by: Max Inden --- core/src/transport/and_then.rs | 6 +++--- protocols/gossipsub/src/behaviour.rs | 1 + protocols/identify/src/identify.rs | 1 + protocols/rendezvous/src/codec.rs | 1 + protocols/rendezvous/src/handler.rs | 1 + protocols/rendezvous/src/handler/inbound.rs | 1 + protocols/rendezvous/src/handler/outbound.rs | 1 + protocols/request-response/src/lib.rs | 8 +------- transports/noise/src/lib.rs | 11 +---------- 9 files changed, 11 insertions(+), 20 deletions(-) diff --git a/core/src/transport/and_then.rs b/core/src/transport/and_then.rs index 51f5d88c..3ff70fca 100644 --- a/core/src/transport/and_then.rs +++ b/core/src/transport/and_then.rs @@ -77,7 +77,7 @@ where let future = AndThenFuture { inner: Either::Left(Box::pin(dialed_fut)), args: Some((self.fun, ConnectedPoint::Dialer { address: addr })), - marker: PhantomPinned, + _marker: PhantomPinned, }; Ok(future) } @@ -132,7 +132,7 @@ where upgrade: AndThenFuture { inner: Either::Left(Box::pin(upgrade)), args: Some((this.fun.clone(), point)), - marker: PhantomPinned, + _marker: PhantomPinned, }, local_addr, remote_addr, @@ -159,7 +159,7 @@ where pub struct AndThenFuture { inner: Either>, Pin>>, args: Option<(TMap, ConnectedPoint)>, - marker: PhantomPinned, + _marker: PhantomPinned, } impl Future for AndThenFuture diff --git a/protocols/gossipsub/src/behaviour.rs b/protocols/gossipsub/src/behaviour.rs index 9daddc5d..d9373d89 100644 --- a/protocols/gossipsub/src/behaviour.rs +++ b/protocols/gossipsub/src/behaviour.rs @@ -147,6 +147,7 @@ pub enum GossipsubEvent { /// A data structure for storing configuration for publishing messages. See [`MessageAuthenticity`] /// for further details. +#[allow(clippy::large_enum_variant)] enum PublishConfig { Signing { keypair: Keypair, diff --git a/protocols/identify/src/identify.rs b/protocols/identify/src/identify.rs index e3600e0d..def59b7c 100644 --- a/protocols/identify/src/identify.rs +++ b/protocols/identify/src/identify.rs @@ -459,6 +459,7 @@ impl NetworkBehaviour for Identify { } /// Event emitted by the `Identify` behaviour. +#[allow(clippy::large_enum_variant)] #[derive(Debug)] pub enum IdentifyEvent { /// Identification information has been received from a peer. diff --git a/protocols/rendezvous/src/codec.rs b/protocols/rendezvous/src/codec.rs index d050ff8c..d8d54d91 100644 --- a/protocols/rendezvous/src/codec.rs +++ b/protocols/rendezvous/src/codec.rs @@ -28,6 +28,7 @@ use unsigned_varint::codec::UviBytes; pub type Ttl = u64; +#[allow(clippy::large_enum_variant)] #[derive(Debug, Clone)] pub enum Message { Register(NewRegistration), diff --git a/protocols/rendezvous/src/handler.rs b/protocols/rendezvous/src/handler.rs index b4883825..d07bf4d2 100644 --- a/protocols/rendezvous/src/handler.rs +++ b/protocols/rendezvous/src/handler.rs @@ -28,6 +28,7 @@ pub mod inbound; pub mod outbound; /// Errors that can occur while interacting with a substream. +#[allow(clippy::large_enum_variant)] #[derive(Debug, thiserror::Error)] pub enum Error { #[error("Reading message {0:?} at this stage is a protocol violation")] diff --git a/protocols/rendezvous/src/handler/inbound.rs b/protocols/rendezvous/src/handler/inbound.rs index 8a18f366..d4452b57 100644 --- a/protocols/rendezvous/src/handler/inbound.rs +++ b/protocols/rendezvous/src/handler/inbound.rs @@ -54,6 +54,7 @@ impl fmt::Debug for Stream { } } +#[allow(clippy::large_enum_variant)] #[derive(Debug, Clone)] pub enum OutEvent { RegistrationRequested(NewRegistration), diff --git a/protocols/rendezvous/src/handler/outbound.rs b/protocols/rendezvous/src/handler/outbound.rs index ab06040c..c1356ee2 100644 --- a/protocols/rendezvous/src/handler/outbound.rs +++ b/protocols/rendezvous/src/handler/outbound.rs @@ -120,6 +120,7 @@ pub enum OutEvent { }, } +#[allow(clippy::large_enum_variant)] #[derive(Debug)] pub enum OpenInfo { RegisterRequest(NewRegistration), diff --git a/protocols/request-response/src/lib.rs b/protocols/request-response/src/lib.rs index 5efce37d..1f6d1eeb 100644 --- a/protocols/request-response/src/lib.rs +++ b/protocols/request-response/src/lib.rs @@ -231,8 +231,6 @@ impl std::error::Error for InboundFailure {} /// See [`RequestResponse::send_response`]. #[derive(Debug)] pub struct ResponseChannel { - request_id: RequestId, - peer: PeerId, sender: oneshot::Sender, } @@ -750,11 +748,7 @@ where request, sender, } => { - let channel = ResponseChannel { - request_id, - peer, - sender, - }; + let channel = ResponseChannel { sender }; let message = RequestResponseMessage::Request { request_id, request, diff --git a/transports/noise/src/lib.rs b/transports/noise/src/lib.rs index d6141483..68506dd7 100644 --- a/transports/noise/src/lib.rs +++ b/transports/noise/src/lib.rs @@ -420,7 +420,7 @@ where } /// Legacy configuration options. -#[derive(Clone)] +#[derive(Clone, Default)] pub struct LegacyConfig { /// Whether to continue sending legacy handshake payloads, /// i.e. length-prefixed protobuf payloads inside a length-prefixed @@ -433,12 +433,3 @@ pub struct LegacyConfig { /// libp2p implementations. pub recv_legacy_handshake: bool, } - -impl Default for LegacyConfig { - fn default() -> Self { - Self { - send_legacy_handshake: false, - recv_legacy_handshake: false, - } - } -}