Skip to content

Commit

Permalink
build: address clippy issues from 1.84 (#2444)
Browse files Browse the repository at this point in the history
  • Loading branch information
jouho authored Jan 10, 2025
1 parent 56117ed commit adc7ba9
Show file tree
Hide file tree
Showing 21 changed files with 32 additions and 37 deletions.
2 changes: 1 addition & 1 deletion dc/s2n-quic-dc/src/fixed_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ where
// Scan each value and check if our requested needle is present.
let values = self.values.read();
for (value_idx, value) in values.iter().enumerate() {
if value.as_ref().map_or(false, |(k, _)| *k == *needle) {
if value.as_ref().is_some_and(|(k, _)| *k == *needle) {
return Some(RwLockReadGuard::map(values, |values| {
&values[value_idx].as_ref().unwrap().1
}));
Expand Down
2 changes: 1 addition & 1 deletion dc/s2n-quic-dc/src/packet/stream/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl Packet<'_> {
let len = VarInt::try_from(self.payload.len()).ok()?;
offset.checked_sub(len)
})
.map_or(false, |v| *v == 0)
.is_some_and(|v| *v == 0)
}

#[inline]
Expand Down
6 changes: 3 additions & 3 deletions dc/s2n-quic-dc/src/stream/send/application/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ impl State {

let has_more_app_data = credits.initial_len > total_payload_len;

let included_fin = reader.final_offset().map_or(false, |fin| {
stream_offset.as_u64() + payload_len as u64 == fin.as_u64()
});
let included_fin = reader
.final_offset()
.is_some_and(|fin| stream_offset.as_u64() + payload_len as u64 == fin.as_u64());

let time_sent = clock.get_time();
probes::on_transmit_stream(
Expand Down
4 changes: 2 additions & 2 deletions quic/s2n-quic-core/src/buffer/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub trait Reader: Storage {
/// Returns `true` if the reader has the final offset buffered
#[inline]
fn has_buffered_fin(&self) -> bool {
self.final_offset().map_or(false, |fin| {
self.final_offset().is_some_and(|fin| {
let buffered_end = self
.current_offset()
.as_u64()
Expand All @@ -44,7 +44,7 @@ pub trait Reader: Storage {
#[inline]
fn is_consumed(&self) -> bool {
self.final_offset()
.map_or(false, |fin| fin == self.current_offset())
.is_some_and(|fin| fin == self.current_offset())
}

/// Skips the data in the reader until `offset` is reached, or the reader storage is exhausted.
Expand Down
5 changes: 2 additions & 3 deletions quic/s2n-quic-core/src/buffer/reassembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,13 @@ impl Reassembler {
#[inline]
pub fn is_writing_complete(&self) -> bool {
self.final_size()
.map_or(false, |len| self.total_received_len() == len)
.is_some_and(|len| self.total_received_len() == len)
}

/// Returns true if the buffer has completely been read and the final size is known
#[inline]
pub fn is_reading_complete(&self) -> bool {
self.final_size()
.map_or(false, |len| self.cursors.start_offset == len)
self.final_size() == Some(self.cursors.start_offset)
}

/// Returns the final size of the stream, if known
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-core/src/buffer/reassembler/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Storage for Reassembler {
);

// if we have a final size and this slot overlaps it then return the entire thing
let chunk = if self.cursors.final_size().map_or(false, |final_size| {
let chunk = if self.cursors.final_size().is_some_and(|final_size| {
final_size <= slot.end_allocated() && watermark >= slot.buffered_len()
}) {
slot.consume()
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-core/src/recovery/bandwidth/estimator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ impl Estimator {
|app_limited_bytes| self.delivered_bytes > app_limited_bytes;
if self
.app_limited_delivered_bytes
.map_or(false, is_app_limited_period_over)
.is_some_and(is_app_limited_period_over)
{
// Clear app-limited field if bubble is ACKed and gone
self.app_limited_delivered_bytes = None;
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-core/src/recovery/bbr/probe_bw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ impl State {
//# return Now() > BBR.cycle_stamp + interval

self.cycle_start_timestamp
.map_or(false, |cycle_stamp| now > cycle_stamp + interval)
.is_some_and(|cycle_stamp| now > cycle_stamp + interval)
}

/// Bandwidth probing can cause loss. To help coexistence with loss-based
Expand Down
5 changes: 2 additions & 3 deletions quic/s2n-quic-core/src/recovery/bbr/windowed_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ impl<

#[inline]
fn window_expired(&self, now: TimeType) -> bool {
self.last_updated.map_or(false, |last_updated| {
now - last_updated >= self.window_length
})
self.last_updated
.is_some_and(|last_updated| now - last_updated >= self.window_length)
}
}
//= https://tools.ietf.org/id/draft-cardwell-iccrg-bbr-congestion-control-02#4.5.3.2
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-core/src/recovery/persistent_congestion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Calculator {
//# potentially too few probes.
ensure!(self
.first_rtt_sample
.map_or(false, |ts| packet_info.time_sent >= ts));
.is_some_and(|ts| packet_info.time_sent >= ts));

// Check that this lost packet was sent on the same path
//
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-core/src/stream/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bytes::Bytes;
use bolero_generator::prelude::*;

static DATA: Bytes = {
const INNER: [u8; DATA_LEN] = {
static INNER: [u8; DATA_LEN] = {
let mut data = [0; DATA_LEN];
let mut idx = 0;
while idx < DATA_LEN {
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-sim/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ impl Filter {
pub fn apply(&self, params: &Parameters, conn: &Connection, conns: &[Connection]) -> bool {
self.query
.apply(params, conn, conns)
.map_or(false, |actual| (self.op)(actual, self.value))
.is_some_and(|actual| (self.op)(actual, self.value))
}
}

Expand Down
8 changes: 4 additions & 4 deletions quic/s2n-quic-transport/src/connection/local_id_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ impl LocalIdInfo {
// Returns true if the connection ID should be moved to PendingRemoval
fn is_retire_ready(&self, timestamp: Timestamp) -> bool {
!self.is_retired()
&& self.retirement_time.map_or(false, |retirement_time| {
retirement_time.has_elapsed(timestamp)
})
&& self
.retirement_time
.is_some_and(|retirement_time| retirement_time.has_elapsed(timestamp))
}

// Returns true if the connection ID has been retired and is pending removal
Expand All @@ -132,7 +132,7 @@ impl LocalIdInfo {
// Returns true if the connection ID should no longer be used
fn is_expired(&self, timestamp: Timestamp) -> bool {
self.removal_time()
.map_or(false, |removal_time| removal_time.has_elapsed(timestamp))
.is_some_and(|removal_time| removal_time.has_elapsed(timestamp))
}

// The time this connection ID should be removed
Expand Down
4 changes: 1 addition & 3 deletions quic/s2n-quic-transport/src/connection/peer_id_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ impl PeerIdInfo {
stateless_reset_token: &stateless_reset::Token,
sequence_number: u32,
) -> Result<bool, PeerIdRegistrationError> {
let reset_token_is_equal = self
.stateless_reset_token
.map_or(false, |token| token == *stateless_reset_token);
let reset_token_is_equal = self.stateless_reset_token == Some(*stateless_reset_token);
let sequence_number_is_equal = self.sequence_number == sequence_number;

if self.id == *new_id {
Expand Down
5 changes: 2 additions & 3 deletions quic/s2n-quic-transport/src/connection/transmission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@ fn has_transmission<P: transmission::interest::Provider>(
transmission_interest_provider: Option<&P>,
transmission_constraint: transmission::Constraint,
) -> bool {
transmission_interest_provider.map_or(false, |provider| {
provider.can_transmit(transmission_constraint)
})
transmission_interest_provider
.is_some_and(|provider| provider.can_transmit(transmission_constraint))
}
6 changes: 3 additions & 3 deletions quic/s2n-quic-transport/src/path/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ impl<Config: endpoint::Config> Manager<Config> {
let valid_initial_received = self.valid_initial_received();

if let Some((id, path)) = self.path_mut(path_handle) {
let source_cid_changed = datagram.source_connection_id.map_or(false, |scid| {
scid != path.peer_connection_id && valid_initial_received
});
let source_cid_changed = datagram
.source_connection_id
.is_some_and(|scid| scid != path.peer_connection_id && valid_initial_received);

if source_cid_changed {
//= https://www.rfc-editor.org/rfc/rfc9000#section-7.2
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-transport/src/stream/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub mod tx {
}

// resetting takes priority
if self.reset.is_some() || response.map_or(false, |res| res.is_reset()) {
if self.reset.is_some() || response.is_ok_and(|res| res.is_reset()) {
let response = response.expect("reset should never fail");

assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-transport/src/stream/send_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ impl SendStream {
.flow_controller_mut()
.on_packet_ack(ack_set);

let should_flush = self.write_waiter.as_ref().map_or(false, |w| w.1);
let should_flush = self.write_waiter.as_ref().is_some_and(|w| w.1);
let mut should_wake = false;
self.data_sender
.flow_controller_mut()
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic/src/client/providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl<
};
if connection_id
.lifetime()
.map_or(false, |lifetime| !valid_lifetime(lifetime))
.is_some_and(|lifetime| !valid_lifetime(lifetime))
{
return Err(StartError::new(connection::id::Error::InvalidLifetime));
};
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic/src/provider/address_token/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl Format {
if self.keys[token.header.key_id() as usize]
.duplicate_filter
.as_ref()
.map_or(false, |f| f.contains(token))
.is_some_and(|f| f.contains(token))
{
return None;
}
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic/src/server/providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl<
};
if connection_id
.lifetime()
.map_or(false, |lifetime| !valid_lifetime(lifetime))
.is_some_and(|lifetime| !valid_lifetime(lifetime))
{
return Err(StartError::new(connection::id::Error::InvalidLifetime));
};
Expand Down

0 comments on commit adc7ba9

Please sign in to comment.