Skip to content

Commit

Permalink
build: fix clippy warnings for 1.78 (#2199)
Browse files Browse the repository at this point in the history
* build: fix clippy warnings for 1.78

* remove unused packet_number_space method

* allow dead code

* remove unreachables
  • Loading branch information
WesleyRosenblum authored May 4, 2024
1 parent de5c33e commit 6dd41e0
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 28 deletions.
2 changes: 0 additions & 2 deletions dc/s2n-quic-dc/src/msg/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ impl Addr {
}
_ => unsafe {
assume!(false, "invalid remote address");
unreachable!()
},
}
}
Expand Down Expand Up @@ -113,7 +112,6 @@ impl Addr {
}
_ => unsafe {
assume!(false, "invalid remote address");
unreachable!()
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-core/src/interval_set/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ impl<T: IntervalBound> IntervalSet<T> {
#[inline]
pub fn union(&mut self, other: &Self) -> Result<(), IntervalSetError> {
if self.intervals.is_empty() {
self.intervals = other.intervals.clone();
self.intervals.clone_from(&other.intervals);
return Ok(());
}

Expand Down
9 changes: 5 additions & 4 deletions quic/s2n-quic-qns/src/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,15 @@ impl Default for TlsProviders {
}
}

impl ToString for TlsProviders {
fn to_string(&self) -> String {
match self {
impl core::fmt::Display for TlsProviders {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let str = match self {
#[cfg(unix)]
TlsProviders::S2N => String::from("s2n-tls"),
TlsProviders::Rustls => String::from("rustls"),
TlsProviders::Null => String::from("null"),
}
};
write!(f, "{}", str)
}
}

Expand Down
2 changes: 2 additions & 0 deletions quic/s2n-quic-sim/src/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ impl Batch {
plan.run(out, &command, self.skip_run, &mut reports)?;
}

// See https://github.com/rust-lang/rust-clippy/pull/12756
#[allow(clippy::assigning_clones)]
for (_title, report) in reports.iter_mut() {
*report = report.strip_prefix(out).unwrap().to_owned();
}
Expand Down
6 changes: 6 additions & 0 deletions quic/s2n-quic-transport/src/connection/open_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ impl Pair {
}
}

impl Default for Pair {
fn default() -> Self {
Self::new()
}
}

#[derive(Debug)]
pub(crate) struct Token(Option<NonZeroU64>);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl<L: LocalLimits, OpenNotify: OpenNotifyBehavior> LocalInitiated<L, OpenNotif
let prev = &self.wakers[index];
// update the waker if it's changed
if !prev.will_wake(context.waker()) {
self.wakers[index] = context.waker().clone();
self.wakers[index].clone_from(context.waker())
}
} else {
// Store a waker that can be woken when we get more credit
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-transport/src/stream/stream_container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ impl<S: StreamTrait> InterestLists<S> {
waiting_for_stream_flow_control_credits
);

if !interests.retained != node.done_streams_link.is_linked() {
if interests.retained == node.done_streams_link.is_linked() {
if !interests.retained {
self.done_streams.push_back(node.clone());
} else {
Expand Down
5 changes: 0 additions & 5 deletions quic/s2n-quic-transport/src/transmission/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use crate::{
transmission::{self, Mode, Provider as _},
};
use core::ops::RangeInclusive;
use s2n_quic_core::packet::number::PacketNumberSpace;

pub enum Payload<'a, Config: endpoint::Config> {
Normal(Normal<'a, Config>),
Expand Down Expand Up @@ -84,10 +83,6 @@ impl<'a, Config: endpoint::Config> super::Payload for Payload<'a, Config> {
Payload::PathValidationOnly(inner) => inner.on_transmit(context),
}
}

fn packet_number_space(&self) -> PacketNumberSpace {
PacketNumberSpace::ApplicationData
}
}

impl<'a, Config: endpoint::Config> transmission::interest::Provider for Payload<'a, Config> {
Expand Down
4 changes: 0 additions & 4 deletions quic/s2n-quic-transport/src/transmission/connection_close.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ impl<'a> super::Payload for Payload<'a> {
fn on_transmit<W: WriteContext>(&mut self, context: &mut W) {
context.write_frame(self.connection_close);
}

fn packet_number_space(&self) -> PacketNumberSpace {
self.packet_number_space
}
}

impl<'a> transmission::interest::Provider for Payload<'a> {
Expand Down
4 changes: 0 additions & 4 deletions quic/s2n-quic-transport/src/transmission/early.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ impl<'a, Config: endpoint::Config> super::Payload for Payload<'a, Config> {
self.ack_manager.on_transmit_complete(context);
}
}

fn packet_number_space(&self) -> PacketNumberSpace {
self.packet_number_space
}
}

impl<'a, Config: endpoint::Config> transmission::interest::Provider for Payload<'a, Config> {
Expand Down
7 changes: 1 addition & 6 deletions quic/s2n-quic-transport/src/transmission/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,13 @@ use s2n_codec::{encoder::scatter, Encoder};
use s2n_quic_core::{
event,
frame::Padding,
packet::{
encoding::PacketPayloadEncoder,
number::{PacketNumber, PacketNumberSpace},
stateless_reset,
},
packet::{encoding::PacketPayloadEncoder, number::PacketNumber, stateless_reset},
time::Timestamp,
};

pub trait Payload: interest::Provider {
fn size_hint(&self, payload_range: RangeInclusive<usize>) -> usize;
fn on_transmit<W: WriteContext>(&mut self, context: &mut W);
fn packet_number_space(&self) -> PacketNumberSpace;
}

pub struct Transmission<'a, 'sub, Config: endpoint::Config, P: Payload> {
Expand Down
6 changes: 6 additions & 0 deletions quic/s2n-quic/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ pub mod stateless_reset_token;
pub mod tls;

// These providers are not currently exposed to applications
#[allow(dead_code)]
pub(crate) mod connection_close_formatter;
#[allow(dead_code)]
pub(crate) mod path_migration;
#[allow(dead_code)]
pub(crate) mod sync;

cfg_if!(
if #[cfg(any(test, feature = "unstable-provider-packet-interceptor"))] {
pub mod packet_interceptor;
} else {
#[allow(dead_code)]
pub(crate) mod packet_interceptor;
}
);
Expand All @@ -34,6 +38,7 @@ cfg_if!(
if #[cfg(any(test, feature = "unstable-provider-random"))] {
pub mod random;
} else {
#[allow(dead_code)]
pub(crate) mod random;
}
);
Expand All @@ -42,6 +47,7 @@ cfg_if!(
if #[cfg(any(test, feature = "unstable-provider-datagram"))] {
pub mod datagram;
} else {
#[allow(dead_code)]
pub(crate) mod datagram;
}
);
Expand Down

0 comments on commit 6dd41e0

Please sign in to comment.