Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: fix clippy warnings for 1.78 #2199

Merged
merged 5 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were these just unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apparently, I'm not sure why it just started popping up in clippy though

Copy link
Contributor

@camshaft camshaft May 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trait is internal to the crate and clippy just started being able to detect this type of dead code. But yeah this method just was never called anywhere.

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
Loading