Skip to content

Commit

Permalink
chore: address latest clippy lints
Browse files Browse the repository at this point in the history
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: libp2p#4571.
  • Loading branch information
umgefahren authored Sep 28, 2023
1 parent d30eb9d commit 665181e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
2 changes: 1 addition & 1 deletion protocols/dcutr/src/behaviour_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ impl Behaviour {
fn observed_addresses(&self) -> Vec<Multiaddr> {
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()
}
Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ impl From<Rpc> 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(),
Expand Down
12 changes: 5 additions & 7 deletions protocols/perf/src/bin/perf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
21 changes: 8 additions & 13 deletions swarm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}")
}
}
}
Expand Down

0 comments on commit 665181e

Please sign in to comment.