Skip to content

Commit

Permalink
chore: address clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
jxs committed May 6, 2024
1 parent a91c48f commit 4cdce02
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ jobs:
fail-fast: false
matrix:
rust-version: [
1.77.0, # current stable
1.78.0, # current stable
beta,
]
steps:
Expand Down
8 changes: 4 additions & 4 deletions libp2p/src/bandwidth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl<SMInner: AsyncRead> AsyncRead for InstrumentedStream<SMInner> {
let this = self.project();
let num_bytes = ready!(this.inner.poll_read(cx, buf))?;
this.sinks.inbound.fetch_add(
u64::try_from(num_bytes).unwrap_or(u64::max_value()),
u64::try_from(num_bytes).unwrap_or(u64::MAX),
Ordering::Relaxed,
);
Poll::Ready(Ok(num_bytes))
Expand All @@ -168,7 +168,7 @@ impl<SMInner: AsyncRead> AsyncRead for InstrumentedStream<SMInner> {
let this = self.project();
let num_bytes = ready!(this.inner.poll_read_vectored(cx, bufs))?;
this.sinks.inbound.fetch_add(
u64::try_from(num_bytes).unwrap_or(u64::max_value()),
u64::try_from(num_bytes).unwrap_or(u64::MAX),
Ordering::Relaxed,
);
Poll::Ready(Ok(num_bytes))
Expand All @@ -184,7 +184,7 @@ impl<SMInner: AsyncWrite> AsyncWrite for InstrumentedStream<SMInner> {
let this = self.project();
let num_bytes = ready!(this.inner.poll_write(cx, buf))?;
this.sinks.outbound.fetch_add(
u64::try_from(num_bytes).unwrap_or(u64::max_value()),
u64::try_from(num_bytes).unwrap_or(u64::MAX),
Ordering::Relaxed,
);
Poll::Ready(Ok(num_bytes))
Expand All @@ -198,7 +198,7 @@ impl<SMInner: AsyncWrite> AsyncWrite for InstrumentedStream<SMInner> {
let this = self.project();
let num_bytes = ready!(this.inner.poll_write_vectored(cx, bufs))?;
this.sinks.outbound.fetch_add(
u64::try_from(num_bytes).unwrap_or(u64::max_value()),
u64::try_from(num_bytes).unwrap_or(u64::MAX),
Ordering::Relaxed,
);
Poll::Ready(Ok(num_bytes))
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions misc/metrics/src/bandwidth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl<SMInner: AsyncRead> AsyncRead for InstrumentedStream<SMInner> {
let num_bytes = ready!(this.inner.poll_read(cx, buf))?;
this.metrics
.inbound
.inc_by(u64::try_from(num_bytes).unwrap_or(u64::max_value()));
.inc_by(u64::try_from(num_bytes).unwrap_or(u64::MAX));
Poll::Ready(Ok(num_bytes))
}

Expand All @@ -268,7 +268,7 @@ impl<SMInner: AsyncRead> AsyncRead for InstrumentedStream<SMInner> {
let num_bytes = ready!(this.inner.poll_read_vectored(cx, bufs))?;
this.metrics
.inbound
.inc_by(u64::try_from(num_bytes).unwrap_or(u64::max_value()));
.inc_by(u64::try_from(num_bytes).unwrap_or(u64::MAX));
Poll::Ready(Ok(num_bytes))
}
}
Expand All @@ -283,7 +283,7 @@ impl<SMInner: AsyncWrite> AsyncWrite for InstrumentedStream<SMInner> {
let num_bytes = ready!(this.inner.poll_write(cx, buf))?;
this.metrics
.outbound
.inc_by(u64::try_from(num_bytes).unwrap_or(u64::max_value()));
.inc_by(u64::try_from(num_bytes).unwrap_or(u64::MAX));
Poll::Ready(Ok(num_bytes))
}

Expand All @@ -296,7 +296,7 @@ impl<SMInner: AsyncWrite> AsyncWrite for InstrumentedStream<SMInner> {
let num_bytes = ready!(this.inner.poll_write_vectored(cx, bufs))?;
this.metrics
.outbound
.inc_by(u64::try_from(num_bytes).unwrap_or(u64::max_value()));
.inc_by(u64::try_from(num_bytes).unwrap_or(u64::MAX));
Poll::Ready(Ok(num_bytes))
}

Expand Down
1 change: 0 additions & 1 deletion misc/multistream-select/src/length_delimited.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use std::{
io,
pin::Pin,
task::{Context, Poll},
u16,
};

const MAX_LEN_BYTES: u16 = 2;
Expand Down
2 changes: 1 addition & 1 deletion misc/quickcheck-ext/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub trait GenRange {
fn gen_range<T: Unsigned + Arbitrary + Copy>(&mut self, _range: Range<T>) -> T;

fn gen_index(&mut self, ubound: usize) -> usize {
if ubound <= (core::u32::MAX as usize) {
if ubound <= (u32::MAX as usize) {
self.gen_range(0..ubound as u32) as usize
} else {
self.gen_range(0..ubound)
Expand Down
2 changes: 1 addition & 1 deletion protocols/kad/src/kbucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ mod tests {
assert!(!bucket_ref.contains(&Distance(min.0 - 1)));
}

if max != Distance(U256::max_value()) {
if max != Distance(U256::MAX) {
// ^ avoid overflow
assert!(!bucket_ref.contains(&Distance(max.0 + 1)));
}
Expand Down
2 changes: 1 addition & 1 deletion protocols/mdns/src/behaviour/iface/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ fn duration_to_secs(duration: Duration) -> u32 {
let secs = duration
.as_secs()
.saturating_add(u64::from(duration.subsec_nanos() > 0));
cmp::min(secs, From::from(u32::max_value())) as u32
cmp::min(secs, From::from(u32::MAX)) as u32
}

/// Appends a big-endian u32 to `out`.
Expand Down
4 changes: 2 additions & 2 deletions protocols/mdns/src/behaviour/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub(crate) mod tokio {
// Taken from: https://docs.rs/async-io/1.7.0/src/async_io/lib.rs.html#91
let mut inner = time::interval_at(
TokioInstant::from_std(instant),
Duration::new(std::u64::MAX, 1_000_000_000 - 1),
Duration::new(u64::MAX, 1_000_000_000 - 1),
);
inner.set_missed_tick_behavior(MissedTickBehavior::Skip);
Self { inner }
Expand All @@ -125,7 +125,7 @@ pub(crate) mod tokio {
}

fn size_hint(&self) -> (usize, Option<usize>) {
(std::usize::MAX, None)
(usize::MAX, None)
}
}
}
3 changes: 3 additions & 0 deletions transports/websocket-websys/src/web_context.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// TODO: remove when https://github.com/rust-lang/rust-clippy/issues/12377 fix lands in stable clippy.
#![allow(clippy::empty_docs)]

use wasm_bindgen::prelude::*;
use web_sys::window;

Expand Down

0 comments on commit 4cdce02

Please sign in to comment.