Skip to content

Commit

Permalink
chore: Address new nightly clippy warnings (#2151)
Browse files Browse the repository at this point in the history
  • Loading branch information
larseggert authored Oct 7, 2024
1 parent 92fe2da commit d6cc30e
Show file tree
Hide file tree
Showing 18 changed files with 111 additions and 102 deletions.
7 changes: 4 additions & 3 deletions neqo-bin/src/client/http09.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub struct Handler<'a> {
read_buffer: Vec<u8>,
}

impl<'a> Handler<'a> {
impl Handler<'_> {
fn reinit(&mut self) {
for url in self.handled_urls.drain(..) {
self.url_queue.push_front(url);
Expand All @@ -49,7 +49,7 @@ impl<'a> Handler<'a> {
}
}

impl<'a> super::Handler for Handler<'a> {
impl super::Handler for Handler<'_> {
type Client = Connection;

fn handle(&mut self, client: &mut Self::Client) -> Res<bool> {
Expand Down Expand Up @@ -255,7 +255,8 @@ impl<'b> Handler<'b> {
.stream_send(client_stream_id, req.as_bytes())
.unwrap();
client.stream_close_send(client_stream_id).unwrap();
let out_file = get_output_file(&url, &self.args.output_dir, &mut self.all_paths);
let out_file =
get_output_file(&url, self.args.output_dir.as_ref(), &mut self.all_paths);
self.streams.insert(client_stream_id, out_file);
self.handled_urls.push(url);
true
Expand Down
8 changes: 4 additions & 4 deletions neqo-bin/src/client/http3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl super::Client for Http3Client {
}
}

impl<'a> Handler<'a> {
impl Handler<'_> {
fn reinit(&mut self) {
for url in self.url_handler.handled_urls.drain(..) {
self.url_handler.url_queue.push_front(url);
Expand All @@ -165,7 +165,7 @@ impl<'a> Handler<'a> {
}
}

impl<'a> super::Handler for Handler<'a> {
impl super::Handler for Handler<'_> {
type Client = Http3Client;

fn handle(&mut self, client: &mut Http3Client) -> Res<bool> {
Expand Down Expand Up @@ -286,7 +286,7 @@ impl StreamHandlerType {
) -> Box<dyn StreamHandler> {
match handler_type {
Self::Download => {
let out_file = get_output_file(url, &args.output_dir, all_paths);
let out_file = get_output_file(url, args.output_dir.as_ref(), all_paths);
client.stream_close_send(client_stream_id).unwrap();
Box::new(DownloadStreamHandler { out_file })
}
Expand Down Expand Up @@ -406,7 +406,7 @@ struct UrlHandler<'a> {
args: &'a Args,
}

impl<'a> UrlHandler<'a> {
impl UrlHandler<'_> {
fn stream_handler(&mut self, stream_id: StreamId) -> Option<&mut Box<dyn StreamHandler>> {
self.stream_handlers.get_mut(&stream_id)
}
Expand Down
4 changes: 2 additions & 2 deletions neqo-bin/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ impl Args {

fn get_output_file(
url: &Url,
output_dir: &Option<PathBuf>,
output_dir: Option<&PathBuf>,
all_paths: &mut Vec<PathBuf>,
) -> Option<BufWriter<File>> {
if let Some(ref dir) = output_dir {
if let Some(dir) = output_dir {
let mut out_path = dir.clone();

let url_path = if url.path() == "/" {
Expand Down
14 changes: 11 additions & 3 deletions neqo-bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl Default for QuicParameters {
}

impl QuicParameters {
fn get_sock_addr<F>(opt: &Option<String>, v: &str, f: F) -> Option<SocketAddr>
fn get_sock_addr<F>(opt: Option<&String>, v: &str, f: F) -> Option<SocketAddr>
where
F: FnMut(&SocketAddr) -> bool,
{
Expand All @@ -176,12 +176,20 @@ impl QuicParameters {

#[must_use]
pub fn preferred_address_v4(&self) -> Option<SocketAddr> {
Self::get_sock_addr(&self.preferred_address_v4, "IPv4", SocketAddr::is_ipv4)
Self::get_sock_addr(
self.preferred_address_v4.as_ref(),
"IPv4",
SocketAddr::is_ipv4,
)
}

#[must_use]
pub fn preferred_address_v6(&self) -> Option<SocketAddr> {
Self::get_sock_addr(&self.preferred_address_v6, "IPv6", SocketAddr::is_ipv6)
Self::get_sock_addr(
self.preferred_address_v6.as_ref(),
"IPv6",
SocketAddr::is_ipv6,
)
}

#[must_use]
Expand Down
4 changes: 2 additions & 2 deletions neqo-common/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl<'a> AsRef<[u8]> for Decoder<'a> {
}
}

impl<'a> Debug for Decoder<'a> {
impl Debug for Decoder<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(&hex_with_len(self.as_ref()))
}
Expand All @@ -186,7 +186,7 @@ where
}
}

impl<'a, 'b> PartialEq<Decoder<'b>> for Decoder<'a> {
impl<'b> PartialEq<Decoder<'b>> for Decoder<'_> {
#[must_use]
fn eq(&self, other: &Decoder<'b>) -> bool {
self.buf == other.buf
Expand Down
2 changes: 1 addition & 1 deletion neqo-common/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ where
}
}

impl<'a, P, E> Iterator for Iter<'a, P, E>
impl<P, E> Iterator for Iter<'_, P, E>
where
P: Provider<Event = E>,
{
Expand Down
2 changes: 1 addition & 1 deletion neqo-crypto/src/agentio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub struct AgentIoInputContext<'a> {
input: &'a mut AgentIoInput,
}

impl<'a> Drop for AgentIoInputContext<'a> {
impl Drop for AgentIoInputContext<'_> {
fn drop(&mut self) {
self.input.reset();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,15 @@ impl WtTest {
e: &Http3ClientEvent,
id: StreamId,
expected_reason: &SessionCloseReason,
expected_headers: &Option<Vec<Header>>,
expected_headers: Option<&Vec<Header>>,
) -> bool {
if let Http3ClientEvent::WebTransport(WebTransportEvent::SessionClosed {
stream_id,
reason,
headers,
}) = e
{
*stream_id == id && reason == expected_reason && headers == expected_headers
*stream_id == id && reason == expected_reason && headers.as_ref() == expected_headers
} else {
false
}
Expand All @@ -239,7 +239,7 @@ impl WtTest {
&mut self,
wt_session_id: StreamId,
expected_reason: &SessionCloseReason,
expected_headers: &Option<Vec<Header>>,
expected_headers: Option<&Vec<Header>>,
) {
let mut event_found = false;

Expand Down Expand Up @@ -404,7 +404,7 @@ impl WtTest {
expected_stop_sending_ids: &[StreamId],
expected_error_stream_stop_sending: Option<u64>,
expected_local: bool,
expected_session_close: &Option<(StreamId, SessionCloseReason)>,
expected_session_close: Option<&(StreamId, SessionCloseReason)>,
) {
let mut reset_ids_count = 0;
let mut stop_sending_ids_count = 0;
Expand Down Expand Up @@ -546,7 +546,7 @@ impl WtTest {
expected_error_stream_reset: Option<u64>,
expected_stop_sending_ids: &[StreamId],
expected_error_stream_stop_sending: Option<u64>,
expected_session_close: &Option<(StreamId, SessionCloseReason)>,
expected_session_close: Option<&(StreamId, SessionCloseReason)>,
) {
let mut reset_ids_count = 0;
let mut stop_sending_ids_count = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn wt_session_reject() {
wt.check_session_closed_event_client(
wt_session_id,
&SessionCloseReason::Status(404),
&Some(headers),
Some(&headers),
);
}

Expand All @@ -64,7 +64,7 @@ fn wt_session_close_server() {
wt.check_session_closed_event_client(
wt_session.stream_id(),
&SessionCloseReason::Error(Error::HttpNoError.code()),
&None,
None,
);
}

Expand All @@ -81,7 +81,7 @@ fn wt_session_close_server_close_send() {
error: 0,
message: String::new(),
},
&None,
None,
);
}

Expand All @@ -97,7 +97,7 @@ fn wt_session_close_server_stop_sending() {
wt.check_session_closed_event_client(
wt_session.stream_id(),
&SessionCloseReason::Error(Error::HttpNoError.code()),
&None,
None,
);
}

Expand All @@ -113,7 +113,7 @@ fn wt_session_close_server_reset() {
wt.check_session_closed_event_client(
wt_session.stream_id(),
&SessionCloseReason::Error(Error::HttpNoError.code()),
&None,
None,
);
}

Expand Down Expand Up @@ -189,7 +189,7 @@ fn wt_session_response_with_redirect() {
wt.check_session_closed_event_client(
wt_session_id,
&SessionCloseReason::Status(302),
&Some(headers),
Some(&headers),
);
}

Expand Down Expand Up @@ -284,7 +284,7 @@ fn wt_session_close_frame_server() {
error: ERROR_NUM,
message: ERROR_MESSAGE.to_string(),
},
&None,
None,
);
}

Expand Down Expand Up @@ -321,14 +321,14 @@ fn wt_unknown_session_frame_client() {
&[],
None,
false,
&None,
None,
);
wt.check_events_after_closing_session_server(
&[],
None,
&[unidi_server.stream_id()],
Some(Error::HttpRequestCancelled.code()),
&Some((
Some(&(
wt_session.stream_id(),
SessionCloseReason::Clean {
error: ERROR_NUM,
Expand Down Expand Up @@ -360,7 +360,7 @@ fn wt_close_session_frame_broken_client() {
wt.check_session_closed_event_client(
wt_session.stream_id(),
&SessionCloseReason::Error(Error::HttpGeneralProtocolStream.code()),
&None,
None,
);
wt.check_session_closed_event_server(
&wt_session,
Expand Down Expand Up @@ -444,13 +444,13 @@ fn wt_close_session_cannot_be_sent_at_once() {
&[unidi_client],
Some(Error::HttpRequestCancelled.code()),
false,
&Some((
Some(&(
wt_session.stream_id(),
SessionCloseReason::Clean {
error: ERROR_NUM,
message: ERROR_MESSAGE.to_string(),
},
)),
);
wt.check_events_after_closing_session_server(&[], None, &[], None, &None);
wt.check_events_after_closing_session_server(&[], None, &[], None, None);
}
Loading

0 comments on commit d6cc30e

Please sign in to comment.