*: 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 <mail@max-inden.de>
This commit is contained in:
Thomas Eizinger
2021-12-07 02:13:42 +11:00
committed by GitHub
parent e021933a06
commit 2d61fe296f
9 changed files with 11 additions and 20 deletions

View File

@ -77,7 +77,7 @@ where
let future = AndThenFuture { let future = AndThenFuture {
inner: Either::Left(Box::pin(dialed_fut)), inner: Either::Left(Box::pin(dialed_fut)),
args: Some((self.fun, ConnectedPoint::Dialer { address: addr })), args: Some((self.fun, ConnectedPoint::Dialer { address: addr })),
marker: PhantomPinned, _marker: PhantomPinned,
}; };
Ok(future) Ok(future)
} }
@ -132,7 +132,7 @@ where
upgrade: AndThenFuture { upgrade: AndThenFuture {
inner: Either::Left(Box::pin(upgrade)), inner: Either::Left(Box::pin(upgrade)),
args: Some((this.fun.clone(), point)), args: Some((this.fun.clone(), point)),
marker: PhantomPinned, _marker: PhantomPinned,
}, },
local_addr, local_addr,
remote_addr, remote_addr,
@ -159,7 +159,7 @@ where
pub struct AndThenFuture<TFut, TMap, TMapOut> { pub struct AndThenFuture<TFut, TMap, TMapOut> {
inner: Either<Pin<Box<TFut>>, Pin<Box<TMapOut>>>, inner: Either<Pin<Box<TFut>>, Pin<Box<TMapOut>>>,
args: Option<(TMap, ConnectedPoint)>, args: Option<(TMap, ConnectedPoint)>,
marker: PhantomPinned, _marker: PhantomPinned,
} }
impl<TFut, TMap, TMapOut> Future for AndThenFuture<TFut, TMap, TMapOut> impl<TFut, TMap, TMapOut> Future for AndThenFuture<TFut, TMap, TMapOut>

View File

@ -147,6 +147,7 @@ pub enum GossipsubEvent {
/// A data structure for storing configuration for publishing messages. See [`MessageAuthenticity`] /// A data structure for storing configuration for publishing messages. See [`MessageAuthenticity`]
/// for further details. /// for further details.
#[allow(clippy::large_enum_variant)]
enum PublishConfig { enum PublishConfig {
Signing { Signing {
keypair: Keypair, keypair: Keypair,

View File

@ -459,6 +459,7 @@ impl NetworkBehaviour for Identify {
} }
/// Event emitted by the `Identify` behaviour. /// Event emitted by the `Identify` behaviour.
#[allow(clippy::large_enum_variant)]
#[derive(Debug)] #[derive(Debug)]
pub enum IdentifyEvent { pub enum IdentifyEvent {
/// Identification information has been received from a peer. /// Identification information has been received from a peer.

View File

@ -28,6 +28,7 @@ use unsigned_varint::codec::UviBytes;
pub type Ttl = u64; pub type Ttl = u64;
#[allow(clippy::large_enum_variant)]
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum Message { pub enum Message {
Register(NewRegistration), Register(NewRegistration),

View File

@ -28,6 +28,7 @@ pub mod inbound;
pub mod outbound; pub mod outbound;
/// Errors that can occur while interacting with a substream. /// Errors that can occur while interacting with a substream.
#[allow(clippy::large_enum_variant)]
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum Error { pub enum Error {
#[error("Reading message {0:?} at this stage is a protocol violation")] #[error("Reading message {0:?} at this stage is a protocol violation")]

View File

@ -54,6 +54,7 @@ impl fmt::Debug for Stream {
} }
} }
#[allow(clippy::large_enum_variant)]
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum OutEvent { pub enum OutEvent {
RegistrationRequested(NewRegistration), RegistrationRequested(NewRegistration),

View File

@ -120,6 +120,7 @@ pub enum OutEvent {
}, },
} }
#[allow(clippy::large_enum_variant)]
#[derive(Debug)] #[derive(Debug)]
pub enum OpenInfo { pub enum OpenInfo {
RegisterRequest(NewRegistration), RegisterRequest(NewRegistration),

View File

@ -231,8 +231,6 @@ impl std::error::Error for InboundFailure {}
/// See [`RequestResponse::send_response`]. /// See [`RequestResponse::send_response`].
#[derive(Debug)] #[derive(Debug)]
pub struct ResponseChannel<TResponse> { pub struct ResponseChannel<TResponse> {
request_id: RequestId,
peer: PeerId,
sender: oneshot::Sender<TResponse>, sender: oneshot::Sender<TResponse>,
} }
@ -750,11 +748,7 @@ where
request, request,
sender, sender,
} => { } => {
let channel = ResponseChannel { let channel = ResponseChannel { sender };
request_id,
peer,
sender,
};
let message = RequestResponseMessage::Request { let message = RequestResponseMessage::Request {
request_id, request_id,
request, request,

View File

@ -420,7 +420,7 @@ where
} }
/// Legacy configuration options. /// Legacy configuration options.
#[derive(Clone)] #[derive(Clone, Default)]
pub struct LegacyConfig { pub struct LegacyConfig {
/// Whether to continue sending legacy handshake payloads, /// Whether to continue sending legacy handshake payloads,
/// i.e. length-prefixed protobuf payloads inside a length-prefixed /// i.e. length-prefixed protobuf payloads inside a length-prefixed
@ -433,12 +433,3 @@ pub struct LegacyConfig {
/// libp2p implementations. /// libp2p implementations.
pub recv_legacy_handshake: bool, pub recv_legacy_handshake: bool,
} }
impl Default for LegacyConfig {
fn default() -> Self {
Self {
send_legacy_handshake: false,
recv_legacy_handshake: false,
}
}
}