Skip to content

Commit

Permalink
chore: Enable the ref_patterns clippy lint (#2326)
Browse files Browse the repository at this point in the history
And fix all the warnings that it generates.

Signed-off-by: Lars Eggert <[email protected]>
  • Loading branch information
larseggert authored Jan 9, 2025
1 parent 3c48567 commit c9815b5
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pedantic = { level = "warn", priority = -1 }
if_then_some_else_none = "warn"
get_unwrap = "warn"
pathbuf_init_then_push = "warn"
ref_patterns = "warn"
renamed_function_params = "warn"

# Optimize build dependencies, because bindgen and proc macros / style
Expand Down
12 changes: 6 additions & 6 deletions neqo-crypto/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,8 @@ impl SecretAgent {
/// Calling this function returns None until the connection is complete.
#[must_use]
pub const fn info(&self) -> Option<&SecretAgentInfo> {
match self.state {
HandshakeState::Complete(ref info) => Some(info),
match &self.state {
HandshakeState::Complete(info) => Some(info),
_ => None,
}
}
Expand Down Expand Up @@ -692,8 +692,8 @@ impl SecretAgent {
// Within this scope, _h maintains a mutable reference to self.io.
let _h = self.io.wrap(input);
match self.state {
HandshakeState::Authenticated(ref err) => unsafe {
ssl::SSL_AuthCertificateComplete(self.fd, *err)
HandshakeState::Authenticated(err) => unsafe {
ssl::SSL_AuthCertificateComplete(self.fd, err)
},
_ => unsafe { ssl::SSL_ForceHandshake(self.fd) },
}
Expand Down Expand Up @@ -726,9 +726,9 @@ impl SecretAgent {
let records = self.setup_raw()?;

// Fire off any authentication we might need to complete.
if let HandshakeState::Authenticated(ref err) = self.state {
if let HandshakeState::Authenticated(err) = self.state {
let result =
secstatus_to_res(unsafe { ssl::SSL_AuthCertificateComplete(self.fd, *err) });
secstatus_to_res(unsafe { ssl::SSL_AuthCertificateComplete(self.fd, err) });
qdebug!([self], "SSL_AuthCertificateComplete: {:?}", result);
// This should return SECSuccess, so don't use update_state().
self.capture_error(result)?;
Expand Down
4 changes: 2 additions & 2 deletions neqo-http3/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,7 @@ impl Http3Connection {
conn: &mut Connection,
) -> Option<Box<dyn RecvStream>> {
let stream = self.recv_streams.remove(&stream_id);
if let Some(ref s) = stream {
if let Some(s) = &stream {
if s.stream_type() == Http3StreamType::ExtendedConnect {
self.send_streams.remove(&stream_id).unwrap();
if let Some(wt) = s.webtransport() {
Expand All @@ -1617,7 +1617,7 @@ impl Http3Connection {
conn: &mut Connection,
) -> Option<Box<dyn SendStream>> {
let stream = self.send_streams.remove(&stream_id);
if let Some(ref s) = stream {
if let Some(s) = &stream {
if s.stream_type() == Http3StreamType::ExtendedConnect {
if let Some(wt) = self.recv_streams.remove(&stream_id).unwrap().webtransport() {
self.remove_extended_connect(&wt, conn);
Expand Down
5 changes: 1 addition & 4 deletions neqo-http3/src/recv_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,7 @@ impl RecvMessage {
}
};
}
RecvMessageState::DecodingHeaders {
ref header_block,
fin,
} => {
RecvMessageState::DecodingHeaders { header_block, fin } => {
if self
.qpack_decoder
.borrow()
Expand Down
4 changes: 2 additions & 2 deletions neqo-transport/src/addr_valid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ impl NewTokenState {
/// Is there a token available?
pub fn has_token(&self) -> bool {
match self {
Self::Client { ref pending, .. } => !pending.is_empty(),
Self::Client { pending, .. } => !pending.is_empty(),
Self::Server(..) => false,
}
}
Expand Down Expand Up @@ -322,7 +322,7 @@ impl NewTokenState {
pub fn save_token(&mut self, token: Vec<u8>) {
if let Self::Client {
ref mut pending,
ref old,
old,
} = self
{
for t in old.iter().rev().chain(pending.iter().rev()) {
Expand Down
2 changes: 1 addition & 1 deletion neqo-transport/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl AddressValidationInfo {

pub fn generate_new_token(&self, peer_address: SocketAddr, now: Instant) -> Option<Vec<u8>> {
match self {
Self::Server(ref w) => w.upgrade().and_then(|validation| {
Self::Server(w) => w.upgrade().and_then(|validation| {
validation
.borrow()
.generate_new_token(peer_address, now)
Expand Down

0 comments on commit c9815b5

Please sign in to comment.