Skip to content

Commit 930118e

Browse files
authored
fix(ci): Clippy Beta
Fixes CI failure in Clippy (Beta) https://github.com/libp2p/rust-libp2p/actions/runs/12055058396/job/33614543029 Pull-Request: #5700.
1 parent 0d890fd commit 930118e

File tree

21 files changed

+45
-17
lines changed

21 files changed

+45
-17
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ libp2p-mdns = { version = "0.46.0", path = "protocols/mdns" }
8888
libp2p-memory-connection-limits = { version = "0.3.1", path = "misc/memory-connection-limits" }
8989
libp2p-metrics = { version = "0.15.0", path = "misc/metrics" }
9090
libp2p-mplex = { version = "0.42.0", path = "muxers/mplex" }
91-
libp2p-noise = { version = "0.45.0", path = "transports/noise" }
91+
libp2p-noise = { version = "0.45.1", path = "transports/noise" }
9292
libp2p-perf = { version = "0.4.0", path = "protocols/perf" }
9393
libp2p-ping = { version = "0.45.1", path = "protocols/ping" }
9494
libp2p-plaintext = { version = "0.42.0", path = "transports/plaintext" }
@@ -111,7 +111,7 @@ libp2p-webrtc-utils = { version = "0.3.0", path = "misc/webrtc-utils" }
111111
libp2p-webrtc-websys = { version = "0.4.0-alpha.2", path = "transports/webrtc-websys" }
112112
libp2p-websocket = { version = "0.44.1", path = "transports/websocket" }
113113
libp2p-websocket-websys = { version = "0.4.1", path = "transports/websocket-websys" }
114-
libp2p-webtransport-websys = { version = "0.4.0", path = "transports/webtransport-websys" }
114+
libp2p-webtransport-websys = { version = "0.4.1", path = "transports/webtransport-websys" }
115115
libp2p-yamux = { version = "0.46.0", path = "muxers/yamux" }
116116

117117
# External dependencies

protocols/gossipsub/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@
1818
- Introduce back pressure and penalize slow peers. Drop stale messages that timeout before being
1919
delivered.
2020
See [PR 5595](https://github.com/libp2p/rust-libp2p/pull/5595).
21+
2122
- Change `Behaviour::unsubscribe` and `Behaviour::report_message_validation_result`
2223
to `bool` they don't need to be a `Result`.
2324
See [PR 5595](https://github.com/libp2p/rust-libp2p/pull/5595).
2425

26+
- Fix `cargo clippy` warnings in `rustc 1.84.0-beta.1`.
27+
See [PR 5700](https://github.com/libp2p/rust-libp2p/pull/5700).
28+
2529
## 0.47.0
2630

2731
<!-- Update to libp2p-swarm v0.45.0 -->

protocols/gossipsub/src/backoff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl BackoffStorage {
124124
pub(crate) fn is_backoff_with_slack(&self, topic: &TopicHash, peer: &PeerId) -> bool {
125125
self.backoffs
126126
.get(topic)
127-
.map_or(false, |m| m.contains_key(peer))
127+
.is_some_and(|m| m.contains_key(peer))
128128
}
129129

130130
pub(crate) fn get_backoff_time(&self, topic: &TopicHash, peer: &PeerId) -> Option<Instant> {

protocols/gossipsub/src/behaviour.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1689,7 +1689,7 @@ where
16891689
let self_published = !self.config.allow_self_origin()
16901690
&& if let Some(own_id) = self.publish_config.get_own_id() {
16911691
own_id != propagation_source
1692-
&& raw_message.source.as_ref().map_or(false, |s| s == own_id)
1692+
&& raw_message.source.as_ref().is_some_and(|s| s == own_id)
16931693
} else {
16941694
self.published_message_ids.contains(msg_id)
16951695
};

protocols/kad/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
See [PR 5573](https://github.com/libp2p/rust-libp2p/pull/5573).
77
- Add `Behavior::find_closest_local_peers()`.
88
See [PR 5645](https://github.com/libp2p/rust-libp2p/pull/5645).
9+
- Fix `cargo clippy` warnings in `rustc 1.84.0-beta.1`.
10+
See [PR 5700](https://github.com/libp2p/rust-libp2p/pull/5700).
911

1012
## 0.46.2
1113

protocols/kad/src/jobs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl PutRecordJob {
203203
T: RecordStore,
204204
{
205205
if self.inner.check_ready(cx, now) {
206-
let publish = self.next_publish.map_or(false, |t_pub| now >= t_pub);
206+
let publish = self.next_publish.is_some_and(|t_pub| now >= t_pub);
207207
let records = store
208208
.records()
209209
.filter_map(|r| {

protocols/kad/src/kbucket.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,12 +529,12 @@ where
529529

530530
/// Returns true if the bucket has a pending node.
531531
pub fn has_pending(&self) -> bool {
532-
self.bucket.pending().map_or(false, |n| !n.is_ready())
532+
self.bucket.pending().is_some_and(|n| !n.is_ready())
533533
}
534534

535535
/// Tests whether the given distance falls into this bucket.
536536
pub fn contains(&self, d: &Distance) -> bool {
537-
BucketIndex::new(d).map_or(false, |i| i == self.index)
537+
BucketIndex::new(d).is_some_and(|i| i == self.index)
538538
}
539539

540540
/// Generates a random distance that falls into this bucket.

protocols/kad/src/kbucket/bucket.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ where
377377
// Adjust `first_connected_pos` accordingly.
378378
match status {
379379
NodeStatus::Connected => {
380-
if self.first_connected_pos.map_or(false, |p| p == pos.0)
380+
if self.first_connected_pos.is_some_and(|p| p == pos.0)
381381
&& pos.0 == self.nodes.len()
382382
{
383383
// It was the last connected node.
@@ -398,7 +398,7 @@ where
398398

399399
/// Returns the status of the node at the given position.
400400
pub(crate) fn status(&self, pos: Position) -> NodeStatus {
401-
if self.first_connected_pos.map_or(false, |i| pos.0 >= i) {
401+
if self.first_connected_pos.is_some_and(|i| pos.0 >= i) {
402402
NodeStatus::Connected
403403
} else {
404404
NodeStatus::Disconnected

protocols/kad/src/record.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl Record {
101101

102102
/// Checks whether the record is expired w.r.t. the given `Instant`.
103103
pub fn is_expired(&self, now: Instant) -> bool {
104-
self.expires.map_or(false, |t| now >= t)
104+
self.expires.is_some_and(|t| now >= t)
105105
}
106106
}
107107

@@ -154,7 +154,7 @@ impl ProviderRecord {
154154

155155
/// Checks whether the provider record is expired w.r.t. the given `Instant`.
156156
pub fn is_expired(&self, now: Instant) -> bool {
157-
self.expires.map_or(false, |t| now >= t)
157+
self.expires.is_some_and(|t| now >= t)
158158
}
159159
}
160160

0 commit comments

Comments
 (0)