Skip to content

Commit c476bce

Browse files
authored
chore: address clippy beta lints
Pull-Request: #6069.
1 parent 7cdf4d5 commit c476bce

File tree

13 files changed

+44
-58
lines changed

13 files changed

+44
-58
lines changed

protocols/autonat/src/v1/behaviour.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ impl Behaviour {
291291
self.as_client().on_new_address();
292292
}
293293

294-
fn as_client(&mut self) -> AsClient {
294+
fn as_client(&mut self) -> AsClient<'_> {
295295
AsClient {
296296
inner: &mut self.inner,
297297
local_peer_id: self.local_peer_id,
@@ -310,7 +310,7 @@ impl Behaviour {
310310
}
311311
}
312312

313-
fn as_server(&mut self) -> AsServer {
313+
fn as_server(&mut self) -> AsServer<'_> {
314314
AsServer {
315315
inner: &mut self.inner,
316316
config: &self.config,

protocols/gossipsub/src/rpc_proto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// DEALINGS IN THE SOFTWARE.
2020

2121
pub(crate) mod proto {
22-
#![allow(unreachable_pub)]
22+
#![allow(unreachable_pub, dead_code)]
2323
include!("generated/mod.rs");
2424
pub use self::gossipsub::pb::{mod_RPC::SubOpts, *};
2525
}

protocols/gossipsub/src/time_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ where
135135
}
136136
}
137137

138-
pub(crate) fn entry(&mut self, key: Key) -> Entry<Key, Value> {
138+
pub(crate) fn entry(&mut self, key: Key) -> Entry<'_, Key, Value> {
139139
let now = Instant::now();
140140
self.remove_expired_keys(now);
141141
match self.map.entry(key) {

protocols/identify/src/behaviour.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,12 @@ fn is_tcp_addr(addr: &Multiaddr) -> bool {
7676

7777
let mut iter = addr.iter();
7878

79-
let first = match iter.next() {
80-
None => return false,
81-
Some(p) => p,
79+
let Some(first) = iter.next() else {
80+
return false;
8281
};
83-
let second = match iter.next() {
84-
None => return false,
85-
Some(p) => p,
82+
83+
let Some(second) = iter.next() else {
84+
return false;
8685
};
8786

8887
matches!(first, Ip4(_) | Ip6(_) | Dns(_) | Dns4(_) | Dns6(_)) && matches!(second, Tcp(_))
@@ -120,9 +119,9 @@ pub struct Config {
120119
/// Application-specific version of the protocol family used by the peer,
121120
/// e.g. `ipfs/1.0.0` or `polkadot/1.0.0`.
122121
protocol_version: String,
123-
/// The key of the local node. Only the public key will be report on the wire.
122+
/// The key of the local node. Only the public key will be report on the wire.
124123
/// The behaviour will send signed [`PeerRecord`](libp2p_core::PeerRecord) in
125-
/// its identify message only when supplied with a keypair.
124+
/// its identify message only when supplied with a keypair.
126125
local_key: Arc<KeyType>,
127126
/// Name and version of the local peer implementation, similar to the
128127
/// `User-Agent` header in the HTTP protocol.
@@ -161,15 +160,15 @@ pub struct Config {
161160

162161
impl Config {
163162
/// Creates a new configuration for the identify [`Behaviour`] that
164-
/// advertises the given protocol version and public key.
163+
/// advertises the given protocol version and public key.
165164
/// Use [`new_with_signed_peer_record`](Config::new_with_signed_peer_record) for
166165
/// `signedPeerRecord` support.
167166
pub fn new(protocol_version: String, local_public_key: PublicKey) -> Self {
168167
Self::new_with_key(protocol_version, local_public_key)
169168
}
170169

171170
/// Creates a new configuration for the identify [`Behaviour`] that
172-
/// advertises the given protocol version and public key.
171+
/// advertises the given protocol version and public key.
173172
/// The private key will be used to sign [`PeerRecord`](libp2p_core::PeerRecord)
174173
/// for verifiable address advertisement.
175174
pub fn new_with_signed_peer_record(protocol_version: String, local_keypair: &Keypair) -> Self {
@@ -532,9 +531,8 @@ impl NetworkBehaviour for Behaviour {
532531
_addresses: &[Multiaddr],
533532
_effective_role: Endpoint,
534533
) -> Result<Vec<Multiaddr>, ConnectionDenied> {
535-
let peer = match maybe_peer {
536-
None => return Ok(vec![]),
537-
Some(peer) => peer,
534+
let Some(peer) = maybe_peer else {
535+
return Ok(vec![]);
538536
};
539537

540538
Ok(self.discovered_peers.get(&peer))

protocols/kad/src/behaviour.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,9 +2251,8 @@ where
22512251
_addresses: &[Multiaddr],
22522252
_effective_role: Endpoint,
22532253
) -> Result<Vec<Multiaddr>, ConnectionDenied> {
2254-
let peer_id = match maybe_peer {
2255-
None => return Ok(vec![]),
2256-
Some(peer) => peer,
2254+
let Some(peer_id) = maybe_peer else {
2255+
return Ok(vec![]);
22572256
};
22582257

22592258
// We should order addresses from decreasing likelihood of connectivity, so start with

protocols/kad/src/handler.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -820,14 +820,11 @@ fn compute_new_protocol_status(
820820
now_supported: bool,
821821
current_status: Option<ProtocolStatus>,
822822
) -> ProtocolStatus {
823-
let current_status = match current_status {
824-
None => {
825-
return ProtocolStatus {
826-
supported: now_supported,
827-
reported: false,
828-
}
829-
}
830-
Some(current) => current,
823+
let Some(current_status) = current_status else {
824+
return ProtocolStatus {
825+
supported: now_supported,
826+
reported: false,
827+
};
831828
};
832829

833830
if now_supported == current_status.supported {

protocols/mdns/src/behaviour.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,8 @@ where
229229
_addresses: &[Multiaddr],
230230
_effective_role: Endpoint,
231231
) -> Result<Vec<Multiaddr>, ConnectionDenied> {
232-
let peer_id = match maybe_peer {
233-
None => return Ok(vec![]),
234-
Some(peer) => peer,
232+
let Some(peer_id) = maybe_peer else {
233+
return Ok(vec![]);
235234
};
236235

237236
Ok(self

protocols/request-response/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,9 +792,8 @@ where
792792
_addresses: &[Multiaddr],
793793
_effective_role: Endpoint,
794794
) -> Result<Vec<Multiaddr>, ConnectionDenied> {
795-
let peer = match maybe_peer {
796-
None => return Ok(vec![]),
797-
Some(peer) => peer,
795+
let Some(peer) = maybe_peer else {
796+
return Ok(vec![]);
798797
};
799798

800799
let mut addresses = Vec::new();

swarm/src/behaviour/external_addresses.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,12 @@ impl ExternalAddresses {
6060
FromSwarm::ExternalAddrExpired(ExternalAddrExpired {
6161
addr: expired_addr, ..
6262
}) => {
63-
let pos = match self
63+
let Some(pos) = self
6464
.addresses
6565
.iter()
6666
.position(|candidate| candidate == *expired_addr)
67-
{
68-
None => return false,
69-
Some(p) => p,
67+
else {
68+
return false;
7069
};
7170

7271
self.addresses.remove(pos);

swarm/src/behaviour/toggle.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,8 @@ where
8080
local_addr: &Multiaddr,
8181
remote_addr: &Multiaddr,
8282
) -> Result<(), ConnectionDenied> {
83-
let inner = match self.inner.as_mut() {
84-
None => return Ok(()),
85-
Some(inner) => inner,
83+
let Some(inner) = self.inner.as_mut() else {
84+
return Ok(());
8685
};
8786

8887
inner.handle_pending_inbound_connection(connection_id, local_addr, remote_addr)?;
@@ -97,9 +96,8 @@ where
9796
local_addr: &Multiaddr,
9897
remote_addr: &Multiaddr,
9998
) -> Result<THandler<Self>, ConnectionDenied> {
100-
let inner = match self.inner.as_mut() {
101-
None => return Ok(ToggleConnectionHandler { inner: None }),
102-
Some(inner) => inner,
99+
let Some(inner) = self.inner.as_mut() else {
100+
return Ok(ToggleConnectionHandler { inner: None });
103101
};
104102

105103
let handler = inner.handle_established_inbound_connection(
@@ -121,9 +119,8 @@ where
121119
addresses: &[Multiaddr],
122120
effective_role: Endpoint,
123121
) -> Result<Vec<Multiaddr>, ConnectionDenied> {
124-
let inner = match self.inner.as_mut() {
125-
None => return Ok(vec![]),
126-
Some(inner) => inner,
122+
let Some(inner) = self.inner.as_mut() else {
123+
return Ok(vec![]);
127124
};
128125

129126
let addresses = inner.handle_pending_outbound_connection(
@@ -144,9 +141,8 @@ where
144141
role_override: Endpoint,
145142
port_use: PortUse,
146143
) -> Result<THandler<Self>, ConnectionDenied> {
147-
let inner = match self.inner.as_mut() {
148-
None => return Ok(ToggleConnectionHandler { inner: None }),
149-
Some(inner) => inner,
144+
let Some(inner) = self.inner.as_mut() else {
145+
return Ok(ToggleConnectionHandler { inner: None });
150146
};
151147

152148
let handler = inner.handle_established_outbound_connection(

0 commit comments

Comments
 (0)