From dd45588993f596b3d122ce5108593f73bbb54a7c Mon Sep 17 00:00:00 2001 From: Alexandru Vasile Date: Wed, 14 Aug 2024 11:00:44 +0300 Subject: [PATCH] transport: Fix clippy Signed-off-by: Alexandru Vasile --- src/transport/common/listener.rs | 6 ++---- src/transport/manager/mod.rs | 2 +- src/transport/quic/connection.rs | 2 +- src/transport/quic/mod.rs | 2 +- src/transport/tcp/mod.rs | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/transport/common/listener.rs b/src/transport/common/listener.rs index 1f422830..9baf772b 100644 --- a/src/transport/common/listener.rs +++ b/src/transport/common/listener.rs @@ -430,10 +430,8 @@ fn multiaddr_to_socket_address( } let maybe_peer = match iter.next() { - Some(Protocol::P2p(multihash)) => Some( - PeerId::from_multihash(multihash) - .map_err(|hash| AddressError::InvalidMultihash(hash))?, - ), + Some(Protocol::P2p(multihash)) => + Some(PeerId::from_multihash(multihash).map_err(AddressError::InvalidMultihash)?), None => None, protocol => { tracing::error!( diff --git a/src/transport/manager/mod.rs b/src/transport/manager/mod.rs index 3e47fa56..6b5b39fe 100644 --- a/src/transport/manager/mod.rs +++ b/src/transport/manager/mod.rs @@ -1724,7 +1724,7 @@ impl TransportManager { "open failure, but not the last transport", ); - self.opening_errors.entry(connection_id).or_insert(Default::default()).extend(errors); + self.opening_errors.entry(connection_id).or_default().extend(errors); } } }, diff --git a/src/transport/quic/connection.rs b/src/transport/quic/connection.rs index b9994341..576436f0 100644 --- a/src/transport/quic/connection.rs +++ b/src/transport/quic/connection.rs @@ -145,7 +145,7 @@ impl QuicConnection { Role::Dialer => dialer_select_proto(stream, protocols, Version::V1).await, Role::Listener => listener_select_proto(stream, protocols).await, } - .map_err(|error| NegotiationError::MultistreamSelectError(error))?; + .map_err(NegotiationError::MultistreamSelectError)?; tracing::trace!(target: LOG_TARGET, ?protocol, "protocol negotiated"); diff --git a/src/transport/quic/mod.rs b/src/transport/quic/mod.rs index e485c4ea..6546b839 100644 --- a/src/transport/quic/mod.rs +++ b/src/transport/quic/mod.rs @@ -356,7 +356,7 @@ impl Transport for QuicTransport { let future = async move { let (socket_address, peer) = QuicListener::get_socket_address(&address) - .map_err(|err| DialError::AddressError(err))?; + .map_err(DialError::AddressError)?; let peer = peer.ok_or_else(|| DialError::AddressError(AddressError::PeerIdMissing))?; diff --git a/src/transport/tcp/mod.rs b/src/transport/tcp/mod.rs index 2a6bc23e..3e41d736 100644 --- a/src/transport/tcp/mod.rs +++ b/src/transport/tcp/mod.rs @@ -569,7 +569,7 @@ impl Stream for TcpTransport { return Poll::Ready(Some(TransportEvent::DialFailure { connection_id, address, - error: error.into(), + error, })); } }