From 665181efb5190285c6c1b1294e8f0b42d9e5a351 Mon Sep 17 00:00:00 2001 From: Hannes <55623006+umgefahren@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:08:51 +0200 Subject: [PATCH] chore: address latest clippy lints I ran clippy on the current nightly and fixed issues found by it. Noteworthy are two instances of the [never_loop](https://rust-lang.github.io/rust-clippy/master/index.html#/never_loop) lint. Pull-Request: #4571. --- protocols/dcutr/src/behaviour_impl.rs | 2 +- protocols/gossipsub/src/types.rs | 2 +- protocols/perf/src/bin/perf.rs | 12 +++++------- swarm/src/lib.rs | 21 ++++++++------------- 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/protocols/dcutr/src/behaviour_impl.rs b/protocols/dcutr/src/behaviour_impl.rs index 4993da655d3..748e163429d 100644 --- a/protocols/dcutr/src/behaviour_impl.rs +++ b/protocols/dcutr/src/behaviour_impl.rs @@ -103,8 +103,8 @@ impl Behaviour { fn observed_addresses(&self) -> Vec { self.external_addresses .iter() - .cloned() .filter(|a| !a.iter().any(|p| p == Protocol::P2pCircuit)) + .cloned() .map(|a| a.with(Protocol::P2p(self.local_peer_id))) .collect() } diff --git a/protocols/gossipsub/src/types.rs b/protocols/gossipsub/src/types.rs index 9c9cd3f97f1..f1865635454 100644 --- a/protocols/gossipsub/src/types.rs +++ b/protocols/gossipsub/src/types.rs @@ -330,7 +330,7 @@ impl From for proto::RPC { .into_iter() .map(|info| proto::PeerInfo { peer_id: info.peer_id.map(|id| id.to_bytes()), - /// TODO, see https://github.com/libp2p/specs/pull/217 + // TODO, see https://github.com/libp2p/specs/pull/217 signed_peer_record: None, }) .collect(), diff --git a/protocols/perf/src/bin/perf.rs b/protocols/perf/src/bin/perf.rs index 31644324571..4205cc3843b 100644 --- a/protocols/perf/src/bin/perf.rs +++ b/protocols/perf/src/bin/perf.rs @@ -428,14 +428,12 @@ async fn connect( let start = Instant::now(); swarm.dial(server_address.clone()).unwrap(); - let server_peer_id = loop { - match swarm.next().await.unwrap() { - SwarmEvent::ConnectionEstablished { peer_id, .. } => break peer_id, - SwarmEvent::OutgoingConnectionError { peer_id, error, .. } => { - bail!("Outgoing connection error to {:?}: {:?}", peer_id, error); - } - e => panic!("{e:?}"), + let server_peer_id = match swarm.next().await.unwrap() { + SwarmEvent::ConnectionEstablished { peer_id, .. } => peer_id, + SwarmEvent::OutgoingConnectionError { peer_id, error, .. } => { + bail!("Outgoing connection error to {:?}: {:?}", peer_id, error); } + e => panic!("{e:?}"), }; let duration = start.elapsed(); diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index 44dc3c8da66..22433d22c62 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -2153,19 +2153,14 @@ mod tests { ) .unwrap(); for mut transport in transports.into_iter() { - loop { - match futures::future::select(transport.select_next_some(), swarm.next()) - .await - { - future::Either::Left((TransportEvent::Incoming { .. }, _)) => { - break; - } - future::Either::Left(_) => { - panic!("Unexpected transport event.") - } - future::Either::Right((e, _)) => { - panic!("Expect swarm to not emit any event {e:?}") - } + match futures::future::select(transport.select_next_some(), swarm.next()).await + { + future::Either::Left((TransportEvent::Incoming { .. }, _)) => {} + future::Either::Left(_) => { + panic!("Unexpected transport event.") + } + future::Either::Right((e, _)) => { + panic!("Expect swarm to not emit any event {e:?}") } } }