Skip to content

Commit

Permalink
Apply clippy suggestions from Rust 1.79
Browse files Browse the repository at this point in the history
  • Loading branch information
djc authored and Ralith committed Jun 13, 2024
1 parent 11050d6 commit 7b97a3f
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 27 deletions.
2 changes: 1 addition & 1 deletion quinn-proto/src/congestion/new_reno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl NewReno {
pub fn new(config: Arc<NewRenoConfig>, now: Instant, current_mtu: u16) -> Self {
Self {
window: config.initial_window,
ssthresh: u64::max_value(),
ssthresh: u64::MAX,
recovery_start_time: now,
current_mtu: current_mtu as u64,
config,
Expand Down
4 changes: 2 additions & 2 deletions quinn-proto/src/connection/pacing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Pacer {
}

// we disable pacing for extremely large windows
if window > u32::max_value().into() {
if window > u32::MAX.into() {
return None;
}

Expand Down Expand Up @@ -104,7 +104,7 @@ impl Pacer {

let unscaled_delay = smoothed_rtt
.checked_mul((bytes_to_send.max(self.capacity) - self.tokens) as _)
.unwrap_or_else(|| Duration::new(u64::max_value(), 999_999_999))
.unwrap_or_else(|| Duration::new(u64::MAX, 999_999_999))
/ window;

// divisions come before multiplications to prevent overflow
Expand Down
2 changes: 1 addition & 1 deletion quinn-proto/src/connection/spaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ impl Dedup {
if let Some(diff) = packet.checked_sub(self.next) {
// Right of window
self.window = (self.window << 1 | 1)
.checked_shl(cmp::min(diff, u64::from(u32::max_value())) as u32)
.checked_shl(cmp::min(diff, u64::from(u32::MAX)) as u32)
.unwrap_or(0);
self.next = packet + 1;
false
Expand Down
2 changes: 1 addition & 1 deletion quinn-proto/src/range_set/btree_range_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl RangeSet {
/// Find the closest range to `x` that begins after it
fn succ(&self, x: u64) -> Option<(u64, u64)> {
self.0
.range((Excluded(x), Included(u64::max_value())))
.range((Excluded(x), Included(u64::MAX)))
.next()
.map(|(&x, &y)| (x, y))
}
Expand Down
2 changes: 1 addition & 1 deletion quinn-proto/src/transport_parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl TransportParameters {
.into(),
max_datagram_frame_size: config
.datagram_receive_buffer_size
.map(|x| (x.min(u16::max_value().into()) as u16).into()),
.map(|x| (x.min(u16::MAX.into()) as u16).into()),
grease_quic_bit: endpoint_config.grease_quic_bit,
min_ack_delay: Some(
VarInt::from_u64(u64::try_from(TIMER_GRANULARITY.as_micros()).unwrap()).unwrap(),
Expand Down
2 changes: 1 addition & 1 deletion quinn/examples/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ async fn run(options: Opt) -> Result<()> {
let response_start = Instant::now();
eprintln!("request sent at {:?}", response_start - start);
let resp = recv
.read_to_end(usize::max_value())
.read_to_end(usize::MAX)
.await
.map_err(|e| anyhow!("failed to read response: {}", e))?;
let duration = response_start.elapsed();
Expand Down
2 changes: 1 addition & 1 deletion quinn/src/recv_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ impl RecvStream {
stream: self,
size_limit,
read: Vec::new(),
start: u64::max_value(),
start: u64::MAX,
end: 0,
}
.await
Expand Down
25 changes: 6 additions & 19 deletions quinn/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,7 @@ fn read_after_close() {
.expect("connect");
tokio::time::sleep_until(Instant::now() + Duration::from_millis(100)).await;
let mut stream = new_conn.accept_uni().await.expect("incoming streams");
let msg = stream
.read_to_end(usize::max_value())
.await
.expect("read_to_end");
let msg = stream.read_to_end(usize::MAX).await.expect("read_to_end");
assert_eq!(msg, MSG);
});
}
Expand Down Expand Up @@ -320,7 +317,7 @@ async fn zero_rtt() {
let c = connection.clone();
tokio::spawn(async move {
while let Ok(mut x) = c.accept_uni().await {
let msg = x.read_to_end(usize::max_value()).await.unwrap();
let msg = x.read_to_end(usize::MAX).await.unwrap();
assert_eq!(msg, MSG0);
}
});
Expand Down Expand Up @@ -348,18 +345,12 @@ async fn zero_rtt() {

{
let mut stream = connection.accept_uni().await.expect("incoming streams");
let msg = stream
.read_to_end(usize::max_value())
.await
.expect("read_to_end");
let msg = stream.read_to_end(usize::MAX).await.expect("read_to_end");
assert_eq!(msg, MSG0);
// Read a 1-RTT message to ensure the handshake completes fully, allowing the server's
// NewSessionTicket frame to be received.
let mut stream = connection.accept_uni().await.expect("incoming streams");
let msg = stream
.read_to_end(usize::max_value())
.await
.expect("read_to_end");
let msg = stream.read_to_end(usize::MAX).await.expect("read_to_end");
assert_eq!(msg, MSG1);
drop(connection);
}
Expand All @@ -381,10 +372,7 @@ async fn zero_rtt() {
});

let mut stream = connection.accept_uni().await.expect("incoming streams");
let msg = stream
.read_to_end(usize::max_value())
.await
.expect("read_to_end");
let msg = stream.read_to_end(usize::MAX).await.expect("read_to_end");
assert_eq!(msg, MSG0);
assert!(zero_rtt.await);

Expand Down Expand Up @@ -581,8 +569,7 @@ fn run_echo(args: EchoArgs) {
send.write_all(&msg).await.expect("write");
send.finish().unwrap();
};
let recv_task =
async { recv.read_to_end(usize::max_value()).await.expect("read") };
let recv_task = async { recv.read_to_end(usize::MAX).await.expect("read") };

let (_, data) = tokio::join!(send_task, recv_task);

Expand Down

0 comments on commit 7b97a3f

Please sign in to comment.