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

chore: Fix clippy warnings #2453

Merged
merged 1 commit into from
Feb 24, 2025
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
7 changes: 0 additions & 7 deletions neqo-common/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ impl<'a> Decoder<'a> {
// Implement `AsRef` for `Decoder` so that values can be examined without
// moving the cursor.
impl<'a> AsRef<[u8]> for Decoder<'a> {
#[must_use]
fn as_ref(&self) -> &'a [u8] {
&self.buf[self.offset..]
}
Expand All @@ -175,7 +174,6 @@ impl Debug for Decoder<'_> {
}

impl<'a> From<&'a [u8]> for Decoder<'a> {
#[must_use]
fn from(buf: &'a [u8]) -> Self {
Decoder::new(buf)
}
Expand All @@ -185,14 +183,12 @@ impl<'a, T> From<&'a T> for Decoder<'a>
where
T: AsRef<[u8]>,
{
#[must_use]
fn from(buf: &'a T) -> Self {
Decoder::new(buf.as_ref())
}
}

impl<'b> PartialEq<Decoder<'b>> for Decoder<'_> {
#[must_use]
fn eq(&self, other: &Decoder<'b>) -> bool {
self.buf == other.buf
}
Expand Down Expand Up @@ -452,14 +448,12 @@ impl AsMut<[u8]> for Encoder {
}

impl<'a> From<Decoder<'a>> for Encoder {
#[must_use]
fn from(dec: Decoder<'a>) -> Self {
Self::from(&dec.buf[dec.offset..])
}
}

impl From<&[u8]> for Encoder {
#[must_use]
fn from(buf: &[u8]) -> Self {
Self {
buf: Vec::from(buf),
Expand All @@ -468,7 +462,6 @@ impl From<&[u8]> for Encoder {
}

impl From<Encoder> for Vec<u8> {
#[must_use]
fn from(buf: Encoder) -> Self {
buf.buf
}
Expand Down
1 change: 0 additions & 1 deletion neqo-common/src/datagram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ impl<D: AsRef<[u8]> + AsMut<[u8]>> DerefMut for Datagram<D> {

impl<D: AsRef<[u8]>> Deref for Datagram<D> {
type Target = [u8];
#[must_use]
fn deref(&self) -> &Self::Target {
AsRef::<[u8]>::as_ref(self)
}
Expand Down
2 changes: 2 additions & 0 deletions neqo-common/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ impl Header {
)
}

#[allow(clippy::missing_const_for_fn)] // TODO: False positive on nightly. Check periodically if this can be removed.
#[must_use]
pub fn name(&self) -> &str {
&self.name
}

#[allow(clippy::missing_const_for_fn)] // TODO: False positive on nightly. Check periodically if this can be removed.
#[must_use]
pub fn value(&self) -> &str {
&self.value
Expand Down
10 changes: 4 additions & 6 deletions neqo-crypto/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ impl SecretAgent {
}

/// Return any fatal alert that the TLS stack might have sent.
#[allow(clippy::missing_const_for_fn)] // TODO: False positive on nightly. Check periodically if this can be removed.
#[must_use]
pub fn alert(&self) -> Option<&Alert> {
(*self.alert).as_ref()
Expand Down Expand Up @@ -773,7 +774,7 @@ impl SecretAgent {
unsafe {
prio::PR_Close(self.fd.cast());
}
};
}
let _output = self.io.take_output();
self.fd = null_mut();
}
Expand All @@ -797,6 +798,7 @@ impl SecretAgent {
}

/// Get the active ECH configuration, which is empty if ECH is disabled.
#[allow(clippy::missing_const_for_fn)] // TODO: False positive on nightly. Check periodically if this can be removed.
#[must_use]
pub fn ech_config(&self) -> &[u8] {
&self.ech_config
Expand Down Expand Up @@ -915,6 +917,7 @@ impl Client {
ssl::SECSuccess
}

#[allow(clippy::missing_const_for_fn)] // TODO: False positive on nightly. Check periodically if this can be removed.
#[must_use]
pub fn server_name(&self) -> &str {
&self.server_name
Expand Down Expand Up @@ -992,7 +995,6 @@ impl Client {

impl Deref for Client {
type Target = SecretAgent;
#[must_use]
fn deref(&self) -> &SecretAgent {
&self.agent
}
Expand Down Expand Up @@ -1201,7 +1203,6 @@ impl Server {

impl Deref for Server {
type Target = SecretAgent;
#[must_use]
fn deref(&self) -> &SecretAgent {
&self.agent
}
Expand All @@ -1228,7 +1229,6 @@ pub enum Agent {

impl Deref for Agent {
type Target = SecretAgent;
#[must_use]
fn deref(&self) -> &SecretAgent {
match self {
Self::Client(c) => c,
Expand All @@ -1247,14 +1247,12 @@ impl DerefMut for Agent {
}

impl From<Client> for Agent {
#[must_use]
fn from(c: Client) -> Self {
Self::Client(c)
}
}

impl From<Server> for Agent {
#[must_use]
fn from(s: Server) -> Self {
Self::Server(s)
}
Expand Down
2 changes: 0 additions & 2 deletions neqo-crypto/src/agentio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ impl RecordList {

impl Deref for RecordList {
type Target = Vec<Record>;
#[must_use]
fn deref(&self) -> &Vec<Record> {
&self.records
}
Expand All @@ -141,7 +140,6 @@ impl Iterator for RecordListIter {
impl IntoIterator for RecordList {
type Item = Record;
type IntoIter = RecordListIter;
#[must_use]
fn into_iter(self) -> Self::IntoIter {
RecordListIter(self.records.into_iter())
}
Expand Down
2 changes: 0 additions & 2 deletions neqo-crypto/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ pub enum AuthenticationStatus {
}

impl From<AuthenticationStatus> for PRErrorCode {
#[must_use]
fn from(v: AuthenticationStatus) -> Self {
v as Self
}
Expand All @@ -46,7 +45,6 @@ impl From<AuthenticationStatus> for PRErrorCode {
// Note that this mapping should be removed after gecko eventually learns how to
// map into the enumerated type.
impl From<PRErrorCode> for AuthenticationStatus {
#[must_use]
fn from(v: PRErrorCode) -> Self {
Self::from_repr(v).unwrap_or(Self::Unknown)
}
Expand Down
4 changes: 0 additions & 4 deletions neqo-crypto/src/err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,9 @@ impl Error {
}

impl std::error::Error for Error {
#[must_use]
fn cause(&self) -> Option<&dyn std::error::Error> {
None
}
#[must_use]
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
None
}
Expand All @@ -100,13 +98,11 @@ impl std::fmt::Display for Error {
}

impl From<std::num::TryFromIntError> for Error {
#[must_use]
fn from(_: std::num::TryFromIntError) -> Self {
Self::IntegerOverflow
}
}
impl From<std::ffi::NulError> for Error {
#[must_use]
fn from(_: std::ffi::NulError) -> Self {
Self::InternalError
}
Expand Down
4 changes: 0 additions & 4 deletions neqo-crypto/src/p11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ macro_rules! scoped_ptr {

impl Deref for $scoped {
type Target = *mut $target;
#[must_use]
fn deref(&self) -> &*mut $target {
&self.ptr
}
Expand Down Expand Up @@ -108,7 +107,6 @@ impl PublicKey {
}

impl Clone for PublicKey {
#[must_use]
fn clone(&self) -> Self {
let ptr = unsafe { SECKEY_CopyPublicKey(self.ptr) };
assert!(!ptr.is_null());
Expand Down Expand Up @@ -163,7 +161,6 @@ impl PrivateKey {
unsafe impl Send for PrivateKey {}

impl Clone for PrivateKey {
#[must_use]
fn clone(&self) -> Self {
let ptr = unsafe { SECKEY_CopyPrivateKey(self.ptr) };
assert!(!ptr.is_null());
Expand Down Expand Up @@ -211,7 +208,6 @@ impl SymKey {
}

impl Clone for SymKey {
#[must_use]
fn clone(&self) -> Self {
let ptr = unsafe { PK11_ReferenceSymKey(self.ptr) };
assert!(!ptr.is_null());
Expand Down
1 change: 0 additions & 1 deletion neqo-crypto/src/secrets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ pub enum SecretDirection {
}

impl From<SSLSecretDirection::Type> for SecretDirection {
#[must_use]
fn from(dir: SSLSecretDirection::Type) -> Self {
Self::from_repr(dir).expect("Invalid secret direction")
}
Expand Down
1 change: 0 additions & 1 deletion neqo-crypto/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ impl TryInto<PRTime> for Time {
}

impl From<Time> for Instant {
#[must_use]
fn from(t: Time) -> Self {
t.t
}
Expand Down
16 changes: 8 additions & 8 deletions neqo-http3/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ The API consists of:
- `webtransport_session_accept` - only used by the server-side implementation
- `webtransport_close_session`
- `webtransport_create_stream_local` - this function is called when an application wants to open
a new `WebTransport` stream. For example `Http3Client::webtransport_create_stream` will call
this function.
a new `WebTransport` stream. For example `Http3Client::webtransport_create_stream` will call
this function.
- `webtransport_create_stream_remote` - this is called when a `WebTransport` stream has been
opened by the peer and this function sets up the appropriate handler for the stream.
opened by the peer and this function sets up the appropriate handler for the stream.
- functions that are called by `process_http3`
- `process_sending` - some send-streams are buffered streams(see the Streams section) and this
function is called to trigger sending of the buffer data.
function is called to trigger sending of the buffer data.
- functions that are called to handle `ConnectionEvent`s:
- `add_new_stream`
- `handle_stream_readable`
Expand Down Expand Up @@ -171,15 +171,15 @@ There are the following types of streams:
- `Decoder`: there is only a receiver stream of this type and the handler is `DecoderRecvStream`.
- `Encoder`: there is only a receiver stream of this type and the handler is `EncoderRecvStream`.
- `NewStream`: there is only a receiver stream of this type and the handler is
`NewStreamHeadReader`.
`NewStreamHeadReader`.
- `Http`: `SendMessage` and `RecvMessage` handlers are responsible for this type of streams.
- `Push`: `RecvMessage` is responsible for this type of streams.
- `ExtendedConnect`: `WebTransportSession` is responsible sender and receiver handler.
- `WebTransport(StreamId)`: `WebTransportSendStream` and `WebTransportRecvStream` are responsible
sender and receiver handler.
sender and receiver handler.
- `Unknown`: These are all other stream types that are not unknown to the current implementation
and should be handled properly by the spec, e.g., in our implementation the streams are
reset.
and should be handled properly by the spec, e.g., in our implementation the streams are
reset.

The streams are registered in `send_streams` and `recv_streams` in following ways depending if they
are local or remote:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl WebTransportSession {
SessionState::Done
};
}
};
}
Ok(())
}

Expand Down
2 changes: 0 additions & 2 deletions neqo-http3/src/server_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ impl Http3OrWebTransportStream {

impl Deref for Http3OrWebTransportStream {
type Target = StreamHandler;
#[must_use]
fn deref(&self) -> &Self::Target {
&self.stream_handler
}
Expand Down Expand Up @@ -382,7 +381,6 @@ impl WebTransportRequest {

impl Deref for WebTransportRequest {
type Target = StreamHandler;
#[must_use]
fn deref(&self) -> &Self::Target {
&self.stream_handler
}
Expand Down
2 changes: 2 additions & 0 deletions neqo-qpack/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ impl DynamicTableEntry {
self.refs -= 1;
}

#[allow(clippy::missing_const_for_fn)] // TODO: False positive on nightly. Check periodically if this can be removed.
pub fn name(&self) -> &[u8] {
&self.name
}

#[allow(clippy::missing_const_for_fn)] // TODO: False positive on nightly. Check periodically if this can be removed.
pub fn value(&self) -> &[u8] {
&self.value
}
Expand Down
5 changes: 0 additions & 5 deletions neqo-transport/src/cc/classic_cc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,30 +149,25 @@ impl<T: WindowAdjustment> CongestionControl for ClassicCongestionControl<T> {
self.qlog = qlog;
}

#[must_use]
fn cwnd(&self) -> usize {
self.congestion_window
}

#[must_use]
fn bytes_in_flight(&self) -> usize {
self.bytes_in_flight
}

#[must_use]
fn cwnd_avail(&self) -> usize {
// BIF can be higher than cwnd due to PTO packets, which are sent even
// if avail is 0, but still count towards BIF.
self.congestion_window.saturating_sub(self.bytes_in_flight)
}

#[must_use]
fn cwnd_min(&self) -> usize {
self.max_datagram_size() * 2
}

#[cfg(test)]
#[must_use]
fn cwnd_initial(&self) -> usize {
cwnd_initial(self.pmtud.plpmtu())
}
Expand Down
1 change: 1 addition & 0 deletions neqo-transport/src/cid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ impl ConnectionIdEntry<[u8; 16]> {
true
}

#[allow(clippy::missing_const_for_fn)] // TODO: False positive on nightly. Check periodically if this can be removed.
pub fn is_empty(&self) -> bool {
self.seqno == CONNECTION_ID_SEQNO_EMPTY || self.cid.is_empty()
}
Expand Down
Loading
Loading