From f3e9793ba21079b1f1a53075be64dd1c421df7b0 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Wed, 8 Jan 2025 09:51:18 +0100 Subject: [PATCH 01/18] fix(qpack): make `can_evict_to` iter all evictable entries (#2307) * Typos * Add unit tests for underflow and false positive * fix(qpack): have can_evict_to iter all evictable entries Previously we had `evict_to` and `can_evict_to`, where the former would actually evict values, whereas the latter would only check how much could be evicted. Both would delegate to `evict_to_internal`. In the case of `evict_to`, `evict_to_internal` would look at the last entry, and evict it if possible, then repeat. In the case of `can_evict_to`, `evict_to_internal` would look at the last value as well, and then repeat, but not actualy evict, thus continuously looking at the last entry, instead of all evictable entries. This commit fixes `can_evict_to` by making it look at all evictable entries. * Update neqo-qpack/src/table.rs Co-authored-by: Lars Eggert Signed-off-by: Max Inden --------- Signed-off-by: Max Inden Co-authored-by: Lars Eggert --- neqo-qpack/src/encoder.rs | 2 +- neqo-qpack/src/table.rs | 90 ++++++++++++++++++++++++++++++--------- 2 files changed, 72 insertions(+), 20 deletions(-) diff --git a/neqo-qpack/src/encoder.rs b/neqo-qpack/src/encoder.rs index 5ca8e71c4e..d791b57165 100644 --- a/neqo-qpack/src/encoder.rs +++ b/neqo-qpack/src/encoder.rs @@ -290,7 +290,7 @@ impl QPackEncoder { stream_id: StreamId, ) -> Res<()> { if let Some(cap) = self.next_capacity { - // Check if it is possible to reduce the capacity, e.g. if enough space can be make free + // Check if it is possible to reduce the capacity, e.g. if enough space can be made free // for the reduction. if cap < self.table.capacity() && !self.table.can_evict_to(cap) { return Err(Error::DynamicTableFull); diff --git a/neqo-qpack/src/table.rs b/neqo-qpack/src/table.rs index 8c8b8d5eaf..94c3be2d32 100644 --- a/neqo-qpack/src/table.rs +++ b/neqo-qpack/src/table.rs @@ -73,7 +73,7 @@ pub struct HeaderTable { /// The total number of inserts thus far. base: u64, /// This is number of inserts that are acked. this correspond to index of the first not acked. - /// This is only used by thee encoder. + /// This is only used by the encoder. acked_inserts_cnt: u64, } @@ -112,9 +112,9 @@ impl HeaderTable { /// /// # Errors /// - /// `ChangeCapacity` if table capacity cannot be reduced. - /// The table cannot be reduce if there are entries that are referred at the moment or their - /// inserts are unacked. + /// [`Error::ChangeCapacity`] if table capacity cannot be reduced. + /// The table cannot be reduced if there are entries that are referred to at + /// the moment, or whose inserts are unacked. pub fn set_capacity(&mut self, cap: u64) -> Res<()> { qtrace!([self], "set capacity to {}", cap); if !self.evict_to(cap) { @@ -253,20 +253,11 @@ impl HeaderTable { } fn evict_to(&mut self, reduce: u64) -> bool { - self.evict_to_internal(reduce, false) - } - - pub fn can_evict_to(&mut self, reduce: u64) -> bool { - self.evict_to_internal(reduce, true) - } - - pub fn evict_to_internal(&mut self, reduce: u64, only_check: bool) -> bool { qtrace!( [self], - "reduce table to {}, currently used:{} only_check:{}", + "reduce table to {}, currently used:{}", reduce, self.used, - only_check ); let mut used = self.used; while (!self.dynamic.is_empty()) && used > reduce { @@ -275,16 +266,26 @@ impl HeaderTable { return false; } used -= u64::try_from(e.size()).unwrap(); - if !only_check { - self.used -= u64::try_from(e.size()).unwrap(); - self.dynamic.pop_back(); - } + self.used -= u64::try_from(e.size()).unwrap(); + self.dynamic.pop_back(); } } true } - pub fn insert_possible(&mut self, size: usize) -> bool { + pub fn can_evict_to(&self, reduce: u64) -> bool { + let evictable_size: usize = self + .dynamic + .iter() + .rev() + .take_while(|e| e.can_reduce(self.acked_inserts_cnt)) + .map(DynamicTableEntry::size) + .sum(); + + self.used - u64::try_from(evictable_size).unwrap() <= reduce + } + + pub fn insert_possible(&self, size: usize) -> bool { u64::try_from(size).unwrap() <= self.capacity && self.can_evict_to(self.capacity - u64::try_from(size).unwrap()) } @@ -389,3 +390,54 @@ impl HeaderTable { self.acked_inserts_cnt } } + +#[cfg(test)] +mod tests { + use super::*; + + /// Due to a bug in [`HeaderTable::can_evict_to`], the function would + /// continuously subtract the size of the last entry instead of the size of + /// each entry starting from the back. + /// + /// See for details. + mod issue_2306 { + use super::*; + + const VALUE: &[u8; 2] = b"42"; + + /// Given two entries where the first is smaller than the second, + /// subtracting the size of the second from the overall size twice leads + /// to an underflow. + #[test] + fn can_evict_to_no_underflow() { + let mut table = HeaderTable::new(true); + table.set_capacity(10000).unwrap(); + + table.insert(b"header1", VALUE).unwrap(); + table.insert(b"larger-header1", VALUE).unwrap(); + + table.increment_acked(2).unwrap(); + + assert!(table.can_evict_to(0)); + } + + /// Given two entries where only the first is acked, continuously + /// subtracting the size of the last entry would give a false-positive + /// on whether both entries can be evicted. + #[test] + fn can_evict_to_false() { + let mut table = HeaderTable::new(true); + table.set_capacity(10000).unwrap(); + + table.insert(b"header1", VALUE).unwrap(); + table.insert(b"header2", VALUE).unwrap(); + + table.increment_acked(1).unwrap(); + + let first_entry_size = table.get_dynamic_with_abs_index(0).unwrap().size() as u64; + + assert!(table.can_evict_to(first_entry_size)); + assert!(!table.can_evict_to(0)); + } + } +} From b53ecd335629dbc4a9edb51e88dad8a3c04e3070 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Wed, 8 Jan 2025 13:05:39 +0200 Subject: [PATCH 02/18] chore: Enable clippy `get_unwrap` lint (#2318) And deal with the warnings. --- Cargo.toml | 2 +- neqo-bin/src/server/mod.rs | 2 +- neqo-transport/src/recv_stream.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 705fd79e63..f71d183613 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ url = { version = "2.5.3", default-features = false, features = ["std"] } cargo = { level = "warn", priority = -1 } nursery = { level = "warn", priority = -1 } pedantic = { level = "warn", priority = -1 } -multiple_crate_versions = "allow" +get_unwrap = "warn" # Optimize build dependencies, because bindgen and proc macros / style # compilation take more to run than to build otherwise. diff --git a/neqo-bin/src/server/mod.rs b/neqo-bin/src/server/mod.rs index 1b6384df0d..2dd05a3daf 100644 --- a/neqo-bin/src/server/mod.rs +++ b/neqo-bin/src/server/mod.rs @@ -263,7 +263,7 @@ impl ServerRunner { async fn read_and_process(&mut self, sockets_index: usize) -> Result<(), io::Error> { loop { - let (host, socket) = self.sockets.get_mut(sockets_index).unwrap(); + let (host, socket) = &mut self.sockets[sockets_index]; let Some(input_dgrams) = socket.recv(*host, &mut self.recv_buf)? else { break; }; diff --git a/neqo-transport/src/recv_stream.rs b/neqo-transport/src/recv_stream.rs index e3b417bfbc..1d6f03a8ce 100644 --- a/neqo-transport/src/recv_stream.rs +++ b/neqo-transport/src/recv_stream.rs @@ -1169,7 +1169,7 @@ mod tests { // Add a chunk s.inbound_frame(0, &[0; 150]); - assert_eq!(s.data_ranges.get(&0).unwrap().len(), 150); + assert_eq!(s.data_ranges[&0].len(), 150); // Read, providing only enough space for the first 100. let mut buf = [0; 100]; let count = s.read(&mut buf[..]); @@ -1180,7 +1180,7 @@ mod tests { // This shouldn't truncate the first frame, as we're already // Reading from it. s.inbound_frame(120, &[0; 60]); - assert_eq!(s.data_ranges.get(&0).unwrap().len(), 180); + assert_eq!(s.data_ranges[&0].len(), 180); // Read second part of first frame and all of the second frame let count = s.read(&mut buf[..]); assert_eq!(count, 80); From b17233ccd30aa265baaeafdedb2d6755a99d51a1 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Wed, 8 Jan 2025 14:40:43 +0200 Subject: [PATCH 03/18] chore: Enable clippy `if_then_some_else_none` lint (#2319) And apply suggestions. Signed-off-by: Lars Eggert --- Cargo.toml | 1 + neqo-common/src/incrdecoder.rs | 18 +++--------------- neqo-crypto/tests/handshake.rs | 8 +++----- neqo-http3/src/connection_client.rs | 8 +------- neqo-qpack/src/decoder.rs | 4 ++-- neqo-transport/src/connection/mod.rs | 8 +++----- neqo-transport/src/connection/state.rs | 8 +++----- neqo-transport/src/fc.rs | 8 +++----- neqo-transport/src/frame.rs | 8 +++----- neqo-transport/src/path.rs | 18 +++--------------- neqo-transport/src/qlog.rs | 6 +----- neqo-transport/src/recovery/mod.rs | 16 ++++++---------- neqo-transport/src/recv_stream.rs | 10 ++++------ neqo-transport/src/send_stream.rs | 8 +++----- neqo-transport/src/sender.rs | 6 +----- test-fixture/src/lib.rs | 6 +----- 16 files changed, 41 insertions(+), 100 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f71d183613..414c831e90 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,6 +42,7 @@ url = { version = "2.5.3", default-features = false, features = ["std"] } cargo = { level = "warn", priority = -1 } nursery = { level = "warn", priority = -1 } pedantic = { level = "warn", priority = -1 } +if_then_some_else_none = "warn" get_unwrap = "warn" # Optimize build dependencies, because bindgen and proc macros / style diff --git a/neqo-common/src/incrdecoder.rs b/neqo-common/src/incrdecoder.rs index 340e0ec5e4..f094d25f1c 100644 --- a/neqo-common/src/incrdecoder.rs +++ b/neqo-common/src/incrdecoder.rs @@ -33,11 +33,7 @@ impl IncrementalDecoderUint { } self.v |= dv.decode_n(amount).unwrap(); *r -= amount; - if *r == 0 { - Some(self.v) - } else { - None - } + (*r == 0).then_some(self.v) } else { let (v, remaining) = dv.decode_uint::().map_or_else( || unreachable!(), @@ -56,11 +52,7 @@ impl IncrementalDecoderUint { ); self.remaining = Some(remaining); self.v = v; - if remaining == 0 { - Some(v) - } else { - None - } + (remaining == 0).then_some(v) } } @@ -100,11 +92,7 @@ impl IncrementalDecoderBuffer { let b = dv.decode(amount).unwrap(); self.v.extend_from_slice(b); self.remaining -= amount; - if self.remaining == 0 { - Some(mem::take(&mut self.v)) - } else { - None - } + (self.remaining == 0).then(|| mem::take(&mut self.v)) } } diff --git a/neqo-crypto/tests/handshake.rs b/neqo-crypto/tests/handshake.rs index 799ccba34e..820c5235aa 100644 --- a/neqo-crypto/tests/handshake.rs +++ b/neqo-crypto/tests/handshake.rs @@ -116,7 +116,7 @@ impl ZeroRttChecker for PermissiveZeroRttChecker { } fn zero_rtt_setup(mode: Resumption, client: &Client, server: &mut Server) -> Option { - if matches!(mode, Resumption::WithZeroRtt) { + matches!(mode, Resumption::WithZeroRtt).then(|| { client.enable_0rtt().expect("should enable 0-RTT on client"); let anti_replay = anti_replay(); @@ -127,10 +127,8 @@ fn zero_rtt_setup(mode: Resumption, client: &Client, server: &mut Server) -> Opt Box::new(PermissiveZeroRttChecker { resuming: false }), ) .expect("should enable 0-RTT on server"); - Some(anti_replay) - } else { - None - } + anti_replay + }) } #[allow(clippy::missing_panics_doc)] diff --git a/neqo-http3/src/connection_client.rs b/neqo-http3/src/connection_client.rs index f23abee831..b9f7db52a4 100644 --- a/neqo-http3/src/connection_client.rs +++ b/neqo-http3/src/connection_client.rs @@ -43,13 +43,7 @@ fn id_gte(base: StreamId) -> impl FnMut((&StreamId, &U)) -> Option where U: ?Sized, { - move |(id, _)| { - if *id >= base && !(id.is_bidi() ^ base.is_bidi()) { - Some(*id) - } else { - None - } - } + move |(id, _)| (*id >= base && !(id.is_bidi() ^ base.is_bidi())).then_some(*id) } const fn alpn_from_quic_version(version: Version) -> &'static str { diff --git a/neqo-qpack/src/decoder.rs b/neqo-qpack/src/decoder.rs index ed1d0b8a18..0a72e3ee7f 100644 --- a/neqo-qpack/src/decoder.rs +++ b/neqo-qpack/src/decoder.rs @@ -93,7 +93,7 @@ impl QPackDecoder { let r = self .blocked_streams .iter() - .filter_map(|(id, req)| if *req <= base_new { Some(*id) } else { None }) + .filter_map(|(id, req)| (*req <= base_new).then_some(*id)) .collect::>(); self.blocked_streams.retain(|(_, req)| *req > base_new); Ok(r) @@ -225,7 +225,7 @@ impl QPackDecoder { let r = self .blocked_streams .iter() - .filter_map(|(id, req)| if *id == stream_id { Some(*req) } else { None }) + .filter_map(|(id, req)| (*id == stream_id).then_some(*req)) .collect::>(); if !r.is_empty() { debug_assert!(r.len() == 1); diff --git a/neqo-transport/src/connection/mod.rs b/neqo-transport/src/connection/mod.rs index 9cbb9ce7e0..81ede422c5 100644 --- a/neqo-transport/src/connection/mod.rs +++ b/neqo-transport/src/connection/mod.rs @@ -699,15 +699,13 @@ impl Connection { pub fn take_resumption_token(&mut self, now: Instant) -> Option { assert_eq!(self.role, Role::Client); - if self.crypto.has_resumption_token() { + self.crypto.has_resumption_token().then(|| { let token = self.make_resumption_token(); if self.crypto.has_resumption_token() { self.release_resumption_token_timer = Some(now + 3 * self.pto()); } - Some(token) - } else { - None - } + token + }) } /// Enable resumption, using a token previously provided. diff --git a/neqo-transport/src/connection/state.rs b/neqo-transport/src/connection/state.rs index d5193b7942..2404f8d377 100644 --- a/neqo-transport/src/connection/state.rs +++ b/neqo-transport/src/connection/state.rs @@ -222,13 +222,11 @@ impl StateSignaling { } pub fn write_done(&mut self, builder: &mut PacketBuilder) -> Option { - if matches!(self, Self::HandshakeDone) && builder.remaining() >= 1 { + (matches!(self, Self::HandshakeDone) && builder.remaining() >= 1).then(|| { *self = Self::Idle; builder.encode_varint(FRAME_TYPE_HANDSHAKE_DONE); - Some(RecoveryToken::HandshakeDone) - } else { - None - } + RecoveryToken::HandshakeDone + }) } pub fn close( diff --git a/neqo-transport/src/fc.rs b/neqo-transport/src/fc.rs index acc4d6582d..80fb5fbe13 100644 --- a/neqo-transport/src/fc.rs +++ b/neqo-transport/src/fc.rs @@ -68,13 +68,11 @@ where /// control if the change was an increase and `None` otherwise. pub fn update(&mut self, limit: u64) -> Option { debug_assert!(limit < u64::MAX); - if limit > self.limit { + (limit > self.limit).then(|| { self.limit = limit; self.blocked_frame = false; - Some(self.available()) - } else { - None - } + self.available() + }) } /// Consume flow control. diff --git a/neqo-transport/src/frame.rs b/neqo-transport/src/frame.rs index c858c41b5c..4b718d5676 100644 --- a/neqo-transport/src/frame.rs +++ b/neqo-transport/src/frame.rs @@ -451,11 +451,9 @@ impl<'a> Frame<'a> { } // Now check for the values for ACK_ECN. - let ecn_count = if ecn { - Some(EcnCount::new(0, dv(dec)?, dv(dec)?, dv(dec)?)) - } else { - None - }; + let ecn_count = ecn + .then(|| -> Res { Ok(EcnCount::new(0, dv(dec)?, dv(dec)?, dv(dec)?)) }) + .transpose()?; Ok(Frame::Ack { largest_acknowledged: la, diff --git a/neqo-transport/src/path.rs b/neqo-transport/src/path.rs index c6fe207375..d2e6371c72 100644 --- a/neqo-transport/src/path.rs +++ b/neqo-transport/src/path.rs @@ -85,13 +85,7 @@ impl Paths { ) -> PathRef { self.paths .iter() - .find_map(|p| { - if p.borrow().received_on(local, remote) { - Some(Rc::clone(p)) - } else { - None - } - }) + .find_map(|p| p.borrow().received_on(local, remote).then(|| Rc::clone(p))) .unwrap_or_else(|| { let mut p = Path::temporary(local, remote, cc, pacing, self.qlog.clone(), now, stats); @@ -178,7 +172,7 @@ impl Paths { .paths .iter() .enumerate() - .find_map(|(i, p)| if Rc::ptr_eq(p, path) { Some(i) } else { None }) + .find_map(|(i, p)| Rc::ptr_eq(p, path).then_some(i)) .expect("migration target should be permanent"); self.paths.swap(0, idx); @@ -306,13 +300,7 @@ impl Paths { pub fn select_path(&self) -> Option { self.paths .iter() - .find_map(|p| { - if p.borrow().has_probe() { - Some(Rc::clone(p)) - } else { - None - } - }) + .find_map(|p| p.borrow().has_probe().then(|| Rc::clone(p))) .or_else(|| self.primary.clone()) } diff --git a/neqo-transport/src/qlog.rs b/neqo-transport/src/qlog.rs index 07a7db1846..153d8d983a 100644 --- a/neqo-transport/src/qlog.rs +++ b/neqo-transport/src/qlog.rs @@ -50,11 +50,7 @@ pub fn connection_tparams_set(qlog: &NeqoQlog, tph: &TransportParametersHandler, initial_source_connection_id: None, retry_source_connection_id: None, stateless_reset_token: remote.get_bytes(tparams::STATELESS_RESET_TOKEN).map(hex), - disable_active_migration: if remote.get_empty(tparams::DISABLE_MIGRATION) { - Some(true) - } else { - None - }, + disable_active_migration: remote.get_empty(tparams::DISABLE_MIGRATION).then_some(true), max_idle_timeout: Some(remote.get_integer(tparams::IDLE_TIMEOUT)), max_udp_payload_size: Some(remote.get_integer(tparams::MAX_UDP_PAYLOAD_SIZE) as u32), ack_delay_exponent: Some(remote.get_integer(tparams::ACK_DELAY_EXPONENT) as u16), diff --git a/neqo-transport/src/recovery/mod.rs b/neqo-transport/src/recovery/mod.rs index 4879750a70..cd55e20e9a 100644 --- a/neqo-transport/src/recovery/mod.rs +++ b/neqo-transport/src/recovery/mod.rs @@ -181,12 +181,10 @@ impl LossRecoverySpace { self.sent_packets .iter_mut() .filter_map(|sent| { - if sent.pto() { + sent.pto().then(|| { qtrace!("PTO: marking packet {} lost ", sent.pn()); - Some(&*sent) - } else { - None - } + &*sent + }) }) .take(count) } @@ -477,13 +475,11 @@ impl PtoState { /// Generate a sending profile, indicating what space it should be from. /// This takes a packet from the supply if one remains, or returns `None`. pub fn send_profile(&mut self, mtu: usize) -> Option { - if self.packets > 0 { + (self.packets > 0).then(|| { // This is a PTO, so ignore the limit. self.packets -= 1; - Some(SendProfile::new_pto(self.space, mtu, self.probe)) - } else { - None - } + SendProfile::new_pto(self.space, mtu, self.probe) + }) } } diff --git a/neqo-transport/src/recv_stream.rs b/neqo-transport/src/recv_stream.rs index 1d6f03a8ce..a57c2bf6d0 100644 --- a/neqo-transport/src/recv_stream.rs +++ b/neqo-transport/src/recv_stream.rs @@ -70,15 +70,13 @@ impl RecvStreams { pub fn keep_alive(&mut self, id: StreamId, k: bool) -> Res<()> { let self_ka = &mut self.keep_alive; let s = self.streams.get_mut(&id).ok_or(Error::InvalidStreamId)?; - s.keep_alive = if k { - Some(self_ka.upgrade().unwrap_or_else(|| { + s.keep_alive = k.then(|| { + self_ka.upgrade().unwrap_or_else(|| { let r = Rc::new(()); *self_ka = Rc::downgrade(&r); r - })) - } else { - None - }; + }) + }); Ok(()) } diff --git a/neqo-transport/src/send_stream.rs b/neqo-transport/src/send_stream.rs index e05a0efa3f..a266da9d78 100644 --- a/neqo-transport/src/send_stream.rs +++ b/neqo-transport/src/send_stream.rs @@ -882,15 +882,13 @@ impl SendStream { "next_bytes apply retransmission limit at {}", self.retransmission_offset ); - if self.retransmission_offset > offset { + (self.retransmission_offset > offset).then(|| { let len = min( usize::try_from(self.retransmission_offset - offset).unwrap(), slice.len(), ); - Some((offset, &slice[..len])) - } else { - None - } + (offset, &slice[..len]) + }) } else { Some((offset, slice)) } diff --git a/neqo-transport/src/sender.rs b/neqo-transport/src/sender.rs index f2f8bcb3ce..ab60be80bb 100644 --- a/neqo-transport/src/sender.rs +++ b/neqo-transport/src/sender.rs @@ -161,11 +161,7 @@ impl PacketSender { #[must_use] pub fn next_paced(&self, rtt: Duration) -> Option { // Only pace if there are bytes in flight. - if self.cc.bytes_in_flight() > 0 { - Some(self.pacer.next(rtt, self.cc.cwnd())) - } else { - None - } + (self.cc.bytes_in_flight() > 0).then(|| self.pacer.next(rtt, self.cc.cwnd())) } #[must_use] diff --git a/test-fixture/src/lib.rs b/test-fixture/src/lib.rs index e58e32f37a..b9e869c5b3 100644 --- a/test-fixture/src/lib.rs +++ b/test-fixture/src/lib.rs @@ -344,11 +344,7 @@ fn split_packet(buf: &[u8]) -> (&[u8], Option<&[u8]>) { } dec.skip_vvec(); // The rest of the packet. let p1 = &buf[..dec.offset()]; - let p2 = if dec.remaining() > 0 { - Some(dec.decode_remainder()) - } else { - None - }; + let p2 = (dec.remaining() > 0).then(|| dec.decode_remainder()); qtrace!("split packet: {} {:?}", hex(p1), p2.map(hex)); (p1, p2) } From 808b01831902a8fad4576518f5c0f2e05fbe9680 Mon Sep 17 00:00:00 2001 From: Oskar Mansfeld <113997378+mansf-osk@users.noreply.github.com> Date: Wed, 8 Jan 2025 17:18:31 +0100 Subject: [PATCH 04/18] chore(transport): Remove `module_name_repetitions` (#2311) * chore(transport): remove `module_name_repetitions` in ECN module * chore(transport): moved `module_name_repetition` allow's to module level * chore(transport): added `ecn::` prefixes * chore(transport): remove `ECN_` prefix from constants * chore: fixed formatting --------- Signed-off-by: Oskar Mansfeld <113997378+mansf-osk@users.noreply.github.com> --- neqo-transport/src/connection/mod.rs | 6 +- neqo-transport/src/connection/tests/ecn.rs | 52 +++++----- neqo-transport/src/crypto.rs | 2 + neqo-transport/src/ecn.rs | 106 ++++++++++----------- neqo-transport/src/frame.rs | 12 ++- neqo-transport/src/lib.rs | 2 - neqo-transport/src/packet/mod.rs | 2 + neqo-transport/src/path.rs | 16 ++-- neqo-transport/src/qlog.rs | 2 + neqo-transport/src/recovery/mod.rs | 10 +- neqo-transport/src/recv_stream.rs | 2 + neqo-transport/src/rtt.rs | 2 + neqo-transport/src/send_stream.rs | 2 + neqo-transport/src/stats.rs | 11 +-- neqo-transport/src/tracking.rs | 8 +- neqo-transport/src/version.rs | 2 + 16 files changed, 126 insertions(+), 111 deletions(-) diff --git a/neqo-transport/src/connection/mod.rs b/neqo-transport/src/connection/mod.rs index 81ede422c5..8ef0ad8e55 100644 --- a/neqo-transport/src/connection/mod.rs +++ b/neqo-transport/src/connection/mod.rs @@ -6,6 +6,8 @@ // The class implementing a QUIC connection. +#![allow(clippy::module_name_repetitions)] + use std::{ cell::RefCell, cmp::{max, min}, @@ -36,7 +38,7 @@ use crate::{ ConnectionIdRef, ConnectionIdStore, LOCAL_ACTIVE_CID_LIMIT, }, crypto::{Crypto, CryptoDxState, CryptoSpace}, - ecn::EcnCount, + ecn, events::{ConnectionEvent, ConnectionEvents, OutgoingDatagramOutcome}, frame::{ CloseError, Frame, FrameType, FRAME_TYPE_CONNECTION_CLOSE_APPLICATION, @@ -3132,7 +3134,7 @@ impl Connection { &mut self, space: PacketNumberSpace, ack_ranges: R, - ack_ecn: Option, + ack_ecn: Option, ack_delay: u64, now: Instant, ) where diff --git a/neqo-transport/src/connection/tests/ecn.rs b/neqo-transport/src/connection/tests/ecn.rs index c4ba07547b..92321bf09e 100644 --- a/neqo-transport/src/connection/tests/ecn.rs +++ b/neqo-transport/src/connection/tests/ecn.rs @@ -19,7 +19,7 @@ use crate::{ new_server, send_and_receive, send_something, send_something_with_modifier, send_with_modifier_and_receive, DEFAULT_RTT, }, - ecn::{EcnValidationOutcome, ECN_TEST_COUNT}, + ecn, path::MAX_PATH_PROBES, ConnectionId, ConnectionParameters, StreamType, }; @@ -143,12 +143,12 @@ fn stats() { let mut server = default_server(); connect_force_idle(&mut client, &mut server); - for _ in 0..ECN_TEST_COUNT { + for _ in 0..ecn::TEST_COUNT { let ack = send_and_receive(&mut client, &mut server, now); client.process_input(ack.unwrap(), now); } - for _ in 0..ECN_TEST_COUNT { + for _ in 0..ecn::TEST_COUNT { let ack = send_and_receive(&mut server, &mut client, now); server.process_input(ack.unwrap(), now); } @@ -156,8 +156,8 @@ fn stats() { for stats in [client.stats(), server.stats()] { for (outcome, count) in stats.ecn_path_validation.iter() { match outcome { - EcnValidationOutcome::Capable => assert_eq!(*count, 1), - EcnValidationOutcome::NotCapable(_) => assert_eq!(*count, 0), + ecn::ValidationOutcome::Capable => assert_eq!(*count, 1), + ecn::ValidationOutcome::NotCapable(_) => assert_eq!(*count, 0), } } @@ -182,7 +182,7 @@ fn disables_on_loss() { let client_pkt = send_something(&mut client, now); assert_ecn_enabled(client_pkt.tos()); - for _ in 0..ECN_TEST_COUNT { + for _ in 0..ecn::TEST_COUNT { send_something(&mut client, now); } @@ -198,7 +198,7 @@ fn disables_on_remark() { let mut server = default_server(); connect_force_idle(&mut client, &mut server); - for _ in 0..ECN_TEST_COUNT { + for _ in 0..ecn::TEST_COUNT { if let Some(ack) = send_with_modifier_and_receive(&mut client, &mut server, now, remark()) { client.process_input(ack, now); } @@ -373,7 +373,7 @@ fn ecn_migration_zero_burst_all_cases() { #[test] fn ecn_migration_noop_bleach_data() { - let (before, after, migrated) = migration_with_modifiers(noop(), bleach(), ECN_TEST_COUNT); + let (before, after, migrated) = migration_with_modifiers(noop(), bleach(), ecn::TEST_COUNT); assert_ecn_enabled(before); // ECN validation concludes before migration. assert_ecn_disabled(after); // ECN validation fails after migration due to bleaching. assert!(migrated); @@ -381,7 +381,7 @@ fn ecn_migration_noop_bleach_data() { #[test] fn ecn_migration_noop_remark_data() { - let (before, after, migrated) = migration_with_modifiers(noop(), remark(), ECN_TEST_COUNT); + let (before, after, migrated) = migration_with_modifiers(noop(), remark(), ecn::TEST_COUNT); assert_ecn_enabled(before); // ECN validation concludes before migration. assert_ecn_disabled(after); // ECN validation fails after migration due to remarking. assert!(migrated); @@ -389,7 +389,7 @@ fn ecn_migration_noop_remark_data() { #[test] fn ecn_migration_noop_ce_data() { - let (before, after, migrated) = migration_with_modifiers(noop(), ce(), ECN_TEST_COUNT); + let (before, after, migrated) = migration_with_modifiers(noop(), ce(), ecn::TEST_COUNT); assert_ecn_enabled(before); // ECN validation concludes before migration. assert_ecn_enabled(after); // ECN validation concludes after migration, despite all CE marks. assert!(migrated); @@ -397,7 +397,7 @@ fn ecn_migration_noop_ce_data() { #[test] fn ecn_migration_noop_drop_data() { - let (before, after, migrated) = migration_with_modifiers(noop(), drop(), ECN_TEST_COUNT); + let (before, after, migrated) = migration_with_modifiers(noop(), drop(), ecn::TEST_COUNT); assert_ecn_enabled(before); // ECN validation concludes before migration. assert_ecn_enabled(after); // Migration failed, ECN on original path is still validated. assert!(!migrated); @@ -405,7 +405,7 @@ fn ecn_migration_noop_drop_data() { #[test] fn ecn_migration_bleach_noop_data() { - let (before, after, migrated) = migration_with_modifiers(bleach(), noop(), ECN_TEST_COUNT); + let (before, after, migrated) = migration_with_modifiers(bleach(), noop(), ecn::TEST_COUNT); assert_ecn_disabled(before); // ECN validation fails before migration due to bleaching. assert_ecn_enabled(after); // ECN validation concludes after migration. assert!(migrated); @@ -413,7 +413,7 @@ fn ecn_migration_bleach_noop_data() { #[test] fn ecn_migration_bleach_bleach_data() { - let (before, after, migrated) = migration_with_modifiers(bleach(), bleach(), ECN_TEST_COUNT); + let (before, after, migrated) = migration_with_modifiers(bleach(), bleach(), ecn::TEST_COUNT); assert_ecn_disabled(before); // ECN validation fails before migration due to bleaching. assert_ecn_disabled(after); // ECN validation fails after migration due to bleaching. assert!(migrated); @@ -421,7 +421,7 @@ fn ecn_migration_bleach_bleach_data() { #[test] fn ecn_migration_bleach_remark_data() { - let (before, after, migrated) = migration_with_modifiers(bleach(), remark(), ECN_TEST_COUNT); + let (before, after, migrated) = migration_with_modifiers(bleach(), remark(), ecn::TEST_COUNT); assert_ecn_disabled(before); // ECN validation fails before migration due to bleaching. assert_ecn_disabled(after); // ECN validation fails after migration due to remarking. assert!(migrated); @@ -429,7 +429,7 @@ fn ecn_migration_bleach_remark_data() { #[test] fn ecn_migration_bleach_ce_data() { - let (before, after, migrated) = migration_with_modifiers(bleach(), ce(), ECN_TEST_COUNT); + let (before, after, migrated) = migration_with_modifiers(bleach(), ce(), ecn::TEST_COUNT); assert_ecn_disabled(before); // ECN validation fails before migration due to bleaching. assert_ecn_enabled(after); // ECN validation concludes after migration, despite all CE marks. assert!(migrated); @@ -437,7 +437,7 @@ fn ecn_migration_bleach_ce_data() { #[test] fn ecn_migration_bleach_drop_data() { - let (before, after, migrated) = migration_with_modifiers(bleach(), drop(), ECN_TEST_COUNT); + let (before, after, migrated) = migration_with_modifiers(bleach(), drop(), ecn::TEST_COUNT); assert_ecn_disabled(before); // ECN validation fails before migration due to bleaching. // Migration failed, ECN on original path is still disabled. assert_ecn_disabled(after); @@ -446,7 +446,7 @@ fn ecn_migration_bleach_drop_data() { #[test] fn ecn_migration_remark_noop_data() { - let (before, after, migrated) = migration_with_modifiers(remark(), noop(), ECN_TEST_COUNT); + let (before, after, migrated) = migration_with_modifiers(remark(), noop(), ecn::TEST_COUNT); assert_ecn_disabled(before); // ECN validation fails before migration due to remarking. assert_ecn_enabled(after); // ECN validation succeeds after migration. assert!(migrated); @@ -454,7 +454,7 @@ fn ecn_migration_remark_noop_data() { #[test] fn ecn_migration_remark_bleach_data() { - let (before, after, migrated) = migration_with_modifiers(remark(), bleach(), ECN_TEST_COUNT); + let (before, after, migrated) = migration_with_modifiers(remark(), bleach(), ecn::TEST_COUNT); assert_ecn_disabled(before); // ECN validation fails before migration due to remarking. assert_ecn_disabled(after); // ECN validation fails after migration due to bleaching. assert!(migrated); @@ -462,7 +462,7 @@ fn ecn_migration_remark_bleach_data() { #[test] fn ecn_migration_remark_remark_data() { - let (before, after, migrated) = migration_with_modifiers(remark(), remark(), ECN_TEST_COUNT); + let (before, after, migrated) = migration_with_modifiers(remark(), remark(), ecn::TEST_COUNT); assert_ecn_disabled(before); // ECN validation fails before migration due to remarking. assert_ecn_disabled(after); // ECN validation fails after migration due to remarking. assert!(migrated); @@ -470,7 +470,7 @@ fn ecn_migration_remark_remark_data() { #[test] fn ecn_migration_remark_ce_data() { - let (before, after, migrated) = migration_with_modifiers(remark(), ce(), ECN_TEST_COUNT); + let (before, after, migrated) = migration_with_modifiers(remark(), ce(), ecn::TEST_COUNT); assert_ecn_disabled(before); // ECN validation fails before migration due to remarking. assert_ecn_enabled(after); // ECN validation concludes after migration, despite all CE marks. assert!(migrated); @@ -478,7 +478,7 @@ fn ecn_migration_remark_ce_data() { #[test] fn ecn_migration_remark_drop_data() { - let (before, after, migrated) = migration_with_modifiers(remark(), drop(), ECN_TEST_COUNT); + let (before, after, migrated) = migration_with_modifiers(remark(), drop(), ecn::TEST_COUNT); assert_ecn_disabled(before); // ECN validation fails before migration due to remarking. assert_ecn_disabled(after); // Migration failed, ECN on original path is still disabled. assert!(!migrated); @@ -486,7 +486,7 @@ fn ecn_migration_remark_drop_data() { #[test] fn ecn_migration_ce_noop_data() { - let (before, after, migrated) = migration_with_modifiers(ce(), noop(), ECN_TEST_COUNT); + let (before, after, migrated) = migration_with_modifiers(ce(), noop(), ecn::TEST_COUNT); assert_ecn_enabled(before); // ECN validation concludes before migration, despite all CE marks. assert_ecn_enabled(after); // ECN validation concludes after migration. assert!(migrated); @@ -494,7 +494,7 @@ fn ecn_migration_ce_noop_data() { #[test] fn ecn_migration_ce_bleach_data() { - let (before, after, migrated) = migration_with_modifiers(ce(), bleach(), ECN_TEST_COUNT); + let (before, after, migrated) = migration_with_modifiers(ce(), bleach(), ecn::TEST_COUNT); assert_ecn_enabled(before); // ECN validation concludes before migration, despite all CE marks. assert_ecn_disabled(after); // ECN validation fails after migration due to bleaching assert!(migrated); @@ -502,7 +502,7 @@ fn ecn_migration_ce_bleach_data() { #[test] fn ecn_migration_ce_remark_data() { - let (before, after, migrated) = migration_with_modifiers(ce(), remark(), ECN_TEST_COUNT); + let (before, after, migrated) = migration_with_modifiers(ce(), remark(), ecn::TEST_COUNT); assert_ecn_enabled(before); // ECN validation concludes before migration, despite all CE marks. assert_ecn_disabled(after); // ECN validation fails after migration due to remarking. assert!(migrated); @@ -510,7 +510,7 @@ fn ecn_migration_ce_remark_data() { #[test] fn ecn_migration_ce_ce_data() { - let (before, after, migrated) = migration_with_modifiers(ce(), ce(), ECN_TEST_COUNT); + let (before, after, migrated) = migration_with_modifiers(ce(), ce(), ecn::TEST_COUNT); assert_ecn_enabled(before); // ECN validation concludes before migration, despite all CE marks. assert_ecn_enabled(after); // ECN validation concludes after migration, despite all CE marks. assert!(migrated); @@ -518,7 +518,7 @@ fn ecn_migration_ce_ce_data() { #[test] fn ecn_migration_ce_drop_data() { - let (before, after, migrated) = migration_with_modifiers(ce(), drop(), ECN_TEST_COUNT); + let (before, after, migrated) = migration_with_modifiers(ce(), drop(), ecn::TEST_COUNT); assert_ecn_enabled(before); // ECN validation concludes before migration, despite all CE marks. // Migration failed, ECN on original path is still enabled. assert_ecn_enabled(after); diff --git a/neqo-transport/src/crypto.rs b/neqo-transport/src/crypto.rs index 756cdbb771..9fa8fc5d50 100644 --- a/neqo-transport/src/crypto.rs +++ b/neqo-transport/src/crypto.rs @@ -4,6 +4,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(clippy::module_name_repetitions)] + use std::{ cell::RefCell, cmp::{max, min}, diff --git a/neqo-transport/src/ecn.rs b/neqo-transport/src/ecn.rs index 944c63ac8a..2ec3285b5f 100644 --- a/neqo-transport/src/ecn.rs +++ b/neqo-transport/src/ecn.rs @@ -16,18 +16,18 @@ use crate::{ }; /// The number of packets to use for testing a path for ECN capability. -pub const ECN_TEST_COUNT: usize = 10; +pub const TEST_COUNT: usize = 10; /// The number of packets to use for testing a path for ECN capability when exchanging -/// Initials during the handshake. This is a lower number than [`ECN_TEST_COUNT`] to avoid -/// unnecessarily delaying the handshake; we would otherwise double the PTO [`ECN_TEST_COUNT`] +/// Initials during the handshake. This is a lower number than [`TEST_COUNT`] to avoid +/// unnecessarily delaying the handshake; we would otherwise double the PTO [`TEST_COUNT`] /// times. -const ECN_TEST_COUNT_INITIAL_PHASE: usize = 3; +const TEST_COUNT_INITIAL_PHASE: usize = 3; /// The state information related to testing a path for ECN capability. /// See RFC9000, Appendix A.4. #[derive(Debug, PartialEq, Clone, Copy)] -enum EcnValidationState { +enum ValidationState { /// The path is currently being tested for ECN capability, with the number of probes sent so /// far on the path during the ECN validation. Testing { @@ -37,12 +37,12 @@ enum EcnValidationState { /// The validation test has concluded but the path's ECN capability is not yet known. Unknown, /// The path is known to **not** be ECN capable. - Failed(EcnValidationError), + Failed(ValidationError), /// The path is known to be ECN capable. Capable, } -impl Default for EcnValidationState { +impl Default for ValidationState { fn default() -> Self { Self::Testing { probes_sent: 0, @@ -51,28 +51,28 @@ impl Default for EcnValidationState { } } -impl EcnValidationState { +impl ValidationState { fn set(&mut self, new: Self, stats: &mut Stats) { let old = std::mem::replace(self, new); match old { Self::Testing { .. } | Self::Unknown => {} Self::Failed(_) => debug_assert!(false, "Failed is a terminal state"), - Self::Capable => stats.ecn_path_validation[EcnValidationOutcome::Capable] -= 1, + Self::Capable => stats.ecn_path_validation[ValidationOutcome::Capable] -= 1, } match new { Self::Testing { .. } | Self::Unknown => {} Self::Failed(error) => { - stats.ecn_path_validation[EcnValidationOutcome::NotCapable(error)] += 1; + stats.ecn_path_validation[ValidationOutcome::NotCapable(error)] += 1; } - Self::Capable => stats.ecn_path_validation[EcnValidationOutcome::Capable] += 1, + Self::Capable => stats.ecn_path_validation[ValidationOutcome::Capable] += 1, } } } /// The counts for different ECN marks. /// -/// Note: [`EcnCount`] is used both for outgoing UDP datagrams, returned by +/// Note: [`Count`] is used both for outgoing UDP datagrams, returned by /// remote through QUIC ACKs and for incoming UDP datagrams, read from IP TOS /// header. In the former case, given that QUIC ACKs only carry /// [`IpTosEcn::Ect0`], [`IpTosEcn::Ect1`] and [`IpTosEcn::Ce`], but never @@ -80,9 +80,9 @@ impl EcnValidationState { /// /// See also . #[derive(PartialEq, Eq, Debug, Clone, Copy, Default)] -pub struct EcnCount(EnumMap); +pub struct Count(EnumMap); -impl Deref for EcnCount { +impl Deref for Count { type Target = EnumMap; fn deref(&self) -> &Self::Target { @@ -90,13 +90,13 @@ impl Deref for EcnCount { } } -impl DerefMut for EcnCount { +impl DerefMut for Count { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } -impl EcnCount { +impl Count { pub const fn new(not_ect: u64, ect0: u64, ect1: u64, ce: u64) -> Self { // Yes, the enum array order is different from the argument order. Self(EnumMap::from_array([not_ect, ect1, ect0, ce])) @@ -108,7 +108,7 @@ impl EcnCount { } } -impl Sub for EcnCount { +impl Sub for Count { type Output = Self; /// Subtract the ECN counts in `other` from `self`. @@ -121,83 +121,83 @@ impl Sub for EcnCount { } } -impl AddAssign for EcnCount { +impl AddAssign for Count { fn add_assign(&mut self, ecn: IpTosEcn) { self[ecn] += 1; } } #[derive(PartialEq, Eq, Debug, Clone, Copy, Default)] -pub struct EcnValidationCount(EnumMap); +pub struct ValidationCount(EnumMap); -impl Deref for EcnValidationCount { - type Target = EnumMap; +impl Deref for ValidationCount { + type Target = EnumMap; fn deref(&self) -> &Self::Target { &self.0 } } -impl DerefMut for EcnValidationCount { +impl DerefMut for ValidationCount { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } #[derive(Debug, Clone, Copy, Enum, PartialEq, Eq)] -pub enum EcnValidationError { +pub enum ValidationError { BlackHole, Bleaching, ReceivedUnsentECT1, } #[derive(Debug, Clone, Copy, Enum, PartialEq, Eq)] -pub enum EcnValidationOutcome { +pub enum ValidationOutcome { Capable, - NotCapable(EcnValidationError), + NotCapable(ValidationError), } #[derive(Debug, Default)] -pub struct EcnInfo { +pub struct Info { /// The current state of ECN validation on this path. - state: EcnValidationState, + state: ValidationState, /// The largest ACK seen so far. largest_acked: PacketNumber, /// The ECN counts from the last ACK frame that increased `largest_acked`. - baseline: EcnCount, + baseline: Count, } -impl EcnInfo { +impl Info { /// Set the baseline (= the ECN counts from the last ACK Frame). - pub fn set_baseline(&mut self, baseline: EcnCount) { + pub fn set_baseline(&mut self, baseline: Count) { self.baseline = baseline; } /// Expose the current baseline. - pub const fn baseline(&self) -> EcnCount { + pub const fn baseline(&self) -> Count { self.baseline } /// Count the number of packets sent out on this path during ECN validation. - /// Exit ECN validation if the number of packets sent exceeds `ECN_TEST_COUNT`. + /// Exit ECN validation if the number of packets sent exceeds `TEST_COUNT`. /// We do not implement the part of the RFC that says to exit ECN validation if the time since /// the start of ECN validation exceeds 3 * PTO, since this seems to happen much too quickly. pub fn on_packet_sent(&mut self, stats: &mut Stats) { - if let EcnValidationState::Testing { probes_sent, .. } = &mut self.state { + if let ValidationState::Testing { probes_sent, .. } = &mut self.state { *probes_sent += 1; qdebug!("ECN probing: sent {} probes", probes_sent); - if *probes_sent == ECN_TEST_COUNT { + if *probes_sent == TEST_COUNT { qdebug!("ECN probing concluded with {} probes sent", probes_sent); - self.state.set(EcnValidationState::Unknown, stats); + self.state.set(ValidationState::Unknown, stats); } } } /// Disable ECN. - pub fn disable_ecn(&mut self, stats: &mut Stats, reason: EcnValidationError) { - self.state.set(EcnValidationState::Failed(reason), stats); + pub fn disable_ecn(&mut self, stats: &mut Stats, reason: ValidationError) { + self.state.set(ValidationState::Failed(reason), stats); } /// Process ECN counts from an ACK frame. @@ -206,19 +206,19 @@ impl EcnInfo { pub fn on_packets_acked( &mut self, acked_packets: &[SentPacket], - ack_ecn: Option, + ack_ecn: Option, stats: &mut Stats, ) -> bool { let prev_baseline = self.baseline; self.validate_ack_ecn_and_update(acked_packets, ack_ecn, stats); - matches!(self.state, EcnValidationState::Capable) + matches!(self.state, ValidationState::Capable) && (self.baseline - prev_baseline)[IpTosEcn::Ce] > 0 } pub fn on_packets_lost(&mut self, lost_packets: &[SentPacket], stats: &mut Stats) { - if let EcnValidationState::Testing { + if let ValidationState::Testing { probes_sent, initial_probes_lost: probes_lost, } = &mut self.state @@ -229,12 +229,12 @@ impl EcnInfo { .count(); // If we have lost all initial probes a bunch of times, we can conclude that the path // is not ECN capable and likely drops all ECN marked packets. - if probes_sent == probes_lost && *probes_lost == ECN_TEST_COUNT_INITIAL_PHASE { + if probes_sent == probes_lost && *probes_lost == TEST_COUNT_INITIAL_PHASE { qdebug!( "ECN validation failed, all {} initial marked packets were lost", probes_lost ); - self.disable_ecn(stats, EcnValidationError::BlackHole); + self.disable_ecn(stats, ValidationError::BlackHole); } } } @@ -243,7 +243,7 @@ impl EcnInfo { pub fn validate_ack_ecn_and_update( &mut self, acked_packets: &[SentPacket], - ack_ecn: Option, + ack_ecn: Option, stats: &mut Stats, ) { // RFC 9000, Appendix A.4: @@ -252,8 +252,8 @@ impl EcnInfo { // > (see Section 13.4.2.1) causes the ECN state for the path to become "capable", unless // > no marked packet has been acknowledged. match self.state { - EcnValidationState::Testing { .. } | EcnValidationState::Failed(_) => return, - EcnValidationState::Unknown | EcnValidationState::Capable => {} + ValidationState::Testing { .. } | ValidationState::Failed(_) => return, + ValidationState::Unknown | ValidationState::Capable => {} } // RFC 9000, Section 13.4.2.1: @@ -277,7 +277,7 @@ impl EcnInfo { // > corresponding ECN counts are not present in the ACK frame. let Some(ack_ecn) = ack_ecn else { qwarn!("ECN validation failed, no ECN counts in ACK frame"); - self.disable_ecn(stats, EcnValidationError::Bleaching); + self.disable_ecn(stats, ValidationError::Bleaching); return; }; @@ -294,7 +294,7 @@ impl EcnInfo { .unwrap(); if newly_acked_sent_with_ect0 == 0 { qwarn!("ECN validation failed, no ECT(0) packets were newly acked"); - self.disable_ecn(stats, EcnValidationError::Bleaching); + self.disable_ecn(stats, ValidationError::Bleaching); return; } let ecn_diff = ack_ecn - self.baseline; @@ -305,13 +305,13 @@ impl EcnInfo { sum_inc, newly_acked_sent_with_ect0 ); - self.disable_ecn(stats, EcnValidationError::Bleaching); + self.disable_ecn(stats, ValidationError::Bleaching); } else if ecn_diff[IpTosEcn::Ect1] > 0 { qwarn!("ECN validation failed, ACK counted ECT(1) marks that were never sent"); - self.disable_ecn(stats, EcnValidationError::ReceivedUnsentECT1); - } else if self.state != EcnValidationState::Capable { + self.disable_ecn(stats, ValidationError::ReceivedUnsentECT1); + } else if self.state != ValidationState::Capable { qinfo!("ECN validation succeeded, path is capable"); - self.state.set(EcnValidationState::Capable, stats); + self.state.set(ValidationState::Capable, stats); } self.baseline = ack_ecn; stats.ecn_tx = ack_ecn; @@ -321,8 +321,8 @@ impl EcnInfo { /// The ECN mark to use for packets sent on this path. pub const fn ecn_mark(&self) -> IpTosEcn { match self.state { - EcnValidationState::Testing { .. } | EcnValidationState::Capable => IpTosEcn::Ect0, - EcnValidationState::Failed(_) | EcnValidationState::Unknown => IpTosEcn::NotEct, + ValidationState::Testing { .. } | ValidationState::Capable => IpTosEcn::Ect0, + ValidationState::Failed(_) | ValidationState::Unknown => IpTosEcn::NotEct, } } } diff --git a/neqo-transport/src/frame.rs b/neqo-transport/src/frame.rs index 4b718d5676..7bc266cb09 100644 --- a/neqo-transport/src/frame.rs +++ b/neqo-transport/src/frame.rs @@ -12,7 +12,7 @@ use neqo_common::{qtrace, Decoder, Encoder}; use crate::{ cid::MAX_CONNECTION_ID_LEN, - ecn::EcnCount, + ecn, packet::PacketType, stream_id::{StreamId, StreamType}, AppError, CloseReason, Error, Res, TransportError, @@ -119,7 +119,7 @@ pub enum Frame<'a> { ack_delay: u64, first_ack_range: u64, ack_ranges: Vec, - ecn_count: Option, + ecn_count: Option, }, ResetStream { stream_id: StreamId, @@ -452,7 +452,9 @@ impl<'a> Frame<'a> { // Now check for the values for ACK_ECN. let ecn_count = ecn - .then(|| -> Res { Ok(EcnCount::new(0, dv(dec)?, dv(dec)?, dv(dec)?)) }) + .then(|| -> Res { + Ok(ecn::Count::new(0, dv(dec)?, dv(dec)?, dv(dec)?)) + }) .transpose()?; Ok(Frame::Ack { @@ -663,7 +665,7 @@ mod tests { use crate::{ cid::MAX_CONNECTION_ID_LEN, - ecn::EcnCount, + ecn::Count, frame::{AckRange, Frame, FRAME_TYPE_ACK}, CloseError, Error, StreamId, StreamType, }; @@ -708,7 +710,7 @@ mod tests { assert_eq!(Frame::decode(&mut dec).unwrap_err(), Error::NoMoreData); // Try to parse ACK_ECN with ECN values - let ecn_count = Some(EcnCount::new(0, 1, 2, 3)); + let ecn_count = Some(Count::new(0, 1, 2, 3)); let fe = Frame::Ack { largest_acknowledged: 0x1234, ack_delay: 0x1235, diff --git a/neqo-transport/src/lib.rs b/neqo-transport/src/lib.rs index 869ef7a4d1..4d795ae49b 100644 --- a/neqo-transport/src/lib.rs +++ b/neqo-transport/src/lib.rs @@ -4,8 +4,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(clippy::module_name_repetitions)] // This lint doesn't work here. - use neqo_common::qwarn; use neqo_crypto::Error as CryptoError; diff --git a/neqo-transport/src/packet/mod.rs b/neqo-transport/src/packet/mod.rs index 5f286c3291..b0b5fdd45d 100644 --- a/neqo-transport/src/packet/mod.rs +++ b/neqo-transport/src/packet/mod.rs @@ -4,6 +4,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(clippy::module_name_repetitions)] + // Encoding and decoding packets off the wire. use std::{ cmp::min, diff --git a/neqo-transport/src/path.rs b/neqo-transport/src/path.rs index d2e6371c72..9ab572eb04 100644 --- a/neqo-transport/src/path.rs +++ b/neqo-transport/src/path.rs @@ -24,7 +24,7 @@ use crate::{ ackrate::{AckRate, PeerAckDelay}, cc::CongestionControlAlgorithm, cid::{ConnectionId, ConnectionIdRef, ConnectionIdStore, RemoteConnectionIdEntry}, - ecn::{EcnCount, EcnInfo}, + ecn, frame::{FRAME_TYPE_PATH_CHALLENGE, FRAME_TYPE_PATH_RESPONSE, FRAME_TYPE_RETIRE_CONNECTION_ID}, packet::PacketBuilder, pmtud::Pmtud, @@ -194,7 +194,7 @@ impl Paths { ) -> bool { debug_assert!(!self.is_temporary(path)); let baseline = self.primary().map_or_else( - || EcnInfo::default().baseline(), + || ecn::Info::default().baseline(), |p| p.borrow().ecn_info.baseline(), ); path.borrow_mut().set_ecn_baseline(baseline); @@ -507,7 +507,7 @@ pub struct Path { /// The number of bytes sent on this path. sent_bytes: usize, /// The ECN-related state for this path (see RFC9000, Section 13.4 and Appendix A.4) - ecn_info: EcnInfo, + ecn_info: ecn::Info, /// For logging of events. qlog: NeqoQlog, } @@ -550,12 +550,12 @@ impl Path { sender, received_bytes: 0, sent_bytes: 0, - ecn_info: EcnInfo::default(), + ecn_info: ecn::Info::default(), qlog, } } - pub fn set_ecn_baseline(&mut self, baseline: EcnCount) { + pub fn set_ecn_baseline(&mut self, baseline: ecn::Count) { self.ecn_info.set_baseline(baseline); } @@ -676,7 +676,7 @@ impl Path { /// Make a datagram. pub fn datagram>>(&mut self, payload: V, stats: &mut Stats) -> Datagram { - // Make sure to use the TOS value from before calling EcnInfo::on_packet_sent, which may + // Make sure to use the TOS value from before calling ecn::Info::on_packet_sent, which may // update the ECN state and can hence change it - this packet should still be sent // with the current value. let tos = self.tos(); @@ -740,7 +740,7 @@ impl Path { "Possible ECN blackhole, disabling ECN and re-probing path" ); self.ecn_info - .disable_ecn(stats, crate::ecn::EcnValidationError::BlackHole); + .disable_ecn(stats, crate::ecn::ValidationError::BlackHole); ProbeState::ProbeNeeded { probe_count: 0 } } else { qinfo!([self], "Probing failed"); @@ -959,7 +959,7 @@ impl Path { pub fn on_packets_acked( &mut self, acked_pkts: &[SentPacket], - ack_ecn: Option, + ack_ecn: Option, now: Instant, stats: &mut Stats, ) { diff --git a/neqo-transport/src/qlog.rs b/neqo-transport/src/qlog.rs index 153d8d983a..b8589b6bba 100644 --- a/neqo-transport/src/qlog.rs +++ b/neqo-transport/src/qlog.rs @@ -6,6 +6,8 @@ // Functions that handle capturing QLOG traces. +#![allow(clippy::module_name_repetitions)] + use std::{ ops::{Deref, RangeInclusive}, time::{Duration, Instant}, diff --git a/neqo-transport/src/recovery/mod.rs b/neqo-transport/src/recovery/mod.rs index cd55e20e9a..ddea357c8c 100644 --- a/neqo-transport/src/recovery/mod.rs +++ b/neqo-transport/src/recovery/mod.rs @@ -6,6 +6,8 @@ // Tracking of sent packets and detecting their loss. +#![allow(clippy::module_name_repetitions)] + #[cfg(feature = "bench")] pub mod sent; #[cfg(not(feature = "bench"))] @@ -26,7 +28,7 @@ use sent::SentPackets; pub use token::{RecoveryToken, StreamRecoveryToken}; use crate::{ - ecn::EcnCount, + ecn, packet::PacketNumber, path::{Path, PathRef}, qlog::{self, QlogMetric}, @@ -604,7 +606,7 @@ impl LossRecovery { primary_path: &PathRef, pn_space: PacketNumberSpace, acked_ranges: R, - ack_ecn: Option, + ack_ecn: Option, ack_delay: Duration, now: Instant, ) -> (Vec, Vec) @@ -982,7 +984,7 @@ mod tests { use crate::{ cc::CongestionControlAlgorithm, cid::{ConnectionId, ConnectionIdEntry}, - ecn::EcnCount, + ecn, packet::{PacketNumber, PacketType}, path::{Path, PathRef}, stats::{Stats, StatsCell}, @@ -1010,7 +1012,7 @@ mod tests { &mut self, pn_space: PacketNumberSpace, acked_ranges: Vec>, - ack_ecn: Option, + ack_ecn: Option, ack_delay: Duration, now: Instant, ) -> (Vec, Vec) { diff --git a/neqo-transport/src/recv_stream.rs b/neqo-transport/src/recv_stream.rs index a57c2bf6d0..60c55f83ef 100644 --- a/neqo-transport/src/recv_stream.rs +++ b/neqo-transport/src/recv_stream.rs @@ -7,6 +7,8 @@ // Building a stream of ordered bytes to give the application from a series of // incoming STREAM frames. +#![allow(clippy::module_name_repetitions)] + use std::{ cell::RefCell, cmp::max, diff --git a/neqo-transport/src/rtt.rs b/neqo-transport/src/rtt.rs index c18bbd62ec..712eb85c3f 100644 --- a/neqo-transport/src/rtt.rs +++ b/neqo-transport/src/rtt.rs @@ -6,6 +6,8 @@ // Tracking of sent packets and detecting their loss. +#![allow(clippy::module_name_repetitions)] + use std::{ cmp::{max, min}, time::{Duration, Instant}, diff --git a/neqo-transport/src/send_stream.rs b/neqo-transport/src/send_stream.rs index a266da9d78..323215cd85 100644 --- a/neqo-transport/src/send_stream.rs +++ b/neqo-transport/src/send_stream.rs @@ -6,6 +6,8 @@ // Buffering data to send until it is acked. +#![allow(clippy::module_name_repetitions)] + use std::{ cell::RefCell, cmp::{max, min, Ordering}, diff --git a/neqo-transport/src/stats.rs b/neqo-transport/src/stats.rs index 33fdc10c2e..98b20e40a4 100644 --- a/neqo-transport/src/stats.rs +++ b/neqo-transport/src/stats.rs @@ -16,10 +16,7 @@ use std::{ use neqo_common::qwarn; -use crate::{ - ecn::{EcnCount, EcnValidationCount}, - packet::PacketNumber, -}; +use crate::{ecn, packet::PacketNumber}; pub const MAX_PTO_COUNTS: usize = 16; @@ -202,7 +199,7 @@ pub struct Stats { pub datagram_tx: DatagramStats, /// ECN path validation count, indexed by validation outcome. - pub ecn_path_validation: EcnValidationCount, + pub ecn_path_validation: ecn::ValidationCount, /// ECN counts for outgoing UDP datagrams, returned by remote through QUIC ACKs. /// /// Note: Given that QUIC ACKs only carry [`Ect0`], [`Ect1`] and [`Ce`], but @@ -214,9 +211,9 @@ pub struct Stats { /// [`Ect1`]: neqo_common::tos::IpTosEcn::Ect1 /// [`Ce`]: neqo_common::tos::IpTosEcn::Ce /// [`NotEct`]: neqo_common::tos::IpTosEcn::NotEct - pub ecn_tx: EcnCount, + pub ecn_tx: ecn::Count, /// ECN counts for incoming UDP datagrams, read from IP TOS header. - pub ecn_rx: EcnCount, + pub ecn_rx: ecn::Count, } impl Stats { diff --git a/neqo-transport/src/tracking.rs b/neqo-transport/src/tracking.rs index 17ec6d6f9c..f8791ac5a2 100644 --- a/neqo-transport/src/tracking.rs +++ b/neqo-transport/src/tracking.rs @@ -18,7 +18,7 @@ use neqo_common::{qdebug, qinfo, qtrace, qwarn, IpTosEcn}; use neqo_crypto::{Epoch, TLS_EPOCH_HANDSHAKE, TLS_EPOCH_INITIAL}; use crate::{ - ecn::EcnCount, + ecn, frame::{FRAME_TYPE_ACK, FRAME_TYPE_ACK_ECN}, packet::{PacketBuilder, PacketNumber, PacketType}, recovery::RecoveryToken, @@ -271,7 +271,7 @@ pub struct RecvdPackets { /// for the purposes of generating immediate acknowledgment. ignore_order: bool, // The counts of different ECN marks that have been received. - ecn_count: EcnCount, + ecn_count: ecn::Count, } impl RecvdPackets { @@ -294,12 +294,12 @@ impl RecvdPackets { 0 }, ignore_order: false, - ecn_count: EcnCount::default(), + ecn_count: ecn::Count::default(), } } /// Get the ECN counts. - pub fn ecn_marks(&mut self) -> &mut EcnCount { + pub fn ecn_marks(&mut self) -> &mut ecn::Count { &mut self.ecn_count } diff --git a/neqo-transport/src/version.rs b/neqo-transport/src/version.rs index fc6878941c..2b8b135d00 100644 --- a/neqo-transport/src/version.rs +++ b/neqo-transport/src/version.rs @@ -4,6 +4,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(clippy::module_name_repetitions)] + use neqo_common::qdebug; use crate::{Error, Res}; From ef9e4dc9a224baaee14f795801336db8727126d4 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Wed, 8 Jan 2025 18:20:52 +0200 Subject: [PATCH 05/18] chore: Enable clippy `pathbuf_init_then_push` lint (#2324) And fix the warnings. --- Cargo.toml | 1 + neqo-bin/src/lib.rs | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 414c831e90..7899277091 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,7 @@ nursery = { level = "warn", priority = -1 } pedantic = { level = "warn", priority = -1 } if_then_some_else_none = "warn" get_unwrap = "warn" +pathbuf_init_then_push = "warn" # Optimize build dependencies, because bindgen and proc macros / style # compilation take more to run than to build otherwise. diff --git a/neqo-bin/src/lib.rs b/neqo-bin/src/lib.rs index 1a9f981780..4ae71b359c 100644 --- a/neqo-bin/src/lib.rs +++ b/neqo-bin/src/lib.rs @@ -276,8 +276,7 @@ mod tests { impl TempDir { fn new() -> Self { - let mut dir = std::env::temp_dir(); - dir.push(format!( + let dir = std::env::temp_dir().join(format!( "neqo-bin-test-{}", SystemTime::now() .duration_since(SystemTime::UNIX_EPOCH) From db0a33205ba02a25780c2ee39116ae11f9c37aa4 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Thu, 9 Jan 2025 17:58:26 +0200 Subject: [PATCH 06/18] ci: Pin nightly (#2335) * ci: Pin nightly Due to https://github.com/rust-lang/rust/issues/135235 * Use default toolchain * Use default toolchain more --- .github/actions/rust/action.yml | 7 ++++--- .github/workflows/check.yml | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/actions/rust/action.yml b/.github/actions/rust/action.yml index 46ff026a5a..7640e986a7 100644 --- a/.github/actions/rust/action.yml +++ b/.github/actions/rust/action.yml @@ -24,7 +24,8 @@ runs: - name: Install Rust uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # master with: - toolchain: ${{ inputs.version }} + # TODO: Unpin once https://github.com/rust-lang/rust/issues/135235 is fixed. + toolchain: ${{ inputs.version == 'nightly' && 'nightly-2025-01-07' || inputs.version }} components: ${{ inputs.components }} targets: ${{ inputs.targets }} @@ -67,11 +68,11 @@ runs: env: GITHUB_TOKEN: ${{ inputs.token }} # TODO: Unpin cargo-quickinstall once our MSRV is > 1.76 - run: cargo +${{ inputs.version }} install --locked cargo-quickinstall@0.3.5 + run: cargo install --locked cargo-quickinstall@0.3.5 - name: Install Rust tools shell: bash if: inputs.tools != '' env: GITHUB_TOKEN: ${{ inputs.token }} - run: cargo +${{ inputs.version }} quickinstall $(echo ${{ inputs.tools }} | tr -d ",") + run: cargo quickinstall $(echo ${{ inputs.tools }} | tr -d ",") diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 34e45fbc94..3ff48a8d02 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -79,7 +79,7 @@ jobs: - name: Check run: | # shellcheck disable=SC2086 - cargo +${{ matrix.rust-toolchain }} check $BUILD_TYPE --all-targets --features ci + cargo check $BUILD_TYPE --all-targets --features ci - name: Run tests and determine coverage env: @@ -89,15 +89,15 @@ jobs: export DUMP_SIMULATION_SEEDS # shellcheck disable=SC2086 if [ "${{ matrix.rust-toolchain }}" == "nightly" ]; then - cargo +${{ matrix.rust-toolchain }} llvm-cov nextest $BUILD_TYPE --mcdc --include-ffi --features ci --profile ci --codecov --output-path codecov.json + cargo llvm-cov nextest $BUILD_TYPE --mcdc --include-ffi --features ci --profile ci --codecov --output-path codecov.json else - cargo +${{ matrix.rust-toolchain }} nextest run $BUILD_TYPE --features ci --profile ci + cargo nextest run $BUILD_TYPE --features ci --profile ci fi - name: Run client/server transfer run: | # shellcheck disable=SC2086 - cargo +${{ matrix.rust-toolchain }} build $BUILD_TYPE --bin neqo-client --bin neqo-server + cargo build $BUILD_TYPE --bin neqo-client --bin neqo-server "target/$BUILD_DIR/neqo-server" "$HOST:4433" & PID=$! # Give the server time to start. From d84f14da5806e5cc4363e46b5cddc58c7d0fe8de Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 9 Jan 2025 18:58:41 +0200 Subject: [PATCH 07/18] build(deps): bump actions/upload-artifact from 4.4.3 to 4.5.0 (#2298) * build(deps): bump actions/upload-artifact from 4.4.3 to 4.5.0 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.4.3 to 4.5.0. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882...6f51ac03b9356f520e9adb1b1b7802705f340c2b) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Add actions * Debug with `--show-output` * Restore `--output null` --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Lars Eggert --- .github/actions/pr-comment-data-export/action.yml | 2 +- .github/actions/quic-interop-runner/action.yml | 4 ++-- .github/workflows/bench.yml | 2 +- .github/workflows/check.yml | 2 +- .github/workflows/firefox.yml | 4 ++-- .github/workflows/mutants.yml | 2 +- .github/workflows/qns.yml | 2 +- .github/workflows/sanitize.yml | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/actions/pr-comment-data-export/action.yml b/.github/actions/pr-comment-data-export/action.yml index 77bfd610ee..57a2f01d94 100644 --- a/.github/actions/pr-comment-data-export/action.yml +++ b/.github/actions/pr-comment-data-export/action.yml @@ -31,7 +31,7 @@ runs: echo "${{ inputs.log-url }}" > comment-data/log-url fi - if: github.event_name == 'pull_request' - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 with: name: ${{ inputs.name }} path: comment-data diff --git a/.github/actions/quic-interop-runner/action.yml b/.github/actions/quic-interop-runner/action.yml index c7f31e37a2..482a286560 100644 --- a/.github/actions/quic-interop-runner/action.yml +++ b/.github/actions/quic-interop-runner/action.yml @@ -94,7 +94,7 @@ runs: exit $FAILED shell: bash - - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 if: always() id: upload-logs with: @@ -110,7 +110,7 @@ runs: mv result.json.tmp result.json shell: bash - - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 if: always() with: name: '${{ inputs.client }} vs. ${{ inputs.server }} results' diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index a2c6794a1b..40bab8d59d 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -276,7 +276,7 @@ jobs: - name: Export perf data id: export - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 with: name: ${{ github.event.repository.name }}-${{ github.sha }} path: | diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 3ff48a8d02..efe963b7e0 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -123,7 +123,7 @@ jobs: - name: Save simulation seeds artifact if: always() - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 with: name: simulation-seeds-${{ matrix.os }}-${{ matrix.rust-toolchain }}-${{ matrix.type }} path: simulation-seeds diff --git a/.github/workflows/firefox.yml b/.github/workflows/firefox.yml index a5ef3247f2..84d47fbae5 100644 --- a/.github/workflows/firefox.yml +++ b/.github/workflows/firefox.yml @@ -141,7 +141,7 @@ jobs: - name: Export binary id: upload - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 with: name: ${{ runner.os }}-${{ env.FIREFOX }}-${{ matrix.type }}.tgz path: ${{ env.FIREFOX }}.tar @@ -150,7 +150,7 @@ jobs: - run: echo "${{ steps.upload.outputs.artifact-url }}" >> artifact - name: Export artifact URL - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 with: name: artifact-${{ runner.os }}-${{ env.FIREFOX }}-${{ matrix.type }} path: artifact diff --git a/.github/workflows/mutants.yml b/.github/workflows/mutants.yml index fcd52f8b9e..4b143cd6cf 100644 --- a/.github/workflows/mutants.yml +++ b/.github/workflows/mutants.yml @@ -61,7 +61,7 @@ jobs: echo '```' } > "$GITHUB_STEP_SUMMARY" - - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 with: name: mutants.out path: mutants.out diff --git a/.github/workflows/qns.yml b/.github/workflows/qns.yml index 71a556b3aa..f312715305 100644 --- a/.github/workflows/qns.yml +++ b/.github/workflows/qns.yml @@ -77,7 +77,7 @@ jobs: platforms: 'linux/amd64' outputs: type=docker,dest=/tmp/${{ env.LATEST }}.tar - - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 with: name: '${{ env.LATEST }} Docker image' path: /tmp/${{ env.LATEST }}.tar diff --git a/.github/workflows/sanitize.yml b/.github/workflows/sanitize.yml index 567c137f4f..3c52b85779 100644 --- a/.github/workflows/sanitize.yml +++ b/.github/workflows/sanitize.yml @@ -81,7 +81,7 @@ jobs: - name: Save simulation seeds artifact if: env.DUMP_SIMULATION_SEEDS - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 with: name: simulation-seeds-${{ matrix.os }}-sanitizer-${{ matrix.sanitizer }} path: ${{ env.DUMP_SIMULATION_SEEDS }} From 17c41033e298c423806a77dd474535c77cdf275e Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Thu, 9 Jan 2025 19:51:09 +0200 Subject: [PATCH 08/18] chore: Enable the `renamed_function_params` lint (#2327) And fix all the warnings. --- Cargo.toml | 1 + neqo-transport/src/crypto.rs | 8 ++++---- neqo-transport/src/ecn.rs | 8 ++++---- neqo-transport/src/fc.rs | 16 ++++++++-------- neqo-transport/src/tracking.rs | 8 ++++---- test-fixture/src/sim/connection.rs | 4 ++-- 6 files changed, 23 insertions(+), 22 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7899277091..f37dd8141d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,6 +45,7 @@ pedantic = { level = "warn", priority = -1 } if_then_some_else_none = "warn" get_unwrap = "warn" pathbuf_init_then_push = "warn" +renamed_function_params = "warn" # Optimize build dependencies, because bindgen and proc macros / style # compilation take more to run than to build otherwise. diff --git a/neqo-transport/src/crypto.rs b/neqo-transport/src/crypto.rs index 9fa8fc5d50..04975169cc 100644 --- a/neqo-transport/src/crypto.rs +++ b/neqo-transport/src/crypto.rs @@ -732,8 +732,8 @@ pub struct CryptoState { impl Index for CryptoState { type Output = CryptoDxState; - fn index(&self, dir: CryptoDxDirection) -> &Self::Output { - match dir { + fn index(&self, index: CryptoDxDirection) -> &Self::Output { + match index { CryptoDxDirection::Read => &self.rx, CryptoDxDirection::Write => &self.tx, } @@ -741,8 +741,8 @@ impl Index for CryptoState { } impl IndexMut for CryptoState { - fn index_mut(&mut self, dir: CryptoDxDirection) -> &mut Self::Output { - match dir { + fn index_mut(&mut self, index: CryptoDxDirection) -> &mut Self::Output { + match index { CryptoDxDirection::Read => &mut self.rx, CryptoDxDirection::Write => &mut self.tx, } diff --git a/neqo-transport/src/ecn.rs b/neqo-transport/src/ecn.rs index 2ec3285b5f..e518052e88 100644 --- a/neqo-transport/src/ecn.rs +++ b/neqo-transport/src/ecn.rs @@ -112,18 +112,18 @@ impl Sub for Count { type Output = Self; /// Subtract the ECN counts in `other` from `self`. - fn sub(self, other: Self) -> Self { + fn sub(self, rhs: Self) -> Self { let mut diff = Self::default(); for (ecn, count) in &mut *diff { - *count = self[ecn].saturating_sub(other[ecn]); + *count = self[ecn].saturating_sub(rhs[ecn]); } diff } } impl AddAssign for Count { - fn add_assign(&mut self, ecn: IpTosEcn) { - self[ecn] += 1; + fn add_assign(&mut self, rhs: IpTosEcn) { + self[rhs] += 1; } } diff --git a/neqo-transport/src/fc.rs b/neqo-transport/src/fc.rs index 80fb5fbe13..bad3d43cf5 100644 --- a/neqo-transport/src/fc.rs +++ b/neqo-transport/src/fc.rs @@ -500,8 +500,8 @@ impl RemoteStreamLimits { impl Index for RemoteStreamLimits { type Output = RemoteStreamLimit; - fn index(&self, idx: StreamType) -> &Self::Output { - match idx { + fn index(&self, index: StreamType) -> &Self::Output { + match index { StreamType::BiDi => &self.bidirectional, StreamType::UniDi => &self.unidirectional, } @@ -509,8 +509,8 @@ impl Index for RemoteStreamLimits { } impl IndexMut for RemoteStreamLimits { - fn index_mut(&mut self, idx: StreamType) -> &mut Self::Output { - match idx { + fn index_mut(&mut self, index: StreamType) -> &mut Self::Output { + match index { StreamType::BiDi => &mut self.bidirectional, StreamType::UniDi => &mut self.unidirectional, } @@ -555,8 +555,8 @@ impl LocalStreamLimits { impl Index for LocalStreamLimits { type Output = SenderFlowControl; - fn index(&self, idx: StreamType) -> &Self::Output { - match idx { + fn index(&self, index: StreamType) -> &Self::Output { + match index { StreamType::BiDi => &self.bidirectional, StreamType::UniDi => &self.unidirectional, } @@ -564,8 +564,8 @@ impl Index for LocalStreamLimits { } impl IndexMut for LocalStreamLimits { - fn index_mut(&mut self, idx: StreamType) -> &mut Self::Output { - match idx { + fn index_mut(&mut self, index: StreamType) -> &mut Self::Output { + match index { StreamType::BiDi => &mut self.bidirectional, StreamType::UniDi => &mut self.unidirectional, } diff --git a/neqo-transport/src/tracking.rs b/neqo-transport/src/tracking.rs index f8791ac5a2..6e5fded27f 100644 --- a/neqo-transport/src/tracking.rs +++ b/neqo-transport/src/tracking.rs @@ -86,14 +86,14 @@ impl PacketNumberSpaceSet { impl Index for PacketNumberSpaceSet { type Output = bool; - fn index(&self, space: PacketNumberSpace) -> &Self::Output { - &self.spaces[space] + fn index(&self, index: PacketNumberSpace) -> &Self::Output { + &self.spaces[index] } } impl IndexMut for PacketNumberSpaceSet { - fn index_mut(&mut self, space: PacketNumberSpace) -> &mut Self::Output { - &mut self.spaces[space] + fn index_mut(&mut self, index: PacketNumberSpace) -> &mut Self::Output { + &mut self.spaces[index] } } diff --git a/test-fixture/src/sim/connection.rs b/test-fixture/src/sim/connection.rs index 63fb56ce0b..8ca75a53ff 100644 --- a/test-fixture/src/sim/connection.rs +++ b/test-fixture/src/sim/connection.rs @@ -138,10 +138,10 @@ impl Node for ConnectionNode { self.setup_goals(now); } - fn process(&mut self, mut dgram: Option, now: Instant) -> Output { + fn process(&mut self, mut d: Option, now: Instant) -> Output { _ = self.process_goals(|goal, c| goal.process(c, now)); loop { - let res = self.c.process(dgram.take(), now); + let res = self.c.process(d.take(), now); let mut active = false; while let Some(e) = self.c.next_event() { From 3c48567e164678acbeeea66391a378080bcee6c3 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Thu, 9 Jan 2025 18:56:42 +0100 Subject: [PATCH 09/18] perf(udp): multi-message receive on apple (#2302) * feat(udp): multi-message receive on apple * docs: improve platforms with segmentation offloading line * refactor: use cfg_aliases * tests: empty datagram on apple --------- Co-authored-by: Lars Eggert --- Cargo.lock | 1 + Cargo.toml | 2 +- neqo-bin/src/client/mod.rs | 8 +- neqo-bin/src/server/mod.rs | 5 +- neqo-bin/src/udp.rs | 4 +- neqo-udp/Cargo.toml | 3 + neqo-udp/build.rs | 16 +++ neqo-udp/src/lib.rs | 213 +++++++++++++++++++++---------------- 8 files changed, 149 insertions(+), 103 deletions(-) create mode 100644 neqo-udp/build.rs diff --git a/Cargo.lock b/Cargo.lock index 16e546b75e..2ed60546e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -955,6 +955,7 @@ dependencies = [ name = "neqo-udp" version = "0.11.0" dependencies = [ + "cfg_aliases", "log", "neqo-common", "quinn-udp", diff --git a/Cargo.toml b/Cargo.toml index f37dd8141d..09e04fe766 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ rust-version = "1.76.0" enum-map = { version = "2.7", default-features = false } log = { version = "0.4", default-features = false } qlog = { version = "0.13", default-features = false } -quinn-udp = { version = "0.5.6", default-features = false, features = ["direct-log"] } +quinn-udp = { version = "0.5.6", default-features = false, features = ["direct-log", "fast-apple-datapath"] } regex = { version = "1.9", default-features = false, features = ["unicode-perl"] } static_assertions = { version = "1.1", default-features = false } url = { version = "2.5.3", default-features = false, features = ["std"] } diff --git a/neqo-bin/src/client/mod.rs b/neqo-bin/src/client/mod.rs index 24102cd283..cb1d829fd4 100644 --- a/neqo-bin/src/client/mod.rs +++ b/neqo-bin/src/client/mod.rs @@ -30,6 +30,7 @@ use neqo_crypto::{ }; use neqo_http3::Output; use neqo_transport::{AppError, CloseReason, ConnectionId, Version}; +use neqo_udp::RecvBuf; use tokio::time::Sleep; use url::{Host, Origin, Url}; @@ -394,7 +395,7 @@ struct Runner<'a, H: Handler> { handler: H, timeout: Option>>, args: &'a Args, - recv_buf: Vec, + recv_buf: RecvBuf, } impl<'a, H: Handler> Runner<'a, H> { @@ -412,7 +413,7 @@ impl<'a, H: Handler> Runner<'a, H> { handler, args, timeout: None, - recv_buf: vec![0; neqo_udp::RECV_BUF_SIZE], + recv_buf: RecvBuf::new(), } } @@ -481,9 +482,6 @@ impl<'a, H: Handler> Runner<'a, H> { let Some(dgrams) = self.socket.recv(self.local_addr, &mut self.recv_buf)? else { break; }; - if dgrams.len() == 0 { - break; - } self.client.process_multiple_input(dgrams, Instant::now()); self.process_output().await?; } diff --git a/neqo-bin/src/server/mod.rs b/neqo-bin/src/server/mod.rs index 2dd05a3daf..bcce011ec6 100644 --- a/neqo-bin/src/server/mod.rs +++ b/neqo-bin/src/server/mod.rs @@ -29,6 +29,7 @@ use neqo_crypto::{ init_db, AntiReplay, Cipher, }; use neqo_transport::{Output, RandomConnectionIdGenerator, Version}; +use neqo_udp::RecvBuf; use tokio::time::Sleep; use crate::SharedArgs; @@ -202,7 +203,7 @@ pub struct ServerRunner { server: Box, timeout: Option>>, sockets: Vec<(SocketAddr, crate::udp::Socket)>, - recv_buf: Vec, + recv_buf: RecvBuf, } impl ServerRunner { @@ -217,7 +218,7 @@ impl ServerRunner { server, timeout: None, sockets, - recv_buf: vec![0; neqo_udp::RECV_BUF_SIZE], + recv_buf: RecvBuf::new(), } } diff --git a/neqo-bin/src/udp.rs b/neqo-bin/src/udp.rs index 8bc78c2665..bd8d0eef85 100644 --- a/neqo-bin/src/udp.rs +++ b/neqo-bin/src/udp.rs @@ -7,7 +7,7 @@ use std::{io, net::SocketAddr}; use neqo_common::Datagram; -use neqo_udp::DatagramIter; +use neqo_udp::{DatagramIter, RecvBuf}; /// Ideally this would live in [`neqo-udp`]. [`neqo-udp`] is used in Firefox. /// @@ -59,7 +59,7 @@ impl Socket { pub fn recv<'a>( &self, local_address: SocketAddr, - recv_buf: &'a mut [u8], + recv_buf: &'a mut RecvBuf, ) -> Result>, io::Error> { self.inner .try_io(tokio::io::Interest::READABLE, || { diff --git a/neqo-udp/Cargo.toml b/neqo-udp/Cargo.toml index 73efce539b..150a68da7e 100644 --- a/neqo-udp/Cargo.toml +++ b/neqo-udp/Cargo.toml @@ -21,6 +21,9 @@ log = { workspace = true } neqo-common = { path = "./../neqo-common" } quinn-udp = { workspace = true } +[build-dependencies] +cfg_aliases = "0.2" + [package.metadata.cargo-machete] ignored = ["log"] diff --git a/neqo-udp/build.rs b/neqo-udp/build.rs new file mode 100644 index 0000000000..c0ad7df7b3 --- /dev/null +++ b/neqo-udp/build.rs @@ -0,0 +1,16 @@ +use cfg_aliases::cfg_aliases; + +fn main() { + // Setup cfg aliases + cfg_aliases! { + // Platforms + apple: { + any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "visionos" + ) + }, + } +} diff --git a/neqo-udp/src/lib.rs b/neqo-udp/src/lib.rs index 61f7fa1ca2..ab272b5559 100644 --- a/neqo-udp/src/lib.rs +++ b/neqo-udp/src/lib.rs @@ -7,20 +7,56 @@ #![allow(clippy::missing_errors_doc)] // Functions simply delegate to tokio and quinn-udp. use std::{ + array, io::{self, IoSliceMut}, + iter, net::SocketAddr, slice::{self, Chunks}, }; +use log::{log_enabled, Level}; use neqo_common::{qdebug, qtrace, Datagram, IpTos}; use quinn_udp::{EcnCodepoint, RecvMeta, Transmit, UdpSocketState}; -/// Socket receive buffer size. +/// Receive buffer size /// -/// Allows reading multiple datagrams in a single [`Socket::recv`] call. -// -// TODO: Experiment with different values across platforms. -pub const RECV_BUF_SIZE: usize = u16::MAX as usize; +/// Fits a maximum size UDP datagram, or, on platforms with segmentation +/// offloading, multiple smaller datagrams. +const RECV_BUF_SIZE: usize = u16::MAX as usize; + +/// The number of buffers to pass to the OS on [`Socket::recv`]. +/// +/// Platforms without segmentation offloading, i.e. platforms not able to read +/// multiple datagrams into a single buffer, can benefit from using multiple +/// buffers instead. +/// +/// Platforms with segmentation offloading have not shown performance +/// improvements when additionally using multiple buffers. +/// +/// - Linux/Android: use segmentation offloading via GRO +/// - Windows: use segmentation offloading via URO (caveat see ) +/// - Apple: no segmentation offloading available, use multiple buffers +#[cfg(not(apple))] +const NUM_BUFS: usize = 1; +#[cfg(apple)] +// Value approximated based on neqo-bin "Download" benchmark only. +const NUM_BUFS: usize = 16; + +/// A UDP receive buffer. +pub struct RecvBuf(Vec>); + +impl RecvBuf { + #[must_use] + pub fn new() -> Self { + Self(vec![vec![0; RECV_BUF_SIZE]; NUM_BUFS]) + } +} + +impl Default for RecvBuf { + fn default() -> Self { + Self::new() + } +} pub fn send_inner( state: &UdpSocketState, @@ -52,88 +88,98 @@ use std::os::fd::AsFd as SocketRef; #[cfg(windows)] use std::os::windows::io::AsSocket as SocketRef; +#[allow(clippy::missing_panics_doc)] pub fn recv_inner<'a>( local_address: SocketAddr, state: &UdpSocketState, socket: impl SocketRef, - recv_buf: &'a mut [u8], + recv_buf: &'a mut RecvBuf, ) -> Result, io::Error> { - let mut meta; - - let data = loop { - meta = RecvMeta::default(); + let mut metas = [RecvMeta::default(); NUM_BUFS]; + let mut iovs: [IoSliceMut; NUM_BUFS] = { + let mut bufs = recv_buf.0.iter_mut().map(|b| IoSliceMut::new(b)); + array::from_fn(|_| bufs.next().expect("NUM_BUFS elements")) + }; - state.recv( - (&socket).into(), - &mut [IoSliceMut::new(recv_buf)], - slice::from_mut(&mut meta), - )?; + let n = state.recv((&socket).into(), &mut iovs, &mut metas)?; - if meta.len == 0 || meta.stride == 0 { - qdebug!( - "ignoring datagram from {} to {} len {} stride {}", + if log_enabled!(Level::Trace) { + for meta in metas.iter().take(n) { + qtrace!( + "received {} bytes from {} to {} in {} segments", + meta.len, meta.addr, local_address, - meta.len, - meta.stride + if meta.stride == 0 { + 0 + } else { + meta.len.div_ceil(meta.stride) + } ); - continue; } - - break &recv_buf[..meta.len]; - }; - - qtrace!( - "received {} bytes from {} to {} in {} segments", - data.len(), - meta.addr, - local_address, - data.len().div_ceil(meta.stride), - ); + } Ok(DatagramIter { - meta, - datagrams: data.chunks(meta.stride), + current_buffer: None, + remaining_buffers: metas.into_iter().zip(recv_buf.0.iter()).take(n), local_address, }) } pub struct DatagramIter<'a> { - meta: RecvMeta, - datagrams: Chunks<'a, u8>, + /// The current buffer, containing zero or more datagrams, each sharing the + /// same [`RecvMeta`]. + current_buffer: Option<(RecvMeta, Chunks<'a, u8>)>, + /// Remaining buffers, each containing zero or more datagrams, one + /// [`RecvMeta`] per buffer. + remaining_buffers: + iter::Take, slice::Iter<'a, Vec>>>, + /// The local address of the UDP socket used to receive the datagrams. local_address: SocketAddr, } -impl std::fmt::Debug for DatagramIter<'_> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("DatagramIter") - .field("meta", &self.meta) - .field("local_address", &self.local_address) - .finish() - } -} - impl<'a> Iterator for DatagramIter<'a> { type Item = Datagram<&'a [u8]>; fn next(&mut self) -> Option { - self.datagrams.next().map(|d| { - Datagram::from_slice( - self.meta.addr, - self.local_address, - self.meta - .ecn - .map(|n| IpTos::from(n as u8)) - .unwrap_or_default(), - d, - ) - }) - } -} - -impl ExactSizeIterator for DatagramIter<'_> { - fn len(&self) -> usize { - self.datagrams.len() + loop { + // Return the next datagram in the current buffer, if any. + if let Some((meta, d)) = self + .current_buffer + .as_mut() + .and_then(|(meta, ds)| ds.next().map(|d| (meta, d))) + { + return Some(Datagram::from_slice( + meta.addr, + self.local_address, + meta.ecn.map(|n| IpTos::from(n as u8)).unwrap_or_default(), + d, + )); + } + + // There are no more datagrams in the current buffer. Try promoting + // one of the remaining buffers, if any, to be the current buffer. + let Some((meta, buf)) = self.remaining_buffers.next() else { + // Handled all buffers. No more datagrams. Iterator is empty. + return None; + }; + + // Ignore empty datagrams. + if meta.len == 0 || meta.stride == 0 { + qdebug!( + "ignoring empty datagram from {} to {} len {} stride {}", + meta.addr, + self.local_address, + meta.len, + meta.stride + ); + continue; + } + + // Got another buffer. Let's chunk it into datagrams and return the + // first datagram in the next loop iteration. + self.current_buffer = Some((meta, buf[0..meta.len].chunks(meta.stride))); + } } } @@ -162,7 +208,7 @@ impl Socket { pub fn recv<'a>( &self, local_address: SocketAddr, - recv_buf: &'a mut [u8], + recv_buf: &'a mut RecvBuf, ) -> Result, io::Error> { recv_inner(local_address, &self.state, &self.inner, recv_buf) } @@ -182,22 +228,19 @@ mod tests { } #[test] - fn ignore_empty_datagram() -> Result<(), io::Error> { - let sender = socket()?; + fn handle_empty_datagram() -> Result<(), io::Error> { + // quinn-udp doesn't support sending emtpy datagrams across all + // platforms. Use `std` socket instead. See also + // . + let sender = std::net::UdpSocket::bind("127.0.0.1:0")?; let receiver = Socket::new(std::net::UdpSocket::bind("127.0.0.1:0")?)?; let receiver_addr: SocketAddr = "127.0.0.1:0".parse().unwrap(); - let datagram = Datagram::new( - sender.inner.local_addr()?, - receiver.inner.local_addr()?, - IpTos::default(), - vec![], - ); + sender.send_to(&[], receiver.inner.local_addr()?)?; + let mut recv_buf = RecvBuf::new(); + let mut datagrams = receiver.recv(receiver_addr, &mut recv_buf)?; - sender.send(&datagram)?; - let mut recv_buf = vec![0; RECV_BUF_SIZE]; - let res = receiver.recv(receiver_addr, &mut recv_buf); - assert_eq!(res.unwrap_err().kind(), std::io::ErrorKind::WouldBlock); + assert_eq!(datagrams.next(), None); Ok(()) } @@ -217,7 +260,7 @@ mod tests { sender.send(&datagram)?; - let mut recv_buf = vec![0; RECV_BUF_SIZE]; + let mut recv_buf = RecvBuf::new(); let mut received_datagrams = receiver .recv(receiver_addr, &mut recv_buf) .expect("receive to succeed"); @@ -260,7 +303,7 @@ mod tests { // Allow for one GSO sendmmsg to result in multiple GRO recvmmsg. let mut num_received = 0; - let mut recv_buf = vec![0; RECV_BUF_SIZE]; + let mut recv_buf = RecvBuf::new(); while num_received < max_gso_segments { receiver .recv(receiver_addr, &mut recv_buf) @@ -277,20 +320,4 @@ mod tests { Ok(()) } - - #[test] - fn fmt_datagram_iter() { - let dgrams = []; - - let i = DatagramIter { - meta: RecvMeta::default(), - datagrams: dgrams.chunks(1), - local_address: "[::]:0".parse().unwrap(), - }; - - assert_eq!( - &format!("{i:?}"), - "DatagramIter { meta: RecvMeta { addr: [::]:0, len: 0, stride: 0, ecn: None, dst_ip: None }, local_address: [::]:0 }" - ); - } } From c9815b5e7e54db1ca2bf1c76d1cff26d18a7ec1e Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Thu, 9 Jan 2025 22:06:29 +0200 Subject: [PATCH 10/18] chore: Enable the `ref_patterns` clippy lint (#2326) And fix all the warnings that it generates. Signed-off-by: Lars Eggert --- Cargo.toml | 1 + neqo-crypto/src/agent.rs | 12 ++++++------ neqo-http3/src/connection.rs | 4 ++-- neqo-http3/src/recv_message.rs | 5 +---- neqo-transport/src/addr_valid.rs | 4 ++-- neqo-transport/src/connection/mod.rs | 2 +- 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 09e04fe766..8dc67bcadc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 diff --git a/neqo-crypto/src/agent.rs b/neqo-crypto/src/agent.rs index b3e76ca39b..f3180fbc78 100644 --- a/neqo-crypto/src/agent.rs +++ b/neqo-crypto/src/agent.rs @@ -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, } } @@ -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) }, } @@ -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)?; diff --git a/neqo-http3/src/connection.rs b/neqo-http3/src/connection.rs index a59b6908e7..b7831a14b4 100644 --- a/neqo-http3/src/connection.rs +++ b/neqo-http3/src/connection.rs @@ -1600,7 +1600,7 @@ impl Http3Connection { conn: &mut Connection, ) -> Option> { 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() { @@ -1617,7 +1617,7 @@ impl Http3Connection { conn: &mut Connection, ) -> Option> { 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); diff --git a/neqo-http3/src/recv_message.rs b/neqo-http3/src/recv_message.rs index 406bca0466..c0757d7bb8 100644 --- a/neqo-http3/src/recv_message.rs +++ b/neqo-http3/src/recv_message.rs @@ -296,10 +296,7 @@ impl RecvMessage { } }; } - RecvMessageState::DecodingHeaders { - ref header_block, - fin, - } => { + RecvMessageState::DecodingHeaders { header_block, fin } => { if self .qpack_decoder .borrow() diff --git a/neqo-transport/src/addr_valid.rs b/neqo-transport/src/addr_valid.rs index 5cb9341e0b..00b23f920a 100644 --- a/neqo-transport/src/addr_valid.rs +++ b/neqo-transport/src/addr_valid.rs @@ -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, } } @@ -322,7 +322,7 @@ impl NewTokenState { pub fn save_token(&mut self, token: Vec) { if let Self::Client { ref mut pending, - ref old, + old, } = self { for t in old.iter().rev().chain(pending.iter().rev()) { diff --git a/neqo-transport/src/connection/mod.rs b/neqo-transport/src/connection/mod.rs index 8ef0ad8e55..cf2b6218b8 100644 --- a/neqo-transport/src/connection/mod.rs +++ b/neqo-transport/src/connection/mod.rs @@ -203,7 +203,7 @@ impl AddressValidationInfo { pub fn generate_new_token(&self, peer_address: SocketAddr, now: Instant) -> Option> { 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) From 6013bde7983b9cc77939b0c084ba47dcbb8478ba Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Thu, 9 Jan 2025 22:11:45 +0200 Subject: [PATCH 11/18] chore: Enable the `unused_trait_names` lint (#2334) * chore: Enable the `unused_trait_names` lint And fix all the warnings it generates. * More * More --------- Signed-off-by: Lars Eggert --- Cargo.toml | 1 + neqo-bin/benches/main.rs | 2 +- neqo-bin/src/bin/client.rs | 2 +- neqo-bin/src/bin/server.rs | 2 +- neqo-bin/src/client/http09.rs | 4 ++-- neqo-bin/src/client/http3.rs | 4 ++-- neqo-bin/src/client/mod.rs | 6 +++--- neqo-bin/src/lib.rs | 4 ++-- neqo-bin/src/server/http09.rs | 2 +- neqo-bin/src/server/http3.rs | 2 +- neqo-bin/src/server/mod.rs | 6 +++--- neqo-common/src/fuzz.rs | 2 +- neqo-common/src/lib.rs | 2 +- neqo-common/src/log.rs | 2 +- neqo-http3/src/connection.rs | 2 +- neqo-http3/src/connection_client.rs | 4 ++-- neqo-http3/src/connection_server.rs | 2 +- .../src/features/extended_connect/tests/webtransport/mod.rs | 2 +- .../extended_connect/tests/webtransport/negotiation.rs | 2 +- .../extended_connect/tests/webtransport/sessions.rs | 2 +- neqo-http3/src/frames/hframe.rs | 2 +- neqo-http3/src/headers_checks.rs | 2 +- neqo-http3/src/recv_message.rs | 2 +- neqo-http3/src/server.rs | 2 +- neqo-http3/src/stream_type_reader.rs | 2 +- neqo-http3/tests/httpconn.rs | 2 +- neqo-http3/tests/priority.rs | 2 +- neqo-http3/tests/send_message.rs | 2 +- neqo-http3/tests/webtransport.rs | 2 +- neqo-qpack/src/header_block.rs | 2 +- neqo-qpack/src/reader.rs | 2 +- neqo-transport/src/cc/tests/cubic.rs | 2 +- neqo-transport/src/cc/tests/new_reno.rs | 2 +- neqo-transport/src/cid.rs | 2 +- neqo-transport/src/connection/dump.rs | 2 +- neqo-transport/src/connection/tests/datagram.rs | 2 +- neqo-transport/src/connection/tests/handshake.rs | 2 +- neqo-transport/src/connection/tests/migration.rs | 2 +- neqo-transport/src/connection/tests/mod.rs | 2 +- neqo-transport/src/connection/tests/priority.rs | 2 +- neqo-transport/src/connection/tests/stream.rs | 2 +- neqo-transport/src/connection/tests/vn.rs | 2 +- neqo-transport/src/connection/tests/zerortt.rs | 2 +- neqo-transport/src/events.rs | 2 +- neqo-transport/src/qlog.rs | 2 +- neqo-transport/src/recovery/mod.rs | 4 ++-- neqo-transport/src/recovery/sent.rs | 2 +- neqo-transport/src/send_stream.rs | 2 +- neqo-transport/src/server.rs | 4 ++-- neqo-transport/tests/common/mod.rs | 2 +- test-fixture/src/lib.rs | 2 +- test-fixture/src/sim/connection.rs | 2 +- 52 files changed, 62 insertions(+), 61 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8dc67bcadc..1ec26cff3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,6 +47,7 @@ get_unwrap = "warn" pathbuf_init_then_push = "warn" ref_patterns = "warn" renamed_function_params = "warn" +unused_trait_names = "warn" # Optimize build dependencies, because bindgen and proc macros / style # compilation take more to run than to build otherwise. diff --git a/neqo-bin/benches/main.rs b/neqo-bin/benches/main.rs index dbdb437709..c1155ccf26 100644 --- a/neqo-bin/benches/main.rs +++ b/neqo-bin/benches/main.rs @@ -4,7 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{env, path::PathBuf, str::FromStr}; +use std::{env, path::PathBuf, str::FromStr as _}; use criterion::{criterion_group, criterion_main, BatchSize, Criterion, Throughput}; use neqo_bin::{client, server}; diff --git a/neqo-bin/src/bin/client.rs b/neqo-bin/src/bin/client.rs index 25c0e8753f..51ecab6a77 100644 --- a/neqo-bin/src/bin/client.rs +++ b/neqo-bin/src/bin/client.rs @@ -4,7 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use clap::Parser; +use clap::Parser as _; #[tokio::main] async fn main() -> Result<(), neqo_bin::client::Error> { diff --git a/neqo-bin/src/bin/server.rs b/neqo-bin/src/bin/server.rs index e9b30261e4..022a950f2f 100644 --- a/neqo-bin/src/bin/server.rs +++ b/neqo-bin/src/bin/server.rs @@ -4,7 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use clap::Parser; +use clap::Parser as _; #[tokio::main] async fn main() -> Result<(), neqo_bin::server::Error> { diff --git a/neqo-bin/src/client/http09.rs b/neqo-bin/src/client/http09.rs index f7f62bf57a..87ab6b0c7b 100644 --- a/neqo-bin/src/client/http09.rs +++ b/neqo-bin/src/client/http09.rs @@ -10,14 +10,14 @@ use std::{ cell::RefCell, collections::{HashMap, VecDeque}, fs::File, - io::{BufWriter, Write}, + io::{BufWriter, Write as _}, net::SocketAddr, path::PathBuf, rc::Rc, time::Instant, }; -use neqo_common::{event::Provider, qdebug, qinfo, qwarn, Datagram}; +use neqo_common::{event::Provider as _, qdebug, qinfo, qwarn, Datagram}; use neqo_crypto::{AuthenticationStatus, ResumptionToken}; use neqo_transport::{ CloseReason, Connection, ConnectionEvent, ConnectionIdGenerator, EmptyConnectionIdGenerator, diff --git a/neqo-bin/src/client/http3.rs b/neqo-bin/src/client/http3.rs index 3a5a777cb6..33e9a9243b 100644 --- a/neqo-bin/src/client/http3.rs +++ b/neqo-bin/src/client/http3.rs @@ -11,14 +11,14 @@ use std::{ collections::{HashMap, VecDeque}, fmt::Display, fs::File, - io::{BufWriter, Write}, + io::{BufWriter, Write as _}, net::SocketAddr, path::PathBuf, rc::Rc, time::Instant, }; -use neqo_common::{event::Provider, hex, qdebug, qinfo, qwarn, Datagram, Header}; +use neqo_common::{event::Provider as _, hex, qdebug, qinfo, qwarn, Datagram, Header}; use neqo_crypto::{AuthenticationStatus, ResumptionToken}; use neqo_http3::{Error, Http3Client, Http3ClientEvent, Http3Parameters, Http3State, Priority}; use neqo_transport::{ diff --git a/neqo-bin/src/client/mod.rs b/neqo-bin/src/client/mod.rs index cb1d829fd4..fe0c32ae3f 100644 --- a/neqo-bin/src/client/mod.rs +++ b/neqo-bin/src/client/mod.rs @@ -11,7 +11,7 @@ use std::{ fmt::{self, Display}, fs::{create_dir_all, File, OpenOptions}, io::{self, BufWriter}, - net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, ToSocketAddrs}, + net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, ToSocketAddrs as _}, path::PathBuf, pin::Pin, process::exit, @@ -21,7 +21,7 @@ use std::{ use clap::Parser; use futures::{ future::{select, Either}, - FutureExt, TryFutureExt, + FutureExt as _, TryFutureExt as _, }; use neqo_common::{qdebug, qerror, qinfo, qlog::NeqoQlog, qwarn, Datagram, Role}; use neqo_crypto::{ @@ -182,7 +182,7 @@ impl Args { #[cfg(any(test, feature = "bench"))] #[allow(clippy::missing_panics_doc)] pub fn new(requests: &[usize], upload: bool) -> Self { - use std::str::FromStr; + use std::str::FromStr as _; Self { shared: crate::SharedArgs::default(), urls: requests diff --git a/neqo-bin/src/lib.rs b/neqo-bin/src/lib.rs index 4ae71b359c..029d0086c6 100644 --- a/neqo-bin/src/lib.rs +++ b/neqo-bin/src/lib.rs @@ -9,7 +9,7 @@ use std::{ fmt::{self, Display}, - net::{SocketAddr, ToSocketAddrs}, + net::{SocketAddr, ToSocketAddrs as _}, path::PathBuf, time::Duration, }; @@ -266,7 +266,7 @@ impl std::error::Error for Error {} #[cfg(test)] mod tests { - use std::{fs, path::PathBuf, str::FromStr, time::SystemTime}; + use std::{fs, path::PathBuf, str::FromStr as _, time::SystemTime}; use crate::{client, server}; diff --git a/neqo-bin/src/server/http09.rs b/neqo-bin/src/server/http09.rs index e183a1b045..a4a4b6a6c3 100644 --- a/neqo-bin/src/server/http09.rs +++ b/neqo-bin/src/server/http09.rs @@ -6,7 +6,7 @@ use std::{borrow::Cow, cell::RefCell, collections::HashMap, fmt::Display, rc::Rc, time::Instant}; -use neqo_common::{event::Provider, hex, qdebug, qerror, qinfo, qwarn, Datagram}; +use neqo_common::{event::Provider as _, hex, qdebug, qerror, qinfo, qwarn, Datagram}; use neqo_crypto::{generate_ech_keys, random, AllowZeroRtt, AntiReplay}; use neqo_http3::Error; use neqo_transport::{ diff --git a/neqo-bin/src/server/http3.rs b/neqo-bin/src/server/http3.rs index bf5a3592e3..c22b95c6fd 100644 --- a/neqo-bin/src/server/http3.rs +++ b/neqo-bin/src/server/http3.rs @@ -12,7 +12,7 @@ use std::{ time::Instant, }; -use neqo_common::{header::HeadersExt, hex, qdebug, qerror, qinfo, Datagram, Header}; +use neqo_common::{header::HeadersExt as _, hex, qdebug, qerror, qinfo, Datagram, Header}; use neqo_crypto::{generate_ech_keys, random, AntiReplay}; use neqo_http3::{ Http3OrWebTransportStream, Http3Parameters, Http3Server, Http3ServerEvent, StreamId, diff --git a/neqo-bin/src/server/mod.rs b/neqo-bin/src/server/mod.rs index bcce011ec6..3f9de917d4 100644 --- a/neqo-bin/src/server/mod.rs +++ b/neqo-bin/src/server/mod.rs @@ -10,7 +10,7 @@ use std::{ cell::RefCell, fmt::{self, Display}, fs, io, - net::{SocketAddr, ToSocketAddrs}, + net::{SocketAddr, ToSocketAddrs as _}, path::PathBuf, pin::Pin, process::exit, @@ -21,7 +21,7 @@ use std::{ use clap::Parser; use futures::{ future::{select, select_all, Either}, - FutureExt, + FutureExt as _, }; use neqo_common::{qdebug, qerror, qinfo, qwarn, Datagram}; use neqo_crypto::{ @@ -122,7 +122,7 @@ pub struct Args { #[cfg(any(test, feature = "bench"))] impl Default for Args { fn default() -> Self { - use std::str::FromStr; + use std::str::FromStr as _; Self { shared: crate::SharedArgs::default(), hosts: vec!["[::]:12345".to_string()], diff --git a/neqo-common/src/fuzz.rs b/neqo-common/src/fuzz.rs index d0a35a49ae..b7fdd13f2e 100644 --- a/neqo-common/src/fuzz.rs +++ b/neqo-common/src/fuzz.rs @@ -7,7 +7,7 @@ use std::{ collections::hash_map::DefaultHasher, fs::File, - hash::{Hash, Hasher}, + hash::{Hash as _, Hasher as _}, io::Write, path::Path, }; diff --git a/neqo-common/src/lib.rs b/neqo-common/src/lib.rs index 5b212f9998..1e7a53ad19 100644 --- a/neqo-common/src/lib.rs +++ b/neqo-common/src/lib.rs @@ -18,7 +18,7 @@ pub mod log; pub mod qlog; pub mod tos; -use std::fmt::Write; +use std::fmt::Write as _; use enum_map::Enum; diff --git a/neqo-common/src/log.rs b/neqo-common/src/log.rs index 04028a26bd..c847b003da 100644 --- a/neqo-common/src/log.rs +++ b/neqo-common/src/log.rs @@ -7,7 +7,7 @@ #![allow(clippy::module_name_repetitions)] use std::{ - io::Write, + io::Write as _, sync::{Once, OnceLock}, time::{Duration, Instant}, }; diff --git a/neqo-http3/src/connection.rs b/neqo-http3/src/connection.rs index b7831a14b4..32a923656c 100644 --- a/neqo-http3/src/connection.rs +++ b/neqo-http3/src/connection.rs @@ -35,7 +35,7 @@ use crate::{ qpack_decoder_receiver::DecoderRecvStream, qpack_encoder_receiver::EncoderRecvStream, recv_message::{RecvMessage, RecvMessageInfo}, - request_target::{AsRequestTarget, RequestTarget}, + request_target::{AsRequestTarget, RequestTarget as _}, send_message::SendMessage, settings::{HSettingType, HSettings, HttpZeroRttChecker}, stream_type_reader::NewStreamHeadReader, diff --git a/neqo-http3/src/connection_client.rs b/neqo-http3/src/connection_client.rs index b9f7db52a4..6ef11bf760 100644 --- a/neqo-http3/src/connection_client.rs +++ b/neqo-http3/src/connection_client.rs @@ -1280,7 +1280,7 @@ impl EventProvider for Http3Client { mod tests { use std::{mem, time::Duration}; - use neqo_common::{event::Provider, qtrace, Datagram, Decoder, Encoder}; + use neqo_common::{event::Provider as _, qtrace, Datagram, Decoder, Encoder}; use neqo_crypto::{AllowZeroRtt, AntiReplay, ResumptionToken}; use neqo_qpack::{encoder::QPackEncoder, QpackSettings}; use neqo_transport::{ @@ -1301,7 +1301,7 @@ mod tests { frames::{HFrame, H3_FRAME_TYPE_SETTINGS, H3_RESERVED_FRAME_TYPES}, qpack_encoder_receiver::EncoderRecvStream, settings::{HSetting, HSettingType, H3_RESERVED_SETTINGS}, - Http3Server, Priority, PushId, RecvStream, + Http3Server, Priority, PushId, RecvStream as _, }; fn assert_closed(client: &Http3Client, expected: &Error) { diff --git a/neqo-http3/src/connection_server.rs b/neqo-http3/src/connection_server.rs index f06cf272ba..c4e9b353c0 100644 --- a/neqo-http3/src/connection_server.rs +++ b/neqo-http3/src/connection_server.rs @@ -6,7 +6,7 @@ use std::{rc::Rc, time::Instant}; -use neqo_common::{event::Provider, qdebug, qinfo, qtrace, Header, MessageType, Role}; +use neqo_common::{event::Provider as _, qdebug, qinfo, qtrace, Header, MessageType, Role}; use neqo_transport::{ AppError, Connection, ConnectionEvent, DatagramTracking, StreamId, StreamType, }; diff --git a/neqo-http3/src/features/extended_connect/tests/webtransport/mod.rs b/neqo-http3/src/features/extended_connect/tests/webtransport/mod.rs index 718a2715c0..679bea1045 100644 --- a/neqo-http3/src/features/extended_connect/tests/webtransport/mod.rs +++ b/neqo-http3/src/features/extended_connect/tests/webtransport/mod.rs @@ -10,7 +10,7 @@ mod sessions; mod streams; use std::{cell::RefCell, rc::Rc, time::Duration}; -use neqo_common::{event::Provider, header::HeadersExt}; +use neqo_common::{event::Provider as _, header::HeadersExt as _}; use neqo_crypto::AuthenticationStatus; use neqo_transport::{ConnectionParameters, Pmtud, StreamId, StreamType}; use test_fixture::{ diff --git a/neqo-http3/src/features/extended_connect/tests/webtransport/negotiation.rs b/neqo-http3/src/features/extended_connect/tests/webtransport/negotiation.rs index 82ec1328a7..b3cf405936 100644 --- a/neqo-http3/src/features/extended_connect/tests/webtransport/negotiation.rs +++ b/neqo-http3/src/features/extended_connect/tests/webtransport/negotiation.rs @@ -6,7 +6,7 @@ use std::time::Duration; -use neqo_common::{event::Provider, Encoder}; +use neqo_common::{event::Provider as _, Encoder}; use neqo_crypto::AuthenticationStatus; use neqo_transport::{CloseReason, Connection, StreamType}; use test_fixture::{default_server_h3, now}; diff --git a/neqo-http3/src/features/extended_connect/tests/webtransport/sessions.rs b/neqo-http3/src/features/extended_connect/tests/webtransport/sessions.rs index 83650b4b9e..6b69b430c7 100644 --- a/neqo-http3/src/features/extended_connect/tests/webtransport/sessions.rs +++ b/neqo-http3/src/features/extended_connect/tests/webtransport/sessions.rs @@ -6,7 +6,7 @@ use std::mem; -use neqo_common::{event::Provider, header::HeadersExt, Encoder}; +use neqo_common::{event::Provider as _, header::HeadersExt as _, Encoder}; use neqo_transport::StreamType; use test_fixture::now; diff --git a/neqo-http3/src/frames/hframe.rs b/neqo-http3/src/frames/hframe.rs index 05c3e240fe..e866f095d5 100644 --- a/neqo-http3/src/frames/hframe.rs +++ b/neqo-http3/src/frames/hframe.rs @@ -4,7 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{fmt::Debug, io::Write}; +use std::{fmt::Debug, io::Write as _}; use neqo_common::{Decoder, Encoder}; use neqo_crypto::random; diff --git a/neqo-http3/src/headers_checks.rs b/neqo-http3/src/headers_checks.rs index 7ea880e222..245e0f6f11 100644 --- a/neqo-http3/src/headers_checks.rs +++ b/neqo-http3/src/headers_checks.rs @@ -5,7 +5,7 @@ // except according to those terms. use enumset::{enum_set, EnumSet, EnumSetType}; -use neqo_common::{header::HeadersExt, Header}; +use neqo_common::{header::HeadersExt as _, Header}; use crate::{Error, MessageType, Res}; diff --git a/neqo-http3/src/recv_message.rs b/neqo-http3/src/recv_message.rs index c0757d7bb8..5b2db8a2a1 100644 --- a/neqo-http3/src/recv_message.rs +++ b/neqo-http3/src/recv_message.rs @@ -6,7 +6,7 @@ use std::{cell::RefCell, cmp::min, collections::VecDeque, fmt::Debug, rc::Rc}; -use neqo_common::{header::HeadersExt, qdebug, qinfo, qtrace, Header}; +use neqo_common::{header::HeadersExt as _, qdebug, qinfo, qtrace, Header}; use neqo_qpack::decoder::QPackDecoder; use neqo_transport::{Connection, StreamId}; diff --git a/neqo-http3/src/server.rs b/neqo-http3/src/server.rs index 8a5dc8a2f3..f923ec0c2f 100644 --- a/neqo-http3/src/server.rs +++ b/neqo-http3/src/server.rs @@ -315,7 +315,7 @@ mod tests { ops::{Deref, DerefMut}, }; - use neqo_common::{event::Provider, Encoder}; + use neqo_common::{event::Provider as _, Encoder}; use neqo_crypto::{AuthenticationStatus, ZeroRttCheckResult, ZeroRttChecker}; use neqo_qpack::{encoder::QPackEncoder, QpackSettings}; use neqo_transport::{ diff --git a/neqo-http3/src/stream_type_reader.rs b/neqo-http3/src/stream_type_reader.rs index 5c5fe75943..eda564bd45 100644 --- a/neqo-http3/src/stream_type_reader.rs +++ b/neqo-http3/src/stream_type_reader.rs @@ -253,7 +253,7 @@ mod tests { use crate::{ control_stream_local::HTTP3_UNI_STREAM_TYPE_CONTROL, frames::{H3_FRAME_TYPE_HEADERS, H3_FRAME_TYPE_SETTINGS}, - CloseType, Error, NewStreamType, PushId, ReceiveOutput, RecvStream, Res, + CloseType, Error, NewStreamType, PushId, ReceiveOutput, RecvStream as _, Res, }; struct Test { diff --git a/neqo-http3/tests/httpconn.rs b/neqo-http3/tests/httpconn.rs index 2e52739fcb..72a11c7235 100644 --- a/neqo-http3/tests/httpconn.rs +++ b/neqo-http3/tests/httpconn.rs @@ -9,7 +9,7 @@ use std::{ time::{Duration, Instant}, }; -use neqo_common::{event::Provider, qtrace, Datagram}; +use neqo_common::{event::Provider as _, qtrace, Datagram}; use neqo_crypto::{AuthenticationStatus, ResumptionToken}; use neqo_http3::{ Header, Http3Client, Http3ClientEvent, Http3OrWebTransportStream, Http3Parameters, Http3Server, diff --git a/neqo-http3/tests/priority.rs b/neqo-http3/tests/priority.rs index 318a20577f..300d72dccd 100644 --- a/neqo-http3/tests/priority.rs +++ b/neqo-http3/tests/priority.rs @@ -6,7 +6,7 @@ use std::time::Instant; -use neqo_common::event::Provider; +use neqo_common::event::Provider as _; use neqo_crypto::AuthenticationStatus; use neqo_http3::{ Header, Http3Client, Http3ClientEvent, Http3Server, Http3ServerEvent, Http3State, Priority, diff --git a/neqo-http3/tests/send_message.rs b/neqo-http3/tests/send_message.rs index 19a47cde7c..469e79ab75 100644 --- a/neqo-http3/tests/send_message.rs +++ b/neqo-http3/tests/send_message.rs @@ -6,7 +6,7 @@ use std::sync::OnceLock; -use neqo_common::event::Provider; +use neqo_common::event::Provider as _; use neqo_crypto::AuthenticationStatus; use neqo_http3::{ Error, Header, Http3Client, Http3ClientEvent, Http3OrWebTransportStream, Http3Server, diff --git a/neqo-http3/tests/webtransport.rs b/neqo-http3/tests/webtransport.rs index 1d29b702bc..6291020f58 100644 --- a/neqo-http3/tests/webtransport.rs +++ b/neqo-http3/tests/webtransport.rs @@ -6,7 +6,7 @@ use std::{cell::RefCell, rc::Rc}; -use neqo_common::{event::Provider, header::HeadersExt}; +use neqo_common::{event::Provider as _, header::HeadersExt as _}; use neqo_crypto::AuthenticationStatus; use neqo_http3::{ Http3Client, Http3ClientEvent, Http3OrWebTransportStream, Http3Parameters, Http3Server, diff --git a/neqo-qpack/src/header_block.rs b/neqo-qpack/src/header_block.rs index d2eab95e3e..5a48543ca9 100644 --- a/neqo-qpack/src/header_block.rs +++ b/neqo-qpack/src/header_block.rs @@ -6,7 +6,7 @@ use std::{ mem, - ops::{Deref, Div}, + ops::{Deref, Div as _}, }; use neqo_common::{qtrace, Header}; diff --git a/neqo-qpack/src/reader.rs b/neqo-qpack/src/reader.rs index d03b118cfa..63b47f25fe 100644 --- a/neqo-qpack/src/reader.rs +++ b/neqo-qpack/src/reader.rs @@ -379,7 +379,7 @@ mod tests { use test_receiver::TestReceiver; use super::{ - parse_utf8, str, test_receiver, Error, IntReader, LiteralReader, ReadByte, + parse_utf8, str, test_receiver, Error, IntReader, LiteralReader, ReadByte as _, ReceiverBufferWrapper, Res, }; diff --git a/neqo-transport/src/cc/tests/cubic.rs b/neqo-transport/src/cc/tests/cubic.rs index 18a4f39a37..c2fc0c6431 100644 --- a/neqo-transport/src/cc/tests/cubic.rs +++ b/neqo-transport/src/cc/tests/cubic.rs @@ -23,7 +23,7 @@ use crate::{ convert_to_f64, Cubic, CUBIC_ALPHA, CUBIC_BETA_USIZE_DIVIDEND, CUBIC_BETA_USIZE_DIVISOR, CUBIC_C, CUBIC_FAST_CONVERGENCE, }, - CongestionControl, + CongestionControl as _, }, packet::PacketType, pmtud::Pmtud, diff --git a/neqo-transport/src/cc/tests/new_reno.rs b/neqo-transport/src/cc/tests/new_reno.rs index d629d26b32..640e59e800 100644 --- a/neqo-transport/src/cc/tests/new_reno.rs +++ b/neqo-transport/src/cc/tests/new_reno.rs @@ -13,7 +13,7 @@ use test_fixture::now; use super::{IP_ADDR, MTU, RTT}; use crate::{ - cc::{new_reno::NewReno, ClassicCongestionControl, CongestionControl}, + cc::{new_reno::NewReno, ClassicCongestionControl, CongestionControl as _}, packet::PacketType, pmtud::Pmtud, recovery::SentPacket, diff --git a/neqo-transport/src/cid.rs b/neqo-transport/src/cid.rs index 0e3144a707..666a3cf3a6 100644 --- a/neqo-transport/src/cid.rs +++ b/neqo-transport/src/cid.rs @@ -10,7 +10,7 @@ use std::{ borrow::Borrow, cell::{Ref, RefCell}, cmp::{max, min}, - ops::Deref, + ops::Deref as _, rc::Rc, }; diff --git a/neqo-transport/src/connection/dump.rs b/neqo-transport/src/connection/dump.rs index 10e1025524..35e9e848ea 100644 --- a/neqo-transport/src/connection/dump.rs +++ b/neqo-transport/src/connection/dump.rs @@ -7,7 +7,7 @@ // Enable just this file for logging to just see packets. // e.g. "RUST_LOG=neqo_transport::dump neqo-client ..." -use std::fmt::Write; +use std::fmt::Write as _; use neqo_common::{qdebug, Decoder, IpTos}; diff --git a/neqo-transport/src/connection/tests/datagram.rs b/neqo-transport/src/connection/tests/datagram.rs index 7fb03aba15..b80a348bca 100644 --- a/neqo-transport/src/connection/tests/datagram.rs +++ b/neqo-transport/src/connection/tests/datagram.rs @@ -6,7 +6,7 @@ use std::{cell::RefCell, rc::Rc}; -use neqo_common::event::Provider; +use neqo_common::event::Provider as _; use static_assertions::const_assert; use test_fixture::now; diff --git a/neqo-transport/src/connection/tests/handshake.rs b/neqo-transport/src/connection/tests/handshake.rs index dcdbd9e276..1e2ee5937d 100644 --- a/neqo-transport/src/connection/tests/handshake.rs +++ b/neqo-transport/src/connection/tests/handshake.rs @@ -12,7 +12,7 @@ use std::{ time::Duration, }; -use neqo_common::{event::Provider, qdebug, Datagram}; +use neqo_common::{event::Provider as _, qdebug, Datagram}; use neqo_crypto::{ constants::TLS_CHACHA20_POLY1305_SHA256, generate_ech_keys, AuthenticationStatus, }; diff --git a/neqo-transport/src/connection/tests/migration.rs b/neqo-transport/src/connection/tests/migration.rs index 9e05c9d289..1f83ced0b6 100644 --- a/neqo-transport/src/connection/tests/migration.rs +++ b/neqo-transport/src/connection/tests/migration.rs @@ -35,7 +35,7 @@ use crate::{ pmtud::Pmtud, stats::FrameStats, tparams::{self, PreferredAddress, TransportParameter}, - CloseReason, ConnectionId, ConnectionIdDecoder, ConnectionIdGenerator, ConnectionIdRef, + CloseReason, ConnectionId, ConnectionIdDecoder as _, ConnectionIdGenerator, ConnectionIdRef, ConnectionParameters, EmptyConnectionIdGenerator, Error, MIN_INITIAL_PACKET_SIZE, }; diff --git a/neqo-transport/src/connection/tests/mod.rs b/neqo-transport/src/connection/tests/mod.rs index 5accfab36d..7e75ac1379 100644 --- a/neqo-transport/src/connection/tests/mod.rs +++ b/neqo-transport/src/connection/tests/mod.rs @@ -14,7 +14,7 @@ use std::{ }; use enum_map::enum_map; -use neqo_common::{event::Provider, qdebug, qtrace, Datagram, Decoder, Role}; +use neqo_common::{event::Provider as _, qdebug, qtrace, Datagram, Decoder, Role}; use neqo_crypto::{random, AllowZeroRtt, AuthenticationStatus, ResumptionToken}; use test_fixture::{fixture_init, new_neqo_qlog, now, DEFAULT_ADDR}; diff --git a/neqo-transport/src/connection/tests/priority.rs b/neqo-transport/src/connection/tests/priority.rs index 7bf9beedd4..9ae9ae4778 100644 --- a/neqo-transport/src/connection/tests/priority.rs +++ b/neqo-transport/src/connection/tests/priority.rs @@ -6,7 +6,7 @@ use std::{cell::RefCell, mem, rc::Rc}; -use neqo_common::event::Provider; +use neqo_common::event::Provider as _; use test_fixture::now; use super::{ diff --git a/neqo-transport/src/connection/tests/stream.rs b/neqo-transport/src/connection/tests/stream.rs index 89e1773dae..5b81e65653 100644 --- a/neqo-transport/src/connection/tests/stream.rs +++ b/neqo-transport/src/connection/tests/stream.rs @@ -6,7 +6,7 @@ use std::{cmp::max, collections::HashMap, mem}; -use neqo_common::{event::Provider, qdebug}; +use neqo_common::{event::Provider as _, qdebug}; use test_fixture::now; use super::{ diff --git a/neqo-transport/src/connection/tests/vn.rs b/neqo-transport/src/connection/tests/vn.rs index 2b0677f164..896944be0a 100644 --- a/neqo-transport/src/connection/tests/vn.rs +++ b/neqo-transport/src/connection/tests/vn.rs @@ -6,7 +6,7 @@ use std::{mem, time::Duration}; -use neqo_common::{event::Provider, Decoder, Encoder}; +use neqo_common::{event::Provider as _, Decoder, Encoder}; use test_fixture::{assertions, datagram, now}; use super::{ diff --git a/neqo-transport/src/connection/tests/zerortt.rs b/neqo-transport/src/connection/tests/zerortt.rs index 1370e3f659..80929e5f72 100644 --- a/neqo-transport/src/connection/tests/zerortt.rs +++ b/neqo-transport/src/connection/tests/zerortt.rs @@ -6,7 +6,7 @@ use std::{cell::RefCell, rc::Rc, time::Duration}; -use neqo_common::{event::Provider, qdebug}; +use neqo_common::{event::Provider as _, qdebug}; use neqo_crypto::{AllowZeroRtt, AntiReplay}; use test_fixture::{assertions, now}; diff --git a/neqo-transport/src/events.rs b/neqo-transport/src/events.rs index 68ef0d6798..ca7f57bf5d 100644 --- a/neqo-transport/src/events.rs +++ b/neqo-transport/src/events.rs @@ -254,7 +254,7 @@ impl EventProvider for ConnectionEvents { #[cfg(test)] mod tests { - use neqo_common::event::Provider; + use neqo_common::event::Provider as _; use crate::{CloseReason, ConnectionEvent, ConnectionEvents, Error, State, StreamId}; diff --git a/neqo-transport/src/qlog.rs b/neqo-transport/src/qlog.rs index b8589b6bba..81060e890b 100644 --- a/neqo-transport/src/qlog.rs +++ b/neqo-transport/src/qlog.rs @@ -9,7 +9,7 @@ #![allow(clippy::module_name_repetitions)] use std::{ - ops::{Deref, RangeInclusive}, + ops::{Deref as _, RangeInclusive}, time::{Duration, Instant}, }; diff --git a/neqo-transport/src/recovery/mod.rs b/neqo-transport/src/recovery/mod.rs index ddea357c8c..47f4a896d5 100644 --- a/neqo-transport/src/recovery/mod.rs +++ b/neqo-transport/src/recovery/mod.rs @@ -16,7 +16,7 @@ mod token; use std::{ cmp::{max, min}, - convert::TryFrom, + convert::TryFrom as _, ops::RangeInclusive, time::{Duration, Instant}, }; @@ -969,7 +969,7 @@ impl ::std::fmt::Display for LossRecovery { mod tests { use std::{ cell::RefCell, - convert::TryInto, + convert::TryInto as _, ops::{Deref, DerefMut, RangeInclusive}, rc::Rc, time::{Duration, Instant}, diff --git a/neqo-transport/src/recovery/sent.rs b/neqo-transport/src/recovery/sent.rs index 7c461f21b2..f465bcb8e6 100644 --- a/neqo-transport/src/recovery/sent.rs +++ b/neqo-transport/src/recovery/sent.rs @@ -305,7 +305,7 @@ impl SentPackets { mod tests { use std::{ cell::OnceCell, - convert::TryFrom, + convert::TryFrom as _, time::{Duration, Instant}, }; diff --git a/neqo-transport/src/send_stream.rs b/neqo-transport/src/send_stream.rs index 323215cd85..2c945b137b 100644 --- a/neqo-transport/src/send_stream.rs +++ b/neqo-transport/src/send_stream.rs @@ -1793,7 +1793,7 @@ pub struct SendStreamRecoveryToken { mod tests { use std::{cell::RefCell, collections::VecDeque, num::NonZeroUsize, rc::Rc}; - use neqo_common::{event::Provider, hex_with_len, qtrace, Encoder}; + use neqo_common::{event::Provider as _, hex_with_len, qtrace, Encoder}; use super::SendStreamRecoveryToken; use crate::{ diff --git a/neqo-transport/src/server.rs b/neqo-transport/src/server.rs index 154ad17ed3..2c13735806 100644 --- a/neqo-transport/src/server.rs +++ b/neqo-transport/src/server.rs @@ -17,8 +17,8 @@ use std::{ }; use neqo_common::{ - event::Provider, hex, qdebug, qerror, qinfo, qlog::NeqoQlog, qtrace, qwarn, Datagram, IpTos, - Role, + event::Provider as _, hex, qdebug, qerror, qinfo, qlog::NeqoQlog, qtrace, qwarn, Datagram, + IpTos, Role, }; use neqo_crypto::{ encode_ech_config, AntiReplay, Cipher, PrivateKey, PublicKey, ZeroRttCheckResult, diff --git a/neqo-transport/tests/common/mod.rs b/neqo-transport/tests/common/mod.rs index a16c5f2c92..794edd7d97 100644 --- a/neqo-transport/tests/common/mod.rs +++ b/neqo-transport/tests/common/mod.rs @@ -8,7 +8,7 @@ use std::{cell::RefCell, mem, ops::Range, rc::Rc}; -use neqo_common::{event::Provider, hex_with_len, qtrace, Datagram, Decoder, Role}; +use neqo_common::{event::Provider as _, hex_with_len, qtrace, Datagram, Decoder, Role}; use neqo_crypto::{ constants::{TLS_AES_128_GCM_SHA256, TLS_VERSION_1_3}, hkdf, diff --git a/test-fixture/src/lib.rs b/test-fixture/src/lib.rs index b9e869c5b3..2efb21cfef 100644 --- a/test-fixture/src/lib.rs +++ b/test-fixture/src/lib.rs @@ -20,7 +20,7 @@ use std::{ }; use neqo_common::{ - event::Provider, + event::Provider as _, hex, qlog::{new_trace, NeqoQlog}, qtrace, Datagram, Decoder, IpTosEcn, Role, diff --git a/test-fixture/src/sim/connection.rs b/test-fixture/src/sim/connection.rs index 8ca75a53ff..1291f1cf9f 100644 --- a/test-fixture/src/sim/connection.rs +++ b/test-fixture/src/sim/connection.rs @@ -12,7 +12,7 @@ use std::{ time::Instant, }; -use neqo_common::{event::Provider, qdebug, qinfo, qtrace, Datagram}; +use neqo_common::{event::Provider as _, qdebug, qinfo, qtrace, Datagram}; use neqo_crypto::AuthenticationStatus; use neqo_transport::{ Connection, ConnectionEvent, ConnectionParameters, Output, State, StreamId, StreamType, From df86bf0e19e9944b129372037c711077eaa4eab8 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Fri, 10 Jan 2025 07:56:38 +0200 Subject: [PATCH 12/18] chore: Remove some unused files (#2290) --- .pre-commit-config.yaml | 22 -- .taskcluster.yml.disabled | 295 ------------------ hooks/check_internal_errors | 46 --- hooks/pre-commit | 56 ---- taskcluster/config.yml | 27 -- taskcluster/docker/linux/Dockerfile | 30 -- taskcluster/kinds/docker-image/kind.yml | 10 - taskcluster/kinds/hello/kind.yml | 17 - .../neqo_taskgraph/transforms/hello.py | 28 -- 9 files changed, 531 deletions(-) delete mode 100644 .pre-commit-config.yaml delete mode 100644 .taskcluster.yml.disabled delete mode 100755 hooks/check_internal_errors delete mode 100755 hooks/pre-commit delete mode 100644 taskcluster/config.yml delete mode 100644 taskcluster/docker/linux/Dockerfile delete mode 100644 taskcluster/kinds/docker-image/kind.yml delete mode 100644 taskcluster/kinds/hello/kind.yml delete mode 100644 taskcluster/neqo_taskgraph/transforms/hello.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index e105128db5..0000000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,22 +0,0 @@ -repos: -- repo: https://github.com/gitleaks/gitleaks - rev: v8.16.3 - hooks: - - id: gitleaks -- repo: https://github.com/jumanjihouse/pre-commit-hooks - rev: 3.0.0 - hooks: - - id: shellcheck -- repo: https://github.com/pocc/pre-commit-hooks - rev: v1.3.5 - hooks: - - id: cpplint -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 - hooks: - - id: end-of-file-fixer - - id: trailing-whitespace -# - repo: https://github.com/pylint-dev/pylint -# rev: v2.17.2 -# hooks: -# - id: pylint diff --git a/.taskcluster.yml.disabled b/.taskcluster.yml.disabled deleted file mode 100644 index 8f3e6f1d0b..0000000000 --- a/.taskcluster.yml.disabled +++ /dev/null @@ -1,295 +0,0 @@ -# yamllint disable rule:line-length -# This file is rendered via JSON-e by -# - github events - https://github.com/taskcluster/taskcluster/tree/main/services/github -# - cron tasks - https://hg.mozilla.org/ci/ci-admin/file/default/build-decision/ -# - action tasks - taskcluster/taskgraph/actions/registry.py ---- -version: 1 -reporting: checks-v1 -autoCancelPreviousChecks: true -policy: - pullRequests: public -tasks: - - $let: - trustDomain: "mozilla" - level: "1" - ownerEmail: - $switch: - 'tasks_for == "github-push"': '${event.pusher.email}' - 'tasks_for == "github-release"': '${event.sender.login}@users.noreply.github.com' - 'tasks_for[:19] == "github-pull-request"': '${event.pull_request.user.login}@users.noreply.github.com' - 'tasks_for in ["cron", "action", "pr-action"]': '${tasks_for}@noreply.mozilla.org' - baseRepoUrl: - $switch: - 'tasks_for[:19] == "github-pull-request"': '${event.pull_request.base.repo.html_url}' - 'tasks_for in ["cron", "action"]': '${repository.url}' - 'tasks_for == "pr-action"': '${repository.base_url}' - $default: '${event.repository.html_url}' - repoUrl: - $switch: - 'tasks_for[:19] == "github-pull-request"': '${event.pull_request.head.repo.html_url}' - 'tasks_for in ["cron", "action", "pr-action"]': '${repository.url}' - $default: '${event.repository.html_url}' - project: - $switch: - 'tasks_for in ["github-push", "github-release"]': '${event.repository.name}' - 'tasks_for[:19] == "github-pull-request"': '${event.pull_request.head.repo.name}' - 'tasks_for in ["cron", "action", "pr-action"]': '${repository.project}' - head_branch: - $switch: - 'tasks_for[:19] == "github-pull-request"': ${event.pull_request.head.ref} - 'tasks_for == "github-push"': ${event.ref} - 'tasks_for == "github-release"': '${event.release.target_commitish}' - 'tasks_for in ["cron", "action", "pr-action"]': '${push.branch}' - base_ref: - $switch: - 'tasks_for[:19] == "github-pull-request"': ${event.pull_request.base.ref} - 'tasks_for == "github-push" && event.base_ref': ${event.base_ref} - 'tasks_for == "github-push" && !(event.base_ref)': ${event.ref} - 'tasks_for == "github-release"': '' - 'tasks_for in ["cron", "action"]': '${push.branch}' - 'tasks_for == "pr-action"': '${push.base_branch}' - head_ref: - $switch: - 'tasks_for[:19] == "github-pull-request"': ${event.pull_request.head.ref} - 'tasks_for == "github-push"': ${event.ref} - 'tasks_for == "github-release"': ${event.release.tag_name} - 'tasks_for in ["cron", "action", "pr-action"]': '${push.branch}' - base_sha: - $switch: - 'tasks_for == "github-push"': '${event.before}' - 'tasks_for == "github-release"': '${event.release.target_commitish}' - 'tasks_for[:19] == "github-pull-request"': '${event.pull_request.base.sha}' - 'tasks_for in ["cron", "action", "pr-action"]': '${push.revision}' - head_sha: - $switch: - 'tasks_for == "github-push"': '${event.after}' - 'tasks_for == "github-release"': '${event.release.tag_name}' - 'tasks_for[:19] == "github-pull-request"': '${event.pull_request.head.sha}' - 'tasks_for in ["cron", "action", "pr-action"]': '${push.revision}' - ownTaskId: - $switch: - '"github" in tasks_for': {$eval: as_slugid("decision_task")} - 'tasks_for in ["cron", "action", "pr-action"]': '${ownTaskId}' - pullRequestAction: - $switch: - 'tasks_for[:19] == "github-pull-request"': ${event.action} - $default: 'UNDEFINED' - releaseAction: - $if: 'tasks_for == "github-release"' - then: ${event.action} - else: 'UNDEFINED' - isPullRequest: - $eval: 'tasks_for[:19] == "github-pull-request"' - in: - $let: - short_base_ref: - $switch: - 'base_ref[:10] == "refs/tags/"': '${base_ref[10:]}' - 'base_ref[:11] == "refs/heads/"': '${base_ref[11:]}' - $default: '${base_ref}' - short_head_ref: - $switch: - 'head_ref[:10] == "refs/tags/"': '${head_ref[10:]}' - 'head_ref[:11] == "refs/heads/"': '${head_ref[11:]}' - $default: '${head_ref}' - in: - $if: > - tasks_for in ["action", "pr-action", "cron"] - || (tasks_for == "github-push" && short_head_ref == "main") - || (isPullRequest && pullRequestAction in ["opened", "reopened", "synchronize"]) - then: - taskId: {$if: 'tasks_for != "action" && tasks_for != "pr-action"', then: '${ownTaskId}'} - taskGroupId: - $if: 'tasks_for in ["action", "pr-action"]' - then: - '${action.taskGroupId}' - else: - '${ownTaskId}' # same as taskId; this is how automation identifies a decision task - schedulerId: '${trustDomain}-level-${level}' - created: {$fromNow: ''} - deadline: {$fromNow: '1 day'} - expires: {$fromNow: '1 year 1 second'} # 1 second so artifacts expire first - metadata: - $merge: - - owner: "${ownerEmail}" - source: "${repoUrl}/raw/${head_sha}/.taskcluster.yml" - - $switch: - 'tasks_for == "github-push" || isPullRequest': - name: "Decision Task" - description: 'The task that creates all of the other tasks in the task graph' - 'tasks_for == "action"': - name: "Action: ${action.title}" - description: | - ${action.description} - - Action triggered by clientID `${clientId}` - 'tasks_for == "pr-action"': - name: "PR action: ${action.title}" - description: | - ${action.description} - - PR action triggered by clientID `${clientId}` - $default: - name: "Decision Task for cron job ${cron.job_name}" - description: 'Created by a [cron task](https://firefox-ci-tc.services.mozilla.com/tasks/${cron.task_id})' - - provisionerId: "${trustDomain}-${level}" - workerType: "decision-gcp" - - tags: - $switch: - 'tasks_for == "github-push" || isPullRequest': - createdForUser: "${ownerEmail}" - kind: decision-task - 'tasks_for in ["action", "pr-action"]': - createdForUser: '${ownerEmail}' - kind: 'action-callback' - 'tasks_for == "cron"': - kind: cron-task - - routes: - $flatten: - - checks - - $switch: - 'tasks_for == "github-push"': - - "index.${trustDomain}.v2.${project}.latest.taskgraph.decision" - - "index.${trustDomain}.v2.${project}.revision.${head_sha}.taskgraph.decision" - 'tasks_for == "action"': - - "index.${trustDomain}.v2.${project}.revision.${head_sha}.taskgraph.actions.${ownTaskId}" - 'tasks_for == "cron"': - - "index.${trustDomain}.v2.${project}.latest.taskgraph.decision-${cron.job_name}" - - "index.${trustDomain}.v2.${project}.revision.${head_sha}.taskgraph.decision-${cron.job_name}" - # list each cron task on this revision, so actions can find them - - 'index.${trustDomain}.v2.${project}.revision.${head_sha}.cron.${ownTaskId}' - $default: [] - - scopes: - $switch: - 'tasks_for in ["github-push"]': - - 'assume:repo:${repoUrl[8:]}:branch:${short_head_ref}' - 'isPullRequest': - - 'assume:repo:github.com/${event.pull_request.base.repo.full_name}:${tasks_for[7:]}' - 'tasks_for == "action"': - - 'assume:repo:${repoUrl[8:]}:action:${action.action_perm}' - 'tasks_for == "pr-action"': - - 'assume:repo:${repoUrl[8:]}:pr-action:${action.action_perm}' - $default: - - 'assume:repo:${repoUrl[8:]}:cron:${cron.job_name}' - - dependencies: [] - requires: all-completed - - priority: - $switch: - 'tasks_for == "cron"': low - 'tasks_for == "github-push"|| isPullRequest': very-low - $default: lowest # tasks_for in ['action', 'pr-action'] - retries: 5 - - payload: - $let: - normProject: - $eval: 'join(split(project, "-"), "_")' - normProjectUpper: - $eval: 'uppercase(join(split(project, "-"), "_"))' - in: - env: - # run-task uses these to check out the source; the inputs to - # `taskgraph decision` are all on the command line. - $merge: - - ${normProjectUpper}_BASE_REPOSITORY: '${baseRepoUrl}' - ${normProjectUpper}_BASE_REF: '${short_base_ref}' - ${normProjectUpper}_BASE_REV: '${base_sha}' - ${normProjectUpper}_HEAD_REPOSITORY: '${repoUrl}' - ${normProjectUpper}_HEAD_REF: '${short_head_ref}' - ${normProjectUpper}_HEAD_REV: '${head_sha}' - ${normProjectUpper}_REPOSITORY_TYPE: git - REPOSITORIES: - $json: - ${normProject}: ${normProject} - - $if: 'isPullRequest' - then: - ${normProjectUpper}_PULL_REQUEST_NUMBER: '${event.pull_request.number}' - - $if: 'tasks_for in ["action", "pr-action"]' - then: - ACTION_TASK_GROUP_ID: '${action.taskGroupId}' # taskGroupId of the target task - ACTION_TASK_ID: {$json: {$eval: 'taskId'}} # taskId of the target task (JSON-encoded) - ACTION_INPUT: {$json: {$eval: 'input'}} - ACTION_CALLBACK: '${action.cb_name}' - - cache: - "${trustDomain}-project-${project}-level-${level}-checkouts-sparse-v2": /builds/worker/checkouts - - features: - taskclusterProxy: true - - image: mozillareleases/taskgraph:decision-v9.0.0@sha256:e56c7e5cd467c2ce497c344b358f68cc84a4f73f3422e507a97b397d4e617fbd - maxRunTime: 1800 - - command: - - run-task - - '--${normProject}-checkout=/builds/worker/checkouts/src' - - '--' - - bash - - -cx - - $let: - extraArgs: {$if: 'tasks_for == "cron"', then: '${cron.quoted_args}', else: ''} - in: - $if: 'tasks_for in ["action", "pr-action"]' - then: > - cd /builds/worker/checkouts/src && - ln -s /builds/worker/artifacts artifacts && - pip3 install -r requirements/base.txt && - ~/.local/bin/taskgraph action-callback - --root .taskcluster - else: > - cd /builds/worker/checkouts/src && - ln -s /builds/worker/artifacts artifacts && - ~/.local/bin/taskgraph decision - --root .taskcluster - --pushlog-id='0' - --pushdate='0' - --project='${project}' - --owner='${ownerEmail}' - --level='${level}' - --repository-type=git - --tasks-for='${tasks_for}' - --base-repository='${baseRepoUrl}' - --base-ref='${base_ref}' - --base-rev='${base_sha}' - --head-repository='${repoUrl}' - --head-ref='${head_ref}' - --head-rev='${head_sha}' - ${extraArgs} - - artifacts: - 'public': - type: 'directory' - path: '/builds/worker/artifacts' - expires: {$fromNow: '1 year'} - 'public/docker-contexts': - type: 'directory' - path: '/builds/worker/checkouts/src/docker-contexts' - # This needs to be at least the deadline of the - # decision task + the docker-image task deadlines. - # It is set to a week to allow for some time for - # debugging, but they are not useful long-term. - expires: {$fromNow: '7 day'} - - extra: - $merge: - - $if: 'tasks_for in ["action", "pr-action"]' - then: - parent: '${action.taskGroupId}' - action: - name: '${action.name}' - context: - taskGroupId: '${action.taskGroupId}' - taskId: {$eval: 'taskId'} - input: {$eval: 'input'} - clientId: {$eval: 'clientId'} - - $if: 'tasks_for == "cron"' - then: - cron: {$json: {$eval: 'cron'}} - - tasks_for: '${tasks_for}' diff --git a/hooks/check_internal_errors b/hooks/check_internal_errors deleted file mode 100755 index bd0bcb07b6..0000000000 --- a/hooks/check_internal_errors +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env bash - -set -e - -cd "$(git rev-parse --show-toplevel)" - -if [[ "$1" == "-v" ]]; then - verbose=1 - shift -else - verbose= -fi - -if [[ "$#" -ge 1 ]]; then - files=("$@") -else - files=($(find . -name '*.rs' -print | sed -e 's~^\./~~;/^target\//d')) -fi - -dirs=($(for f in "${files[@]}"; do echo "${f%%/*}"; done | uniq)) - -find_internal_errors() { - d="$1" - shift - for f in "$@"; do - if [[ "${f#$d/}" != "$f" ]]; then - sed -e '/Error::\(InternalError\|HttpInternal(\)/{s/.*[^a-zA-Z]\([a-zA-Z]*Error::[a-zA-Z]*([0-9]*)\).*/\1/;t;};d' "$f" - fi - done -} - -err=0 -for d in "${dirs[@]}"; do - all=($(find_internal_errors "$d" "${files[@]}")) - print_all() { for e in "${all[@]}"; do echo "$e"; done; } - if [[ -n "$verbose" ]]; then - echo "$d:" - print_all | sort -b | paste /dev/null /dev/stdin - fi - unique=($(print_all | sort -b | uniq)) - if [[ "${#all[@]}" -ne "${#unique[@]}" ]]; then - echo "Found ${#all[@]} internal errors, but only ${#unique[@]} unique values." 1>&2 - err=1 - fi -done -exit $err diff --git a/hooks/pre-commit b/hooks/pre-commit deleted file mode 100755 index 9166f739b3..0000000000 --- a/hooks/pre-commit +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bash -# This is a pre-commit hook that validates code formatting. -# -# Install this by running the script with an argument of "install", -# which installs a symlink to .git/hooks/precommit: -# $ ln -s ../../hooks/pre-commit .git/hooks/pre-commit - -root="$(git rev-parse --show-toplevel 2>/dev/null)" - -set -e - -# Some sanity checking. -hash cargo -[[ -n "$root" ]] - -# Installation. -if [[ "$1" == "install" ]]; then - hook="$root"/.git/hooks/pre-commit - if [[ ! -e "$hook" ]]; then - ln -s ../../hooks/pre-commit "$hook" - echo "Installed git pre-commit hook at $hook" - else - echo "Hook already installed" - fi - exit -fi - -if [[ ./neqo-crypto/bindings/bindings.toml -nt ./neqo-crypto/src/lib.rs ]]; then - echo "NSS bindings are newer than the code that uses them." - echo "Check the value of MINIMUM_NSS_VERSION in neqo-crypto/src/lib.rs" - echo "Touch neqo-crypto/src/lib.rs to remove this warning." - exit 1 -fi - -toolchain=nightly -fmtconfig="$root/.rustfmt.toml" -if ! cargo "+$toolchain" version >/dev/null; then - echo "warning: A rust $toolchain toolchain is recommended to check formatting." - toolchain=stable - fmtconfig=/dev/null -fi - -# Check formatting. -trap 'git stash pop -q' EXIT -git stash push -k -u -q -m "pre-commit stash" -if ! errors=($(cargo "+$toolchain" fmt -- --check -l --config-path="$fmtconfig")); then - echo "Formatting errors found." - echo "Run \`cargo fmt +$toolchain\` to fix the following files:" - for err in "${errors[@]}"; do - echo " $err" - done - exit 1 -fi - -# Check internal errors -./hooks/check_internal_errors diff --git a/taskcluster/config.yml b/taskcluster/config.yml deleted file mode 100644 index 2499a87931..0000000000 --- a/taskcluster/config.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -trust-domain: "mozilla" -task-priority: low - -taskgraph: - cached-task-prefix: "mozilla.v2.neqo" - repositories: - neqo: - name: "neqo" - -workers: - aliases: - b-linux: - provisioner: '{trust-domain}-{level}' - implementation: docker-worker - os: linux - worker-type: '{alias}-gcp' - images: - provisioner: '{trust-domain}-{level}' - implementation: docker-worker - os: linux - worker-type: '{alias}-gcp' - t-linux-large: - provisioner: '{trust-domain}-t' - implementation: docker-worker - os: linux - worker-type: '{alias}-gcp' diff --git a/taskcluster/docker/linux/Dockerfile b/taskcluster/docker/linux/Dockerfile deleted file mode 100644 index 187b962e81..0000000000 --- a/taskcluster/docker/linux/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -FROM alpine:latest@sha256:21dc6063fd678b478f57c0e13f47560d0ea4eeba26dfc947b2a4f81f686b9f45 -LABEL maintainer="Mozilla Release Engineering " - -# Add worker user -RUN mkdir /builds && \ - adduser -h /builds/worker -s /bin/ash -D worker && \ - mkdir /builds/worker/artifacts && \ - chown worker:worker /builds/worker/artifacts - -# Update repositories -RUN apk update - -# Setup Python -RUN apk add --no-cache python3 py3-pip && \ - python3 -m pip install --no-cache --upgrade --break-system-packages pip setuptools - -# Setup other dependencies -RUN apk add bash git - -# %include-run-task - -ENV SHELL=/bin/ash \ - HOME=/builds/worker \ - PATH=/builds/worker/.local/bin:$PATH - -VOLUME /builds/worker/checkouts -VOLUME /builds/worker/.cache - -# Set a default command useful for debugging -CMD ["/bin/ash"] diff --git a/taskcluster/kinds/docker-image/kind.yml b/taskcluster/kinds/docker-image/kind.yml deleted file mode 100644 index cc2480a81d..0000000000 --- a/taskcluster/kinds/docker-image/kind.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -loader: taskgraph.loader.transform:loader - -transforms: - - taskgraph.transforms.docker_image:transforms - - taskgraph.transforms.cached_tasks:transforms - - taskgraph.transforms.task:transforms - -tasks: - linux: {} diff --git a/taskcluster/kinds/hello/kind.yml b/taskcluster/kinds/hello/kind.yml deleted file mode 100644 index a70db5dfc6..0000000000 --- a/taskcluster/kinds/hello/kind.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -transforms: - - neqo_taskgraph.transforms.hello:transforms - -task-defaults: - worker-type: t-linux-large - worker: - docker-image: {in-tree: linux} - max-run-time: 1800 - -tasks: - world: - noun: world - run: - using: run-task - command: >- - echo "Hello $NOUN!" diff --git a/taskcluster/neqo_taskgraph/transforms/hello.py b/taskcluster/neqo_taskgraph/transforms/hello.py deleted file mode 100644 index 25dd7f159d..0000000000 --- a/taskcluster/neqo_taskgraph/transforms/hello.py +++ /dev/null @@ -1,28 +0,0 @@ -from voluptuous import ALLOW_EXTRA, Required - -from taskgraph.transforms.base import TransformSequence -from taskgraph.util.schema import Schema - -transforms = TransformSequence() - -HELLO_SCHEMA = Schema( - { - Required("noun"): str, - }, - extra=ALLOW_EXTRA, -) - -transforms = TransformSequence() -transforms.add_validate(HELLO_SCHEMA) - - -@transforms.add -def add_noun(config, tasks): - for task in tasks: - noun = task.pop("noun").capitalize() - task["description"] = f"Prints 'Hello {noun}'" - - env = task.setdefault("worker", {}).setdefault("env", {}) - env["NOUN"] = noun - - yield task From 763ac2cc01122ab981c8b269f5b7f8b165ced6c6 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Fri, 10 Jan 2025 07:54:24 +0200 Subject: [PATCH 13/18] chore: Enable clippy `multiple_inherent_impl` lint (#2323) And fix all the warnings. Signed-off-by: Lars Eggert --- Cargo.toml | 1 + neqo-crypto/src/cert.rs | 20 ++++++++------------ neqo-http3/src/frames/reader.rs | 3 --- neqo-http3/src/push_controller.rs | 14 ++++++-------- neqo-transport/src/connection/idle.rs | 3 --- 5 files changed, 15 insertions(+), 26 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1ec26cff3c..06cfedb800 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,7 @@ nursery = { level = "warn", priority = -1 } pedantic = { level = "warn", priority = -1 } if_then_some_else_none = "warn" get_unwrap = "warn" +multiple_inherent_impl = "warn" pathbuf_init_then_push = "warn" ref_patterns = "warn" renamed_function_params = "warn" diff --git a/neqo-crypto/src/cert.rs b/neqo-crypto/src/cert.rs index 80609f5316..212679b4b7 100644 --- a/neqo-crypto/src/cert.rs +++ b/neqo-crypto/src/cert.rs @@ -72,6 +72,14 @@ fn signed_cert_timestamp(fd: *mut PRFileDesc) -> Option> { }) } +impl<'a> IntoIterator for &'a CertificateInfo { + type IntoIter = ItemArrayIterator<'a>; + type Item = &'a [u8]; + fn into_iter(self) -> Self::IntoIter { + self.iter() + } +} + impl CertificateInfo { pub(crate) fn new(fd: *mut PRFileDesc) -> Option { peer_certificate_chain(fd).map(|certs| Self { @@ -80,24 +88,12 @@ impl CertificateInfo { signed_cert_timestamp: signed_cert_timestamp(fd), }) } -} -impl CertificateInfo { #[must_use] pub fn iter(&self) -> ItemArrayIterator<'_> { self.certs.into_iter() } -} - -impl<'a> IntoIterator for &'a CertificateInfo { - type IntoIter = ItemArrayIterator<'a>; - type Item = &'a [u8]; - fn into_iter(self) -> Self::IntoIter { - self.iter() - } -} -impl CertificateInfo { #[must_use] pub const fn stapled_ocsp_responses(&self) -> &Option>> { &self.stapled_ocsp_responses diff --git a/neqo-http3/src/frames/reader.rs b/neqo-http3/src/frames/reader.rs index 6d2c0614b0..909cb83e72 100644 --- a/neqo-http3/src/frames/reader.rs +++ b/neqo-http3/src/frames/reader.rs @@ -235,9 +235,6 @@ impl FrameReader { } Ok(None) } -} - -impl FrameReader { fn frame_type_decoded>(&mut self, frame_type: HFrameType) -> Res<()> { T::frame_type_allowed(frame_type)?; self.frame_type = frame_type; diff --git a/neqo-http3/src/push_controller.rs b/neqo-http3/src/push_controller.rs index 564b149c2b..5de184caf1 100644 --- a/neqo-http3/src/push_controller.rs +++ b/neqo-http3/src/push_controller.rs @@ -156,6 +156,12 @@ pub struct PushController { conn_events: Http3ClientEvents, } +impl Display for PushController { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + write!(f, "Push controller") + } +} + impl PushController { pub const fn new(max_concurent_push: u64, conn_events: Http3ClientEvents) -> Self { Self { @@ -165,15 +171,7 @@ impl PushController { conn_events, } } -} - -impl Display for PushController { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - write!(f, "Push controller") - } -} -impl PushController { /// A new `push_promise` has been received. /// /// # Errors diff --git a/neqo-transport/src/connection/idle.rs b/neqo-transport/src/connection/idle.rs index c5b570a09c..6e327705f8 100644 --- a/neqo-transport/src/connection/idle.rs +++ b/neqo-transport/src/connection/idle.rs @@ -39,9 +39,6 @@ impl IdleTimeout { keep_alive_outstanding: false, } } -} - -impl IdleTimeout { pub fn set_peer_timeout(&mut self, peer_timeout: Duration) { self.timeout = min(self.timeout, peer_timeout); } From 01816e69c4526b0a885fff5a77765385c2966b13 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Fri, 10 Jan 2025 08:06:40 +0200 Subject: [PATCH 14/18] chore: Enable the `redundant_type_annotations` lint (#2325) And fix all the warnings it generates. Signed-off-by: Lars Eggert --- Cargo.toml | 1 + neqo-http3/src/frames/tests/mod.rs | 2 +- neqo-transport/src/cc/tests/cubic.rs | 10 +++++----- neqo-transport/src/connection/tests/handshake.rs | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 06cfedb800..e675e807c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,6 +46,7 @@ if_then_some_else_none = "warn" get_unwrap = "warn" multiple_inherent_impl = "warn" pathbuf_init_then_push = "warn" +redundant_type_annotations = "warn" ref_patterns = "warn" renamed_function_params = "warn" unused_trait_names = "warn" diff --git a/neqo-http3/src/frames/tests/mod.rs b/neqo-http3/src/frames/tests/mod.rs index c358cbf936..ce5e674e86 100644 --- a/neqo-http3/src/frames/tests/mod.rs +++ b/neqo-http3/src/frames/tests/mod.rs @@ -33,7 +33,7 @@ pub fn enc_dec>(d: &Encoder, st: &str, remaining: usize) -> T // create a stream let stream_id = conn_s.stream_create(StreamType::BiDi).unwrap(); - let mut fr: FrameReader = FrameReader::new(); + let mut fr = FrameReader::new(); // convert string into u8 vector let buf = Encoder::from_hex(st); diff --git a/neqo-transport/src/cc/tests/cubic.rs b/neqo-transport/src/cc/tests/cubic.rs index c2fc0c6431..edf0984d9d 100644 --- a/neqo-transport/src/cc/tests/cubic.rs +++ b/neqo-transport/src/cc/tests/cubic.rs @@ -200,7 +200,7 @@ fn tcp_phase() { #[test] fn cubic_phase() { let mut cubic = ClassicCongestionControl::new(Cubic::default(), Pmtud::new(IP_ADDR, MTU)); - let cwnd_initial_f64: f64 = convert_to_f64(cubic.cwnd_initial()); + let cwnd_initial_f64 = convert_to_f64(cubic.cwnd_initial()); // Set last_max_cwnd to a higher number make sure that cc is the cubic phase (cwnd is calculated // by the cubic equation). cubic.set_last_max_cwnd(cwnd_initial_f64 * 10.0); @@ -271,7 +271,7 @@ fn congestion_event_slow_start() { packet_lost(&mut cubic, 1); // last_max_cwnd is equal to cwnd before decrease. - let cwnd_initial_f64: f64 = convert_to_f64(cubic.cwnd_initial()); + let cwnd_initial_f64 = convert_to_f64(cubic.cwnd_initial()); assert_within( cubic.last_max_cwnd(), cwnd_initial_f64 + convert_to_f64(cubic.max_datagram_size()), @@ -302,7 +302,7 @@ fn congestion_event_congestion_avoidance() { // Trigger a congestion_event in slow start phase packet_lost(&mut cubic, 1); - let cwnd_initial_f64: f64 = convert_to_f64(cubic.cwnd_initial()); + let cwnd_initial_f64 = convert_to_f64(cubic.cwnd_initial()); assert_within(cubic.last_max_cwnd(), cwnd_initial_f64, f64::EPSILON); assert_eq!(cubic.cwnd(), cwnd_after_loss(cubic.cwnd_initial())); } @@ -315,7 +315,7 @@ fn congestion_event_congestion_avoidance_2() { cubic.set_ssthresh(1); // Set last_max_cwnd to something higher than cwnd so that the fast convergence is triggered. - let cwnd_initial_f64: f64 = convert_to_f64(cubic.cwnd_initial()); + let cwnd_initial_f64 = convert_to_f64(cubic.cwnd_initial()); cubic.set_last_max_cwnd(cwnd_initial_f64 * 10.0); _ = fill_cwnd(&mut cubic, 0, now()); @@ -344,7 +344,7 @@ fn congestion_event_congestion_avoidance_no_overflow() { cubic.set_ssthresh(1); // Set last_max_cwnd to something higher than cwnd so that the fast convergence is triggered. - let cwnd_initial_f64: f64 = convert_to_f64(cubic.cwnd_initial()); + let cwnd_initial_f64 = convert_to_f64(cubic.cwnd_initial()); cubic.set_last_max_cwnd(cwnd_initial_f64 * 10.0); _ = fill_cwnd(&mut cubic, 0, now()); diff --git a/neqo-transport/src/connection/tests/handshake.rs b/neqo-transport/src/connection/tests/handshake.rs index 1e2ee5937d..5c21d418d4 100644 --- a/neqo-transport/src/connection/tests/handshake.rs +++ b/neqo-transport/src/connection/tests/handshake.rs @@ -1218,7 +1218,7 @@ fn server_initial_retransmits_identical() { // Force the server to retransmit its Initial packet a number of times and make sure the // retranmissions are identical to the original. Also, verify the PTO durations. let mut server = default_server(); - let mut total_ptos: Duration = Duration::from_secs(0); + let mut total_ptos = Duration::from_secs(0); for i in 1..=3 { let si = server.process(ci.take(), now).dgram().unwrap(); assert_eq!(si.len(), server.plpmtu()); From b0fbde70c7e0b81b04ffbb1ba66ee537c8770425 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Fri, 10 Jan 2025 08:07:03 +0200 Subject: [PATCH 15/18] chore: Enable the `unneeded_field_pattern` lint (#2332) And fix the lint errors in the codebase. Signed-off-by: Lars Eggert --- Cargo.toml | 1 + neqo-http3/tests/priority.rs | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e675e807c3..11ef83bb44 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,6 +49,7 @@ pathbuf_init_then_push = "warn" redundant_type_annotations = "warn" ref_patterns = "warn" renamed_function_params = "warn" +unneeded_field_pattern = "warn" unused_trait_names = "warn" # Optimize build dependencies, because bindgen and proc macros / style diff --git a/neqo-http3/tests/priority.rs b/neqo-http3/tests/priority.rs index 300d72dccd..7edb2d03b9 100644 --- a/neqo-http3/tests/priority.rs +++ b/neqo-http3/tests/priority.rs @@ -83,11 +83,7 @@ fn priority_update() { }; match header_event { - Http3ServerEvent::Headers { - stream: _, - headers, - fin, - } => { + Http3ServerEvent::Headers { headers, fin, .. } => { let expected_headers = &[ Header::new(":method", "GET"), Header::new(":scheme", "https"), From 82683d41a67c88abfa5d795d70c9d6ad574fa80e Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Fri, 10 Jan 2025 08:45:59 +0200 Subject: [PATCH 16/18] chore: Enable the `try_err` lint (#2331) And fix the lint errors Signed-off-by: Lars Eggert --- Cargo.toml | 1 + neqo-bin/src/server/mod.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 11ef83bb44..0ec4ea1ff8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,6 +49,7 @@ pathbuf_init_then_push = "warn" redundant_type_annotations = "warn" ref_patterns = "warn" renamed_function_params = "warn" +try_err = "warn" unneeded_field_pattern = "warn" unused_trait_names = "warn" diff --git a/neqo-bin/src/server/mod.rs b/neqo-bin/src/server/mod.rs index 3f9de917d4..77dbf1d743 100644 --- a/neqo-bin/src/server/mod.rs +++ b/neqo-bin/src/server/mod.rs @@ -393,7 +393,7 @@ pub async fn server(mut args: Args) -> Res<()> { let hosts = args.listen_addresses(); if hosts.is_empty() { qerror!("No valid hosts defined"); - Err(io::Error::new(io::ErrorKind::InvalidInput, "No hosts"))?; + return Err(io::Error::new(io::ErrorKind::InvalidInput, "No hosts").into()); } let sockets = hosts .into_iter() From 5aee5328ba806ed7b357e022070e855daaadd850 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Fri, 10 Jan 2025 09:07:40 +0200 Subject: [PATCH 17/18] chore: Enable some rustc lints (#2317) * chore: Enable some rustc lints And deal with the fallout. * `unused_qualifications` has issues on 1.76 * Fixes --------- Signed-off-by: Lars Eggert --- Cargo.toml | 17 +++ neqo-bin/src/client/http09.rs | 6 +- neqo-bin/src/client/http3.rs | 4 +- neqo-bin/src/client/mod.rs | 8 +- neqo-bin/src/server/mod.rs | 2 +- neqo-common/src/codec.rs | 4 +- neqo-common/src/hrtime.rs | 4 +- neqo-common/src/qlog.rs | 4 +- neqo-crypto/src/aead.rs | 4 +- neqo-crypto/src/agent.rs | 26 ++-- neqo-crypto/src/lib.rs | 4 +- neqo-crypto/src/p11.rs | 3 +- neqo-crypto/tests/hp.rs | 6 +- neqo-http3/src/connection.rs | 20 +-- neqo-http3/src/connection_client.rs | 124 +++++++++--------- .../tests/webtransport/mod.rs | 2 +- .../tests/webtransport/negotiation.rs | 2 +- .../tests/webtransport/sessions.rs | 4 +- .../tests/webtransport/streams.rs | 28 ++-- neqo-http3/src/frames/tests/mod.rs | 8 +- neqo-http3/src/frames/tests/reader.rs | 16 +-- neqo-http3/src/push_controller.rs | 4 +- neqo-http3/src/server.rs | 13 +- neqo-http3/src/stream_type_reader.rs | 8 +- neqo-http3/tests/httpconn.rs | 23 ++-- neqo-qpack/src/decoder.rs | 6 +- neqo-qpack/src/encoder.rs | 10 +- neqo-transport/src/cid.rs | 6 +- neqo-transport/src/connection/mod.rs | 6 +- .../src/connection/tests/ackrate.rs | 4 +- neqo-transport/src/connection/tests/cc.rs | 6 +- .../src/connection/tests/handshake.rs | 15 +-- neqo-transport/src/connection/tests/idle.rs | 23 ++-- neqo-transport/src/connection/tests/keys.rs | 18 ++- .../src/connection/tests/migration.rs | 3 +- neqo-transport/src/connection/tests/mod.rs | 2 +- .../src/connection/tests/priority.rs | 12 +- .../src/connection/tests/recovery.rs | 15 +-- .../src/connection/tests/resumption.rs | 10 +- neqo-transport/src/connection/tests/stream.rs | 36 ++--- neqo-transport/src/connection/tests/vn.rs | 6 +- neqo-transport/src/lib.rs | 2 +- neqo-transport/src/path.rs | 7 +- neqo-transport/src/recovery/mod.rs | 2 - neqo-transport/src/recovery/sent.rs | 3 +- neqo-transport/src/tparams.rs | 2 +- neqo-transport/tests/common/mod.rs | 2 +- neqo-transport/tests/retry.rs | 3 +- neqo-transport/tests/server.rs | 16 +-- neqo-udp/src/lib.rs | 2 +- test-fixture/src/lib.rs | 2 +- 51 files changed, 273 insertions(+), 290 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0ec4ea1ff8..3271443073 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,6 +38,23 @@ regex = { version = "1.9", default-features = false, features = ["unicode-perl"] static_assertions = { version = "1.1", default-features = false } url = { version = "2.5.3", default-features = false, features = ["std"] } +[workspace.lints.rust] +absolute_paths_not_starting_with_crate = "warn" +ambiguous_negative_literals = "warn" +closure_returning_async_block = "warn" +explicit_outlives_requirements = "warn" +macro_use_extern_crate = "warn" +missing_abi = "warn" +non_ascii_idents = "warn" +redundant_imports = "warn" +redundant_lifetimes = "warn" +trivial_numeric_casts = "warn" +unit_bindings = "warn" +unused_import_braces = "warn" +unused_lifetimes = "warn" +unused_macro_rules = "warn" +# unused_qualifications = "warn" // Try to re-enable when MSRV is > 1.76 + [workspace.lints.clippy] cargo = { level = "warn", priority = -1 } nursery = { level = "warn", priority = -1 } diff --git a/neqo-bin/src/client/http09.rs b/neqo-bin/src/client/http09.rs index 87ab6b0c7b..3c3439b035 100644 --- a/neqo-bin/src/client/http09.rs +++ b/neqo-bin/src/client/http09.rs @@ -17,7 +17,7 @@ use std::{ time::Instant, }; -use neqo_common::{event::Provider as _, qdebug, qinfo, qwarn, Datagram}; +use neqo_common::{event::Provider, qdebug, qinfo, qwarn, Datagram}; use neqo_crypto::{AuthenticationStatus, ResumptionToken}; use neqo_transport::{ CloseReason, Connection, ConnectionEvent, ConnectionIdGenerator, EmptyConnectionIdGenerator, @@ -61,7 +61,7 @@ impl super::Handler for Handler<'_> { self.needs_key_update = false; self.download_urls(client); } - Err(neqo_transport::Error::KeyUpdateBlocked) => (), + Err(Error::KeyUpdateBlocked) => (), Err(e) => return Err(e.into()), } } @@ -213,7 +213,7 @@ impl super::Client for Connection { } fn has_events(&self) -> bool { - neqo_common::event::Provider::has_events(self) + Provider::has_events(self) } } diff --git a/neqo-bin/src/client/http3.rs b/neqo-bin/src/client/http3.rs index 33e9a9243b..9ceb97cd29 100644 --- a/neqo-bin/src/client/http3.rs +++ b/neqo-bin/src/client/http3.rs @@ -18,7 +18,7 @@ use std::{ time::Instant, }; -use neqo_common::{event::Provider as _, hex, qdebug, qinfo, qwarn, Datagram, Header}; +use neqo_common::{event::Provider, hex, qdebug, qinfo, qwarn, Datagram, Header}; use neqo_crypto::{AuthenticationStatus, ResumptionToken}; use neqo_http3::{Error, Http3Client, Http3ClientEvent, Http3Parameters, Http3State, Priority}; use neqo_transport::{ @@ -155,7 +155,7 @@ impl super::Client for Http3Client { } fn has_events(&self) -> bool { - neqo_common::event::Provider::has_events(self) + Provider::has_events(self) } } diff --git a/neqo-bin/src/client/mod.rs b/neqo-bin/src/client/mod.rs index fe0c32ae3f..7794952210 100644 --- a/neqo-bin/src/client/mod.rs +++ b/neqo-bin/src/client/mod.rs @@ -48,7 +48,7 @@ pub enum Error { IoError(io::Error), QlogError(qlog::Error), TransportError(neqo_transport::Error), - ApplicationError(neqo_transport::AppError), + ApplicationError(AppError), CryptoError(neqo_crypto::Error), } @@ -82,8 +82,8 @@ impl From for Error { } } -impl From for Error { - fn from(err: neqo_transport::CloseReason) -> Self { +impl From for Error { + fn from(err: CloseReason) -> Self { match err { CloseReason::Transport(e) => Self::TransportError(e), CloseReason::Application(e) => Self::ApplicationError(e), @@ -184,7 +184,7 @@ impl Args { pub fn new(requests: &[usize], upload: bool) -> Self { use std::str::FromStr as _; Self { - shared: crate::SharedArgs::default(), + shared: SharedArgs::default(), urls: requests .iter() .map(|r| Url::from_str(&format!("http://[::1]:12345/{r}")).unwrap()) diff --git a/neqo-bin/src/server/mod.rs b/neqo-bin/src/server/mod.rs index 77dbf1d743..ab0ed15332 100644 --- a/neqo-bin/src/server/mod.rs +++ b/neqo-bin/src/server/mod.rs @@ -124,7 +124,7 @@ impl Default for Args { fn default() -> Self { use std::str::FromStr as _; Self { - shared: crate::SharedArgs::default(), + shared: SharedArgs::default(), hosts: vec!["[::]:12345".to_string()], db: PathBuf::from_str("../test-fixture/db").unwrap(), key: "key".to_string(), diff --git a/neqo-common/src/codec.rs b/neqo-common/src/codec.rs index a43d7ab023..f772c5949b 100644 --- a/neqo-common/src/codec.rs +++ b/neqo-common/src/codec.rs @@ -4,7 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{fmt::Debug, mem::size_of}; +use std::fmt::Debug; use crate::hex_with_len; @@ -111,7 +111,7 @@ impl<'a> Decoder<'a> { /// unsigned integer types: `u8`, `u16`, `u32`, or `u64`. /// Signed types will fail if the high bit is set. pub fn decode_uint>(&mut self) -> Option { - let v = self.decode_n(size_of::()); + let v = self.decode_n(std::mem::size_of::()); v.and_then(|v| T::try_from(v).ok()) } diff --git a/neqo-common/src/hrtime.rs b/neqo-common/src/hrtime.rs index 7187b7727d..8fc0b5270f 100644 --- a/neqo-common/src/hrtime.rs +++ b/neqo-common/src/hrtime.rs @@ -80,7 +80,7 @@ impl PeriodSet { #[cfg(target_os = "macos")] #[allow(non_camel_case_types)] mod mac { - use std::{mem::size_of, ptr::addr_of_mut}; + use std::ptr::addr_of_mut; // These are manually extracted from the many bindings generated // by bindgen when provided with the simple header: @@ -126,7 +126,7 @@ mod mac { const THREAD_TIME_CONSTRAINT_POLICY: thread_policy_flavor_t = 2; #[allow(clippy::cast_possible_truncation)] const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t = - (size_of::() / size_of::()) + (std::mem::size_of::() / std::mem::size_of::()) as mach_msg_type_number_t; // These function definitions are taken from a comment in . diff --git a/neqo-common/src/qlog.rs b/neqo-common/src/qlog.rs index 5f7b5dca3d..0276532a95 100644 --- a/neqo-common/src/qlog.rs +++ b/neqo-common/src/qlog.rs @@ -59,7 +59,7 @@ impl NeqoQlog { title, description, None, - std::time::Instant::now(), + Instant::now(), new_trace(role), qlog::events::EventImportance::Base, Box::new(BufWriter::new(file)), @@ -175,7 +175,7 @@ impl Drop for NeqoQlogShared { } #[must_use] -pub fn new_trace(role: Role) -> qlog::TraceSeq { +pub fn new_trace(role: Role) -> TraceSeq { TraceSeq { vantage_point: VantagePoint { name: Some(format!("neqo-{role}")), diff --git a/neqo-crypto/src/aead.rs b/neqo-crypto/src/aead.rs index 0678d147fb..059e9acb61 100644 --- a/neqo-crypto/src/aead.rs +++ b/neqo-crypto/src/aead.rs @@ -17,7 +17,7 @@ use crate::{ experimental_api, p11::{PK11SymKey, SymKey}, scoped_ptr, - ssl::{self, PRUint16, PRUint64, PRUint8, SSLAeadContext}, + ssl::{PRUint16, PRUint64, PRUint8, SSLAeadContext}, }; experimental_api!(SSL_MakeAead( @@ -80,7 +80,7 @@ impl RealAead { prefix: &str, ) -> Res { let p = prefix.as_bytes(); - let mut ctx: *mut ssl::SSLAeadContext = null_mut(); + let mut ctx: *mut SSLAeadContext = null_mut(); SSL_MakeAead( version, cipher, diff --git a/neqo-crypto/src/agent.rs b/neqo-crypto/src/agent.rs index f3180fbc78..11289a61eb 100644 --- a/neqo-crypto/src/agent.rs +++ b/neqo-crypto/src/agent.rs @@ -7,7 +7,7 @@ use std::{ cell::RefCell, ffi::{CStr, CString}, - mem::{self, MaybeUninit}, + mem::MaybeUninit, ops::{Deref, DerefMut}, os::raw::{c_uint, c_void}, pin::Pin, @@ -135,7 +135,7 @@ impl SecretAgentPreInfo { ssl::SSL_GetPreliminaryChannelInfo( fd, info.as_mut_ptr(), - c_uint::try_from(mem::size_of::())?, + c_uint::try_from(std::mem::size_of::())?, ) })?; @@ -222,7 +222,7 @@ impl SecretAgentInfo { ssl::SSL_GetChannelInfo( fd, info.as_mut_ptr(), - c_uint::try_from(mem::size_of::())?, + c_uint::try_from(std::mem::size_of::())?, ) })?; let info = unsafe { info.assume_init() }; @@ -347,8 +347,8 @@ impl SecretAgent { unsafe extern "C" fn auth_complete_hook( arg: *mut c_void, _fd: *mut ssl::PRFileDesc, - _check_sig: ssl::PRBool, - _is_server: ssl::PRBool, + _check_sig: PRBool, + _is_server: PRBool, ) -> ssl::SECStatus { let auth_required_ptr = arg.cast::(); *auth_required_ptr = true; @@ -394,7 +394,7 @@ impl SecretAgent { self.now.bind(self.fd)?; self.configure(grease)?; - secstatus_to_res(unsafe { ssl::SSL_ResetHandshake(self.fd, ssl::PRBool::from(is_server)) }) + secstatus_to_res(unsafe { ssl::SSL_ResetHandshake(self.fd, PRBool::from(is_server)) }) } /// Default configuration. @@ -438,13 +438,13 @@ impl SecretAgent { for i in 0..cipher_count { let p = all_ciphers.wrapping_add(i); secstatus_to_res(unsafe { - ssl::SSL_CipherPrefSet(self.fd, i32::from(*p), ssl::PRBool::from(false)) + ssl::SSL_CipherPrefSet(self.fd, i32::from(*p), PRBool::from(false)) })?; } for c in ciphers { secstatus_to_res(unsafe { - ssl::SSL_CipherPrefSet(self.fd, i32::from(*c), ssl::PRBool::from(true)) + ssl::SSL_CipherPrefSet(self.fd, i32::from(*c), PRBool::from(true)) })?; } Ok(()) @@ -876,7 +876,7 @@ impl Client { token, len, info.as_mut_ptr(), - c_uint::try_from(mem::size_of::()).unwrap(), + c_uint::try_from(std::mem::size_of::()).unwrap(), ); if info_res.is_err() { // Ignore the token. @@ -1016,7 +1016,7 @@ pub enum ZeroRttCheckResult { /// A `ZeroRttChecker` is used by the agent to validate the application token (as provided by /// `send_ticket`) -pub trait ZeroRttChecker: std::fmt::Debug + std::marker::Unpin { +pub trait ZeroRttChecker: std::fmt::Debug + Unpin { fn check(&self, token: &[u8]) -> ZeroRttCheckResult; } @@ -1068,7 +1068,7 @@ impl Server { return Err(Error::CertificateLoading); }; let key_ptr = unsafe { p11::PK11_FindKeyByAnyCert(*cert, null_mut()) }; - let Ok(key) = p11::PrivateKey::from_ptr(key_ptr) else { + let Ok(key) = PrivateKey::from_ptr(key_ptr) else { return Err(Error::CertificateLoading); }; secstatus_to_res(unsafe { @@ -1213,8 +1213,8 @@ impl ::std::fmt::Display for Server { /// A generic container for Client or Server. #[derive(Debug)] pub enum Agent { - Client(crate::agent::Client), - Server(crate::agent::Server), + Client(Client), + Server(Server), } impl Deref for Agent { diff --git a/neqo-crypto/src/lib.rs b/neqo-crypto/src/lib.rs index 1816440d63..44c24fcc8f 100644 --- a/neqo-crypto/src/lib.rs +++ b/neqo-crypto/src/lib.rs @@ -70,7 +70,7 @@ mod nss { // Need to map the types through. fn secstatus_to_res(code: nss::SECStatus) -> Res<()> { - crate::err::secstatus_to_res(code as crate::ssl::SECStatus) + err::secstatus_to_res(code) } enum NssLoaded { @@ -106,7 +106,7 @@ fn version_check() -> Res<()> { /// This allows us to use SSLTRACE in all of our unit tests and programs. #[cfg(debug_assertions)] fn enable_ssl_trace() -> Res<()> { - let opt = ssl::Opt::Locking.as_int(); + let opt = Opt::Locking.as_int(); let mut v: ::std::os::raw::c_int = 0; secstatus_to_res(unsafe { ssl::SSL_OptionGetDefault(opt, &mut v) }) } diff --git a/neqo-crypto/src/p11.rs b/neqo-crypto/src/p11.rs index 20a88ba70f..96d149ad82 100644 --- a/neqo-crypto/src/p11.rs +++ b/neqo-crypto/src/p11.rs @@ -11,7 +11,6 @@ use std::{ cell::RefCell, - mem, ops::{Deref, DerefMut}, os::raw::c_uint, ptr::null_mut, @@ -265,7 +264,7 @@ impl Item { SECItem { type_: SECItemType::siBuffer, data: data.cast_mut().cast(), - len: c_uint::try_from(mem::size_of::()).unwrap(), + len: c_uint::try_from(std::mem::size_of::()).unwrap(), } } diff --git a/neqo-crypto/tests/hp.rs b/neqo-crypto/tests/hp.rs index 1a3c39e1d7..4524720e14 100644 --- a/neqo-crypto/tests/hp.rs +++ b/neqo-crypto/tests/hp.rs @@ -4,8 +4,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::mem; - use neqo_crypto::{ constants::{ Cipher, TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256, @@ -71,12 +69,12 @@ fn chacha20_ctr() { #[should_panic(expected = "out of range")] fn aes_short() { let hp = make_hp(TLS_AES_128_GCM_SHA256); - mem::drop(hp.mask(&[0; 15])); + drop(hp.mask(&[0; 15])); } #[test] #[should_panic(expected = "out of range")] fn chacha20_short() { let hp = make_hp(TLS_CHACHA20_POLY1305_SHA256); - mem::drop(hp.mask(&[0; 15])); + drop(hp.mask(&[0; 15])); } diff --git a/neqo-http3/src/connection.rs b/neqo-http3/src/connection.rs index 32a923656c..d3dd12d8fe 100644 --- a/neqo-http3/src/connection.rs +++ b/neqo-http3/src/connection.rs @@ -805,7 +805,7 @@ impl Http3Connection { Ok((_, false)) => {} Err(e) => { if e.stream_reset_error() && !self.recv_stream_is_critical(stream_id) { - mem::drop(conn.stream_stop_sending(stream_id, e.code())); + drop(conn.stream_stop_sending(stream_id, e.code())); self.close_recv(stream_id, CloseType::LocalError(e.code()), conn)?; return Ok((U::default(), false)); } @@ -1056,7 +1056,7 @@ impl Http3Connection { return Err(Error::InvalidStreamId); } // Stream may be already be closed and we may get an error here, but we do not care. - mem::drop(self.stream_reset_send(conn, stream_id, error)); + drop(self.stream_reset_send(conn, stream_id, error)); } (None, Some(s)) => { if !matches!( @@ -1069,7 +1069,7 @@ impl Http3Connection { } // Stream may be already be closed and we may get an error here, but we do not care. - mem::drop(self.stream_stop_sending(conn, stream_id, error)); + drop(self.stream_stop_sending(conn, stream_id, error)); } (Some(s), Some(r)) => { debug_assert_eq!(s.stream_type(), r.stream_type()); @@ -1080,9 +1080,9 @@ impl Http3Connection { return Err(Error::InvalidStreamId); } // Stream may be already be closed and we may get an error here, but we do not care. - mem::drop(self.stream_reset_send(conn, stream_id, error)); + drop(self.stream_reset_send(conn, stream_id, error)); // Stream may be already be closed and we may get an error here, but we do not care. - mem::drop(self.stream_stop_sending(conn, stream_id, error)); + drop(self.stream_stop_sending(conn, stream_id, error)); } } Ok(()) @@ -1098,7 +1098,7 @@ impl Http3Connection { .ok_or(Error::InvalidStreamId)?; // The following function may return InvalidStreamId from the transport layer if the stream // has been closed already. It is ok to ignore it here. - mem::drop(send_stream.close(conn)); + drop(send_stream.close(conn)); if send_stream.done() { self.remove_send_stream(stream_id, conn); } else if send_stream.has_data_to_send() { @@ -1192,7 +1192,7 @@ impl Http3Connection { .send_headers(headers, conn) .is_ok() { - mem::drop(self.stream_close_send(conn, stream_id)); + drop(self.stream_close_send(conn, stream_id)); // TODO issue 1294: add a timer to clean up the recv_stream if the peer does not // do that in a short time. self.streams_with_pending_data.insert(stream_id); @@ -1581,16 +1581,16 @@ impl Http3Connection { // Use CloseType::ResetRemote so that an event will be sent. CloseType::LocalError would // have the same effect. if let Some(mut s) = self.recv_streams.remove(&id) { - mem::drop(s.reset(CloseType::ResetRemote(Error::HttpRequestCancelled.code()))); + drop(s.reset(CloseType::ResetRemote(Error::HttpRequestCancelled.code()))); } - mem::drop(conn.stream_stop_sending(id, Error::HttpRequestCancelled.code())); + drop(conn.stream_stop_sending(id, Error::HttpRequestCancelled.code())); } for id in send { qtrace!("Remove the extended connect sub send stream {}", id); if let Some(mut s) = self.send_streams.remove(&id) { s.handle_stop_sending(CloseType::ResetRemote(Error::HttpRequestCancelled.code())); } - mem::drop(conn.stream_reset_send(id, Error::HttpRequestCancelled.code())); + drop(conn.stream_reset_send(id, Error::HttpRequestCancelled.code())); } } diff --git a/neqo-http3/src/connection_client.rs b/neqo-http3/src/connection_client.rs index 6ef11bf760..d90c5be991 100644 --- a/neqo-http3/src/connection_client.rs +++ b/neqo-http3/src/connection_client.rs @@ -7,7 +7,7 @@ use std::{ cell::RefCell, fmt::{Debug, Display}, - iter, mem, + iter, net::SocketAddr, rc::Rc, time::Instant, @@ -1141,7 +1141,7 @@ impl Http3Client { { // We are not interested in the result of stream_stop_sending, we are not interested // in this stream. - mem::drop( + drop( self.conn .stream_stop_sending(stream_id, Error::HttpRequestCancelled.code()), ); @@ -1201,7 +1201,7 @@ impl Http3Client { .collect(); for id in send_ids { // We do not care about streams that are going to be closed. - mem::drop(self.base_handler.handle_stream_stop_sending( + drop(self.base_handler.handle_stream_stop_sending( id, Error::HttpRequestRejected.code(), &mut self.conn, @@ -1216,7 +1216,7 @@ impl Http3Client { .collect(); for id in recv_ids { // We do not care about streams that are going to be closed. - mem::drop(self.base_handler.handle_stream_reset( + drop(self.base_handler.handle_stream_reset( id, Error::HttpRequestRejected.code(), &mut self.conn, @@ -1278,7 +1278,7 @@ impl EventProvider for Http3Client { #[cfg(test)] mod tests { - use std::{mem, time::Duration}; + use std::time::Duration; use neqo_common::{event::Provider as _, qtrace, Datagram, Decoder, Encoder}; use neqo_crypto::{AllowZeroRtt, AntiReplay, ResumptionToken}; @@ -1699,8 +1699,8 @@ mod tests { // connecting with default max_table_size let mut client = default_http3_client_param(100); let server = Connection::new_server( - test_fixture::DEFAULT_KEYS, - test_fixture::DEFAULT_ALPN_H3, + DEFAULT_KEYS, + DEFAULT_ALPN_H3, Rc::new(RefCell::new(CountingConnectionIdGenerator::default())), server_conn_params, ) @@ -1889,7 +1889,7 @@ mod tests { } let out = server.conn.process(None::, now()); let out = client.process(out.dgram(), now()); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); } const PUSH_PROMISE_DATA: &[u8] = &[ @@ -1928,7 +1928,7 @@ mod tests { let out = server.conn.process_output(now()); let out = client.process(out.dgram(), now()); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); push_stream_id } @@ -1943,7 +1943,7 @@ mod tests { let out = server.conn.process_output(now()); let out = client.process(out.dgram(), now()); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); } fn send_cancel_push_and_exchange_packets( @@ -1961,7 +1961,7 @@ mod tests { let out = server.conn.process_output(now()); let out = client.process(out.dgram(), now()); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); } const PUSH_DATA: &[u8] = &[ @@ -2117,7 +2117,7 @@ mod tests { // Client: Test receiving a new control stream and a SETTINGS frame. #[test] fn client_connect_and_exchange_qpack_and_control_streams() { - mem::drop(connect()); + drop(connect()); } // Client: Test that the connection will be closed if control stream @@ -2311,7 +2311,7 @@ mod tests { let out = server.conn.process_output(now()); let out = client.process(out.dgram(), now()); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); assert_closed(&client, &Error::HttpFrameUnexpected); } @@ -2371,7 +2371,7 @@ mod tests { .unwrap(); let out = server.conn.process_output(now()); let out = client.process(out.dgram(), now()); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); // check for stop-sending with Error::HttpStreamCreation. let mut stop_sending_event_found = false; @@ -2399,7 +2399,7 @@ mod tests { // Generate packet with the above bad h3 input let out = server.conn.process_output(now()); // Process bad input and close the connection. - mem::drop(client.process(out.dgram(), now())); + drop(client.process(out.dgram(), now())); assert_closed(&client, &Error::HttpFrameUnexpected); } @@ -2676,7 +2676,7 @@ mod tests { client.stream_close_send(request_stream_id).unwrap(); let out = client.process_output(now()); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); // find the new request/response stream and send response on it. while let Some(e) = server.conn.next_event() { @@ -3372,7 +3372,7 @@ mod tests { assert_eq!(request_stream_id_3, 8); let out = client.process_output(now()); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); _ = server .conn @@ -3456,7 +3456,7 @@ mod tests { assert_eq!(request_stream_id_3, 8); let out = client.process_output(now()); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); // First send a Goaway frame with an higher number _ = server @@ -4029,11 +4029,11 @@ mod tests { assert!(!client.events().any(header_ready_event)); // Let client receive the encoder instructions. - mem::drop(client.process(encoder_inst_pkt.dgram(), now())); + drop(client.process(encoder_inst_pkt.dgram(), now())); let out = server.conn.process_output(now()); - mem::drop(client.process(out.dgram(), now())); - mem::drop(client.process_output(now())); + drop(client.process(out.dgram(), now())); + drop(client.process_output(now())); let mut recv_header = false; let mut recv_data = false; @@ -4183,7 +4183,7 @@ mod tests { let out = client.process(out.dgram(), now()); assert_eq!(client.state(), Http3State::Connected); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); assert!(server.conn.state().connected()); assert!(client.tls_info().unwrap().resumed()); @@ -4254,8 +4254,8 @@ mod tests { let mut client = default_http3_client(); let mut server = Connection::new_server( - test_fixture::DEFAULT_KEYS, - test_fixture::DEFAULT_ALPN_H3, + DEFAULT_KEYS, + DEFAULT_ALPN_H3, Rc::new(RefCell::new(CountingConnectionIdGenerator::default())), ConnectionParameters::default(), ) @@ -4307,7 +4307,7 @@ mod tests { assert_eq!(res.unwrap_err(), Error::InvalidStreamId); // Client will send Setting frame and open new qpack streams. - mem::drop(server.process(client_out.dgram(), now())); + drop(server.process(client_out.dgram(), now())); TestServer::new_with_conn(server).check_client_control_qpack_streams_no_resumption(); // Check that we can send a request and that the stream_id starts again from 0. @@ -4353,7 +4353,7 @@ mod tests { let out = client.process(out.dgram(), now()); assert_eq!(client.state(), Http3State::Connected); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); assert!(server.conn.state().connected()); assert!(client.tls_info().unwrap().resumed()); @@ -4977,7 +4977,7 @@ mod tests { let request_stream_id = make_request(&mut client, true, &[]); let out = client.process_output(now()); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); setup_server_side_encoder(&mut client, &mut server); @@ -5012,13 +5012,13 @@ mod tests { server.conn.stream_close_send(request_stream_id).unwrap(); let out = server.conn.process_output(now()); - mem::drop(client.process(out.dgram(), now())); + drop(client.process(out.dgram(), now())); let header_ready_event = |e| matches!(e, Http3ClientEvent::HeaderReady { .. }); assert!(!client.events().any(header_ready_event)); // Let client receive the encoder instructions. - mem::drop(client.process(qpack_pkt1.dgram(), now())); + drop(client.process(qpack_pkt1.dgram(), now())); assert!(client.events().any(header_ready_event)); } @@ -5456,7 +5456,7 @@ mod tests { assert_eq!(request_stream_id_2, 4); let out = client.process_output(now()); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); send_push_promise_and_exchange_packets( &mut client, @@ -5502,7 +5502,7 @@ mod tests { assert_eq!(request_stream_id_2, 4); let out = client.process_output(now()); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); send_push_promise_and_exchange_packets( &mut client, @@ -5560,7 +5560,7 @@ mod tests { assert_eq!(request_stream_id_2, 4); let out = client.process_output(now()); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); send_push_promise_and_exchange_packets( &mut client, @@ -5663,7 +5663,7 @@ mod tests { ); let out = client.process_output(now()); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); // Check max_push_id frame has been received let control_stream_readable = @@ -5682,7 +5682,7 @@ mod tests { let out = server.conn.process_output(now()); let out = client.process(out.dgram(), now()); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); assert_eq!(client.state(), Http3State::Connected); @@ -5957,7 +5957,7 @@ mod tests { assert!(client.cancel_push(PushId::new(0)).is_ok()); let out = client.process_output(now()); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); // Assert that we do not have any push event. assert!(!check_push_events(&mut client)); @@ -5996,7 +5996,7 @@ mod tests { assert!(client.cancel_push(PushId::new(0)).is_ok()); let out = client.process_output(now()); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); send_push_promise_and_exchange_packets( &mut client, @@ -6046,7 +6046,7 @@ mod tests { .send_encoder_updates(&mut server.conn) .unwrap(); let out = server.conn.process_output(now()); - mem::drop(client.process(out.dgram(), now())); + drop(client.process(out.dgram(), now())); } fn setup_server_side_encoder(client: &mut Http3Client, server: &mut TestServer) { @@ -6365,7 +6365,7 @@ mod tests { setup_server_side_encoder(&mut client, &mut server); - mem::drop( + drop( send_push_promise_using_encoder( &mut client, &mut server, @@ -6391,7 +6391,7 @@ mod tests { .unwrap(); let out = client.process_output(now()); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); // Check that encoder got stream_canceled instruction. let mut inst = [0_u8; 100]; let (amount, fin) = server @@ -6455,7 +6455,7 @@ mod tests { ); // Now read headers. - mem::drop(client.process(encoder_insts.dgram(), now())); + drop(client.process(encoder_insts.dgram(), now())); } #[test] @@ -6463,11 +6463,11 @@ mod tests { let (mut client, mut server, request_stream_id) = connect_and_send_request(true); setup_server_side_encoder(&mut client, &mut server); // Cancel request. - mem::drop(client.cancel_fetch(request_stream_id, Error::HttpRequestCancelled.code())); + drop(client.cancel_fetch(request_stream_id, Error::HttpRequestCancelled.code())); assert_eq!(server.encoder.borrow_mut().stats().stream_cancelled_recv, 0); let out = client.process_output(now()); - mem::drop(server.conn.process(out.dgram(), now())); - mem::drop(server.encoder_receiver.receive(&mut server.conn)); + drop(server.conn.process(out.dgram(), now())); + drop(server.encoder_receiver.receive(&mut server.conn)); assert_eq!(server.encoder.borrow_mut().stats().stream_cancelled_recv, 1); } @@ -6515,8 +6515,8 @@ mod tests { assert_eq!(server.encoder.borrow_mut().stats().stream_cancelled_recv, 0); let out = server.conn.process_output(now()); let out = client.process(out.dgram(), now()); - mem::drop(server.conn.process(out.dgram(), now())); - mem::drop(server.encoder_receiver.receive(&mut server.conn)); + drop(server.conn.process(out.dgram(), now())); + drop(server.encoder_receiver.receive(&mut server.conn)); assert_eq!(server.encoder.borrow_mut().stats().stream_cancelled_recv, 1); } @@ -6526,7 +6526,7 @@ mod tests { setup_server_side_encoder(&mut client, &mut server); - mem::drop( + drop( send_headers_using_encoder( &mut client, &mut server, @@ -6551,8 +6551,8 @@ mod tests { assert_eq!(server.encoder.borrow_mut().stats().stream_cancelled_recv, 0); let out = client.process_output(now()); - mem::drop(server.conn.process(out.dgram(), now())); - mem::drop(server.encoder_receiver.receive(&mut server.conn).unwrap()); + drop(server.conn.process(out.dgram(), now())); + drop(server.encoder_receiver.receive(&mut server.conn).unwrap()); assert_eq!(server.encoder.borrow_mut().stats().stream_cancelled_recv, 1); } @@ -6575,7 +6575,7 @@ mod tests { ); // Exchange encoder instructions - mem::drop(client.process(encoder_instruct, now())); + drop(client.process(encoder_instruct, now())); let header_ready_event = |e| matches!(e, Http3ClientEvent::HeaderReady { .. }); assert!(client.events().any(header_ready_event)); @@ -6588,8 +6588,8 @@ mod tests { assert_eq!(server.encoder.borrow_mut().stats().stream_cancelled_recv, 0); let out = client.process_output(now()); - mem::drop(server.conn.process(out.dgram(), now())); - mem::drop(server.encoder_receiver.receive(&mut server.conn).unwrap()); + drop(server.conn.process(out.dgram(), now())); + drop(server.encoder_receiver.receive(&mut server.conn).unwrap()); assert_eq!(server.encoder.borrow_mut().stats().stream_cancelled_recv, 0); } @@ -6614,10 +6614,10 @@ mod tests { // Send the encoder instructions. let out = server.conn.process_output(now()); - mem::drop(client.process(out.dgram(), now())); + drop(client.process(out.dgram(), now())); // Send PushPromise that will be blocked waiting for decoder instructions. - mem::drop( + drop( send_push_promise_using_encoder( &mut client, &mut server, @@ -6649,8 +6649,8 @@ mod tests { .unwrap(); let out = client.process_output(now()); - mem::drop(server.conn.process(out.dgram(), now())); - mem::drop(server.encoder_receiver.receive(&mut server.conn).unwrap()); + drop(server.conn.process(out.dgram(), now())); + drop(server.encoder_receiver.receive(&mut server.conn).unwrap()); assert_eq!(server.encoder.borrow_mut().stats().stream_cancelled_recv, 1); } @@ -6663,8 +6663,8 @@ mod tests { .unwrap(); assert_eq!(server.encoder.borrow_mut().stats().stream_cancelled_recv, 0); let out = client.process_output(now()); - mem::drop(server.conn.process(out.dgram(), now())); - mem::drop(server.encoder_receiver.receive(&mut server.conn).unwrap()); + drop(server.conn.process(out.dgram(), now())); + drop(server.encoder_receiver.receive(&mut server.conn).unwrap()); assert_eq!(server.encoder.borrow_mut().stats().stream_cancelled_recv, 0); } @@ -6716,7 +6716,7 @@ mod tests { assert!(!client.events().any(header_ready_event)); // Now make the encoder instructions available. - mem::drop(client.process(encoder_insts.dgram(), now())); + drop(client.process(encoder_insts.dgram(), now())); // Header blocks for both streams should be ready. let mut count_responses = 0; @@ -6861,7 +6861,7 @@ mod tests { ); let out = client.process_output(now()); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); // Check that server has received a reset. let stop_sending_event = |e| { @@ -6982,7 +6982,7 @@ mod tests { assert!(client.events().any(push_reset_event)); let out = client.process_output(now()); - mem::drop(server.conn.process(out.dgram(), now())); + drop(server.conn.process(out.dgram(), now())); // Check that server has received a reset. let stop_sending_event = |e| { @@ -7164,7 +7164,7 @@ mod tests { // exchange qpack settings, server will send a token as well. datagram = client.process(datagram, now()).dgram(); datagram = server.process(datagram, now()).dgram(); - mem::drop(client.process(datagram, now()).dgram()); + drop(client.process(datagram, now()).dgram()); client .events() @@ -7226,7 +7226,7 @@ mod tests { let out = server.process(out.dgram(), now()); let out = client.process(out.dgram(), now()); let out = server.process(out.dgram(), now()); - mem::drop(client.process(out.dgram(), now())); + drop(client.process(out.dgram(), now())); // The header ack for the first request has been received. assert_eq!(client.qpack_encoder_stats().header_acks_recv, 1); diff --git a/neqo-http3/src/features/extended_connect/tests/webtransport/mod.rs b/neqo-http3/src/features/extended_connect/tests/webtransport/mod.rs index 679bea1045..15b6c343cb 100644 --- a/neqo-http3/src/features/extended_connect/tests/webtransport/mod.rs +++ b/neqo-http3/src/features/extended_connect/tests/webtransport/mod.rs @@ -105,7 +105,7 @@ fn connect_with(client: &mut Http3Client, server: &mut Http3Server) { let out = server.process(out.dgram(), now()); let out = client.process(out.dgram(), now()); let out = server.process(out.dgram(), now()); - std::mem::drop(client.process(out.dgram(), now())); + drop(client.process(out.dgram(), now())); } fn connect( diff --git a/neqo-http3/src/features/extended_connect/tests/webtransport/negotiation.rs b/neqo-http3/src/features/extended_connect/tests/webtransport/negotiation.rs index b3cf405936..0c7bbb3ba7 100644 --- a/neqo-http3/src/features/extended_connect/tests/webtransport/negotiation.rs +++ b/neqo-http3/src/features/extended_connect/tests/webtransport/negotiation.rs @@ -88,7 +88,7 @@ fn zero_rtt( // exchange token let out = server.process_output(now()); // We do not have a token so we need to wait for a resumption token timer to trigger. - std::mem::drop(client.process(out.dgram(), now() + Duration::from_millis(250))); + drop(client.process(out.dgram(), now() + Duration::from_millis(250))); assert_eq!(client.state(), Http3State::Connected); let token = client .events() diff --git a/neqo-http3/src/features/extended_connect/tests/webtransport/sessions.rs b/neqo-http3/src/features/extended_connect/tests/webtransport/sessions.rs index 6b69b430c7..4c327af457 100644 --- a/neqo-http3/src/features/extended_connect/tests/webtransport/sessions.rs +++ b/neqo-http3/src/features/extended_connect/tests/webtransport/sessions.rs @@ -4,8 +4,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::mem; - use neqo_common::{event::Provider as _, header::HeadersExt as _, Encoder}; use neqo_transport::StreamType; use test_fixture::now; @@ -26,7 +24,7 @@ use crate::{ #[test] fn wt_session() { let mut wt = WtTest::new(); - mem::drop(wt.create_wt_session()); + drop(wt.create_wt_session()); } #[test] diff --git a/neqo-http3/src/features/extended_connect/tests/webtransport/streams.rs b/neqo-http3/src/features/extended_connect/tests/webtransport/streams.rs index 07a761206f..73db34ca7e 100644 --- a/neqo-http3/src/features/extended_connect/tests/webtransport/streams.rs +++ b/neqo-http3/src/features/extended_connect/tests/webtransport/streams.rs @@ -4,8 +4,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::mem; - use neqo_transport::StreamType; use crate::{ @@ -94,7 +92,7 @@ fn wt_server_stream_bidi() { wt.send_data_server(&wt_server_stream, BUF_SERVER); wt.receive_data_client(wt_server_stream.stream_id(), true, BUF_SERVER, false); wt.send_data_client(wt_server_stream.stream_id(), BUF_CLIENT); - mem::drop(wt.receive_data_server(wt_server_stream.stream_id(), false, BUF_CLIENT, false)); + drop(wt.receive_data_server(wt_server_stream.stream_id(), false, BUF_CLIENT, false)); let stats = wt.send_stream_stats(wt_server_stream.stream_id()).unwrap(); assert_eq!(stats.bytes_written(), BUF_CLIENT.len() as u64); assert_eq!(stats.bytes_sent(), BUF_CLIENT.len() as u64); @@ -161,7 +159,7 @@ fn wt_server_stream_bidi_close() { wt.receive_data_client(wt_server_stream.stream_id(), true, BUF_SERVER, true); wt.send_data_client(wt_server_stream.stream_id(), BUF_CLIENT); wt.close_stream_sending_client(wt_server_stream.stream_id()); - mem::drop(wt.receive_data_server(wt_server_stream.stream_id(), false, BUF_CLIENT, true)); + drop(wt.receive_data_server(wt_server_stream.stream_id(), false, BUF_CLIENT, true)); } #[test] @@ -172,7 +170,7 @@ fn wt_client_stream_uni_reset() { let wt_session = wt.create_wt_session(); let wt_stream = wt.create_wt_stream_client(wt_session.stream_id(), StreamType::UniDi); wt.send_data_client(wt_stream, BUF_CLIENT); - mem::drop(wt.receive_data_server(wt_stream, true, BUF_CLIENT, false)); + drop(wt.receive_data_server(wt_stream, true, BUF_CLIENT, false)); wt.reset_stream_client(wt_stream); wt.receive_reset_server(wt_stream, Error::HttpNoError.code()); } @@ -315,7 +313,7 @@ fn wt_client_session_close_1() { let bidi_from_client = wt.create_wt_stream_client(wt_session.stream_id(), StreamType::BiDi); wt.send_data_client(bidi_from_client, BUF); - std::mem::drop(wt.receive_data_server(bidi_from_client, true, BUF, false)); + drop(wt.receive_data_server(bidi_from_client, true, BUF, false)); wt.cancel_session_client(wt_session.stream_id()); @@ -350,7 +348,7 @@ fn wt_client_session_close_2() { let unidi_from_client = wt.create_wt_stream_client(wt_session.stream_id(), StreamType::UniDi); wt.send_data_client(unidi_from_client, BUF); - std::mem::drop(wt.receive_data_server(unidi_from_client, true, BUF, false)); + drop(wt.receive_data_server(unidi_from_client, true, BUF, false)); wt.cancel_session_client(wt_session.stream_id()); @@ -385,7 +383,7 @@ fn wt_client_session_close_3() { let unidi_from_client = wt.create_wt_stream_client(wt_session.stream_id(), StreamType::UniDi); wt.send_data_client(unidi_from_client, BUF); - std::mem::drop(wt.receive_data_server(unidi_from_client, true, BUF, false)); + drop(wt.receive_data_server(unidi_from_client, true, BUF, false)); wt.close_stream_sending_client(unidi_from_client); wt.cancel_session_client(wt_session.stream_id()); @@ -450,7 +448,7 @@ fn wt_client_session_close_5() { let unidi_from_client = wt.create_wt_stream_client(wt_session.stream_id(), StreamType::UniDi); wt.send_data_client(unidi_from_client, BUF); - mem::drop(wt.receive_data_server(unidi_from_client, true, BUF, false)); + drop(wt.receive_data_server(unidi_from_client, true, BUF, false)); wt.reset_stream_client(unidi_from_client); wt.cancel_session_client(wt_session.stream_id()); @@ -700,10 +698,10 @@ fn wt_client_session_close_13() { let bidi_client_1 = wt.create_wt_stream_client(wt_session.stream_id(), StreamType::BiDi); wt.send_data_client(bidi_client_1, BUF); - std::mem::drop(wt.receive_data_server(bidi_client_1, true, BUF, false)); + drop(wt.receive_data_server(bidi_client_1, true, BUF, false)); let bidi_client_2 = wt.create_wt_stream_client(wt_session.stream_id(), StreamType::BiDi); wt.send_data_client(bidi_client_2, BUF); - std::mem::drop(wt.receive_data_server(bidi_client_2, true, BUF, false)); + drop(wt.receive_data_server(bidi_client_2, true, BUF, false)); wt.cancel_session_client(wt_session.stream_id()); @@ -750,7 +748,7 @@ fn wt_client_session_server_close_1() { let bidi_client = wt.create_wt_stream_client(wt_session.stream_id(), StreamType::BiDi); wt.send_data_client(bidi_client, BUF); - std::mem::drop(wt.receive_data_server(bidi_client, true, BUF, false)); + drop(wt.receive_data_server(bidi_client, true, BUF, false)); wt.cancel_session_server(&wt_session); @@ -784,7 +782,7 @@ fn wt_client_session_server_close_2() { let unidi_client = wt.create_wt_stream_client(wt_session.stream_id(), StreamType::UniDi); wt.send_data_client(unidi_client, BUF); - std::mem::drop(wt.receive_data_server(unidi_client, true, BUF, false)); + drop(wt.receive_data_server(unidi_client, true, BUF, false)); wt.cancel_session_server(&wt_session); @@ -1064,10 +1062,10 @@ fn wt_client_session_server_close_11() { let bidi_client_1 = wt.create_wt_stream_client(wt_session.stream_id(), StreamType::BiDi); wt.send_data_client(bidi_client_1, BUF); - std::mem::drop(wt.receive_data_server(bidi_client_1, true, BUF, false)); + drop(wt.receive_data_server(bidi_client_1, true, BUF, false)); let bidi_client_2 = wt.create_wt_stream_client(wt_session.stream_id(), StreamType::BiDi); wt.send_data_client(bidi_client_2, BUF); - std::mem::drop(wt.receive_data_server(bidi_client_2, true, BUF, false)); + drop(wt.receive_data_server(bidi_client_2, true, BUF, false)); wt.cancel_session_server(&wt_session); diff --git a/neqo-http3/src/frames/tests/mod.rs b/neqo-http3/src/frames/tests/mod.rs index ce5e674e86..3f93c11547 100644 --- a/neqo-http3/src/frames/tests/mod.rs +++ b/neqo-http3/src/frames/tests/mod.rs @@ -4,8 +4,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::mem; - use neqo_common::Encoder; use neqo_crypto::AuthenticationStatus; use neqo_transport::StreamType; @@ -25,10 +23,10 @@ pub fn enc_dec>(d: &Encoder, st: &str, remaining: usize) -> T let out = conn_c.process_output(now()); let out = conn_s.process(out.dgram(), now()); let out = conn_c.process(out.dgram(), now()); - mem::drop(conn_s.process(out.dgram(), now())); + drop(conn_s.process(out.dgram(), now())); conn_c.authenticated(AuthenticationStatus::Ok, now()); let out = conn_c.process_output(now()); - mem::drop(conn_s.process(out.dgram(), now())); + drop(conn_s.process(out.dgram(), now())); // create a stream let stream_id = conn_s.stream_create(StreamType::BiDi).unwrap(); @@ -39,7 +37,7 @@ pub fn enc_dec>(d: &Encoder, st: &str, remaining: usize) -> T let buf = Encoder::from_hex(st); conn_s.stream_send(stream_id, buf.as_ref()).unwrap(); let out = conn_s.process_output(now()); - mem::drop(conn_c.process(out.dgram(), now())); + drop(conn_c.process(out.dgram(), now())); let (frame, fin) = fr .receive::(&mut StreamReaderConnectionWrapper::new( diff --git a/neqo-http3/src/frames/tests/reader.rs b/neqo-http3/src/frames/tests/reader.rs index 5e0596d5d3..0aaba04a93 100644 --- a/neqo-http3/src/frames/tests/reader.rs +++ b/neqo-http3/src/frames/tests/reader.rs @@ -4,7 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{fmt::Debug, mem}; +use std::fmt::Debug; use neqo_common::Encoder; use neqo_transport::{Connection, StreamId, StreamType}; @@ -40,7 +40,7 @@ impl FrameReaderTest { fn process>(&mut self, v: &[u8]) -> Option { self.conn_s.stream_send(self.stream_id, v).unwrap(); let out = self.conn_s.process_output(now()); - mem::drop(self.conn_c.process(out.dgram(), now())); + drop(self.conn_c.process(out.dgram(), now())); let (frame, fin) = self .fr .receive::(&mut StreamReaderConnectionWrapper::new( @@ -231,12 +231,12 @@ fn test_reading_frame + PartialEq + Debug>( } let out = fr.conn_s.process_output(now()); - mem::drop(fr.conn_c.process(out.dgram(), now())); + drop(fr.conn_c.process(out.dgram(), now())); if matches!(test_to_send, FrameReadingTestSend::DataThenFin) { fr.conn_s.stream_close_send(fr.stream_id).unwrap(); let out = fr.conn_s.process_output(now()); - mem::drop(fr.conn_c.process(out.dgram(), now())); + drop(fr.conn_c.process(out.dgram(), now())); } let rv = fr.fr.receive::(&mut StreamReaderConnectionWrapper::new( @@ -483,11 +483,11 @@ fn frame_reading_when_stream_is_closed_before_sending_data() { fr.conn_s.stream_send(fr.stream_id, &[0x00]).unwrap(); let out = fr.conn_s.process_output(now()); - mem::drop(fr.conn_c.process(out.dgram(), now())); + drop(fr.conn_c.process(out.dgram(), now())); assert_eq!(Ok(()), fr.conn_c.stream_close_send(fr.stream_id)); let out = fr.conn_c.process_output(now()); - mem::drop(fr.conn_s.process(out.dgram(), now())); + drop(fr.conn_s.process(out.dgram(), now())); assert_eq!( Ok((None, true)), fr.fr @@ -506,11 +506,11 @@ fn wt_frame_reading_when_stream_is_closed_before_sending_data() { fr.conn_s.stream_send(fr.stream_id, &[0x00]).unwrap(); let out = fr.conn_s.process_output(now()); - mem::drop(fr.conn_c.process(out.dgram(), now())); + drop(fr.conn_c.process(out.dgram(), now())); assert_eq!(Ok(()), fr.conn_c.stream_close_send(fr.stream_id)); let out = fr.conn_c.process_output(now()); - mem::drop(fr.conn_s.process(out.dgram(), now())); + drop(fr.conn_s.process(out.dgram(), now())); assert_eq!( Ok((None, true)), fr.fr diff --git a/neqo-http3/src/push_controller.rs b/neqo-http3/src/push_controller.rs index 5de184caf1..48ce43be3c 100644 --- a/neqo-http3/src/push_controller.rs +++ b/neqo-http3/src/push_controller.rs @@ -308,7 +308,7 @@ impl PushController { } PushState::OnlyPushStream { stream_id, .. } | PushState::Active { stream_id, .. } => { - mem::drop(base_handler.stream_stop_sending( + drop(base_handler.stream_stop_sending( conn, stream_id, Error::HttpRequestCancelled.code(), @@ -363,7 +363,7 @@ impl PushController { Some(PushState::Active { stream_id, .. }) => { self.conn_events.remove_events_for_push_id(push_id); // Cancel the stream. The transport stream may already be done, so ignore an error. - mem::drop(base_handler.stream_stop_sending( + drop(base_handler.stream_stop_sending( conn, *stream_id, Error::HttpRequestCancelled.code(), diff --git a/neqo-http3/src/server.rs b/neqo-http3/src/server.rs index f923ec0c2f..8f431f8b5f 100644 --- a/neqo-http3/src/server.rs +++ b/neqo-http3/src/server.rs @@ -311,7 +311,6 @@ fn prepare_data( mod tests { use std::{ collections::HashMap, - mem, ops::{Deref, DerefMut}, }; @@ -506,7 +505,7 @@ mod tests { // The server will open the control and qpack streams and send SETTINGS frame. #[test] fn server_connect() { - mem::drop(connect_and_receive_settings()); + drop(connect_and_receive_settings()); } struct PeerConnection { @@ -559,7 +558,7 @@ mod tests { assert_eq!(sent, Ok(1)); let out1 = neqo_trans_conn.process_output(now()); let out2 = server.process(out1.dgram(), now()); - mem::drop(neqo_trans_conn.process(out2.dgram(), now())); + drop(neqo_trans_conn.process(out2.dgram(), now())); // assert no error occurred. assert_not_closed(server); @@ -579,7 +578,7 @@ mod tests { // Server: Test receiving a new control stream and a SETTINGS frame. #[test] fn server_receive_control_frame() { - mem::drop(connect()); + drop(connect()); } // Server: Test that the connection will be closed if control stream @@ -710,9 +709,9 @@ mod tests { .unwrap(); let out = peer_conn.process_output(now()); let out = hconn.process(out.dgram(), now()); - mem::drop(peer_conn.process(out.dgram(), now())); + drop(peer_conn.process(out.dgram(), now())); let out = hconn.process_output(now()); - mem::drop(peer_conn.process(out.dgram(), now())); + drop(peer_conn.process(out.dgram(), now())); // check for stop-sending with Error::HttpStreamCreation. let mut stop_sending_event_found = false; @@ -741,7 +740,7 @@ mod tests { _ = peer_conn.stream_send(push_stream_id, &[0x1]).unwrap(); let out = peer_conn.process_output(now()); let out = hconn.process(out.dgram(), now()); - mem::drop(peer_conn.conn.process(out.dgram(), now())); + drop(peer_conn.conn.process(out.dgram(), now())); assert_closed(&hconn, &Error::HttpStreamCreation); } diff --git a/neqo-http3/src/stream_type_reader.rs b/neqo-http3/src/stream_type_reader.rs index eda564bd45..e05ad8c060 100644 --- a/neqo-http3/src/stream_type_reader.rs +++ b/neqo-http3/src/stream_type_reader.rs @@ -237,8 +237,6 @@ impl RecvStream for NewStreamHeadReader { #[cfg(test)] mod tests { - use std::mem; - use neqo_common::{Encoder, Role}; use neqo_qpack::{ decoder::QPACK_UNI_STREAM_TYPE_DECODER, encoder::QPACK_UNI_STREAM_TYPE_ENCODER, @@ -269,7 +267,7 @@ mod tests { // create a stream let stream_id = conn_s.stream_create(stream_type).unwrap(); let out = conn_s.process_output(now()); - mem::drop(conn_c.process(out.dgram(), now())); + drop(conn_c.process(out.dgram(), now())); Self { conn_c, @@ -292,7 +290,7 @@ mod tests { .stream_send(self.stream_id, &enc[i..=i]) .unwrap(); let out = self.conn_s.process_output(now()); - mem::drop(self.conn_c.process(out.dgram(), now())); + drop(self.conn_c.process(out.dgram(), now())); assert_eq!( self.decoder.receive(&mut self.conn_c).unwrap(), (ReceiveOutput::NoOutput, false) @@ -306,7 +304,7 @@ mod tests { self.conn_s.stream_close_send(self.stream_id).unwrap(); } let out = self.conn_s.process_output(now()); - mem::drop(self.conn_c.process(out.dgram(), now())); + drop(self.conn_c.process(out.dgram(), now())); assert_eq!(&self.decoder.receive(&mut self.conn_c), outcome); assert_eq!(self.decoder.done(), done); } diff --git a/neqo-http3/tests/httpconn.rs b/neqo-http3/tests/httpconn.rs index 72a11c7235..efe138ee00 100644 --- a/neqo-http3/tests/httpconn.rs +++ b/neqo-http3/tests/httpconn.rs @@ -4,10 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{ - mem, - time::{Duration, Instant}, -}; +use std::time::{Duration, Instant}; use neqo_common::{event::Provider as _, qtrace, Datagram}; use neqo_crypto::{AuthenticationStatus, ResumptionToken}; @@ -97,7 +94,7 @@ fn connect_peers(hconn_c: &mut Http3Client, hconn_s: &mut Http3Server) -> Option let out = hconn_c.process_output(now()); // Initial let out = hconn_s.process(out.dgram(), now()); // Initial + Handshake let out = hconn_c.process(out.dgram(), now()); // ACK - mem::drop(hconn_s.process(out.dgram(), now())); // consume ACK + drop(hconn_s.process(out.dgram(), now())); // consume ACK let authentication_needed = |e| matches!(e, Http3ClientEvent::AuthenticationNeeded); assert!(hconn_c.events().any(authentication_needed)); hconn_c.authenticated(AuthenticationStatus::Ok, now()); @@ -189,14 +186,14 @@ fn fetch() { let out = hconn_c.process(dgram, now()); qtrace!("-----server"); let out = hconn_s.process(out.dgram(), now()); - mem::drop(hconn_c.process(out.dgram(), now())); + drop(hconn_c.process(out.dgram(), now())); process_server_events(&hconn_s); let out = hconn_s.process(None::, now()); qtrace!("-----client"); - mem::drop(hconn_c.process(out.dgram(), now())); + drop(hconn_c.process(out.dgram(), now())); let out = hconn_s.process(None::, now()); - mem::drop(hconn_c.process(out.dgram(), now())); + drop(hconn_c.process(out.dgram(), now())); process_client_events(&mut hconn_c); } @@ -218,7 +215,7 @@ fn response_103() { let out = hconn_c.process(dgram, now()); let out = hconn_s.process(out.dgram(), now()); - mem::drop(hconn_c.process(out.dgram(), now())); + drop(hconn_c.process(out.dgram(), now())); let request = receive_request(&hconn_s).unwrap(); let info_headers = [ Header::new(":status", "103"), @@ -228,7 +225,7 @@ fn response_103() { request.send_headers(&info_headers).unwrap(); let out = hconn_s.process(None::, now()); - mem::drop(hconn_c.process(out.dgram(), now())); + drop(hconn_c.process(out.dgram(), now())); let info_headers_event = |e| { matches!(e, Http3ClientEvent::HeaderReady { headers, @@ -239,7 +236,7 @@ fn response_103() { set_response(&request); let out = hconn_s.process(None::, now()); - mem::drop(hconn_c.process(out.dgram(), now())); + drop(hconn_c.process(out.dgram(), now())); process_client_events(&mut hconn_c); } @@ -256,7 +253,7 @@ fn data_writable_events_low_watermark() -> Result<(), Box ConnectionParameters::default().max_stream_data(StreamType::BiDi, false, STREAM_LIMIT), )); let mut hconn_s = default_http3_server(); - mem::drop(connect_peers(&mut hconn_c, &mut hconn_s)); + drop(connect_peers(&mut hconn_c, &mut hconn_s)); // Client sends GET to server. let stream_id = hconn_c.fetch( @@ -330,7 +327,7 @@ fn data_writable_events() { )); let mut hconn_s = default_http3_server(); - mem::drop(connect_peers(&mut hconn_c, &mut hconn_s)); + drop(connect_peers(&mut hconn_c, &mut hconn_s)); // Create a request. let req = hconn_c diff --git a/neqo-qpack/src/decoder.rs b/neqo-qpack/src/decoder.rs index 0a72e3ee7f..6b79c53913 100644 --- a/neqo-qpack/src/decoder.rs +++ b/neqo-qpack/src/decoder.rs @@ -285,8 +285,6 @@ fn map_error(err: &Error) -> Error { #[cfg(test)] mod tests { - use std::mem; - use neqo_common::Header; use neqo_transport::{StreamId, StreamType}; use test_fixture::now; @@ -334,7 +332,7 @@ mod tests { .stream_send(decoder.recv_stream_id, encoder_instruction) .unwrap(); let out = decoder.peer_conn.process_output(now()); - mem::drop(decoder.conn.process(out.dgram(), now())); + drop(decoder.conn.process(out.dgram(), now())); assert_eq!( decoder .decoder @@ -346,7 +344,7 @@ mod tests { fn send_instructions_and_check(decoder: &mut TestDecoder, decoder_instruction: &[u8]) { decoder.decoder.send(&mut decoder.conn).unwrap(); let out = decoder.conn.process_output(now()); - mem::drop(decoder.peer_conn.process(out.dgram(), now())); + drop(decoder.peer_conn.process(out.dgram(), now())); let mut buf = [0_u8; 100]; let (amount, fin) = decoder .peer_conn diff --git a/neqo-qpack/src/encoder.rs b/neqo-qpack/src/encoder.rs index d791b57165..bf0ca105dd 100644 --- a/neqo-qpack/src/encoder.rs +++ b/neqo-qpack/src/encoder.rs @@ -528,8 +528,6 @@ fn map_stream_send_atomic_error(err: &TransportError) -> Error { #[cfg(test)] mod tests { - use std::mem; - use neqo_transport::{ConnectionParameters, StreamId, StreamType}; use test_fixture::{default_client, default_server, handshake, new_server, now, DEFAULT_ALPN}; @@ -576,7 +574,7 @@ mod tests { self.encoder.send_encoder_updates(&mut self.conn).unwrap(); let out = self.conn.process_output(now()); let out2 = self.peer_conn.process(out.dgram(), now()); - mem::drop(self.conn.process(out2.dgram(), now())); + drop(self.conn.process(out2.dgram(), now())); let mut buf = [0_u8; 100]; let (amount, fin) = self .peer_conn @@ -638,7 +636,7 @@ mod tests { .stream_send(encoder.recv_stream_id, decoder_instruction) .unwrap(); let out = encoder.peer_conn.process_output(now()); - mem::drop(encoder.conn.process(out.dgram(), now())); + drop(encoder.conn.process(out.dgram(), now())); assert!(encoder .encoder .read_instructions(&mut encoder.conn, encoder.recv_stream_id) @@ -1566,7 +1564,7 @@ mod tests { // exchange a flow control update. let out = encoder.peer_conn.process_output(now()); - mem::drop(encoder.conn.process(out.dgram(), now())); + drop(encoder.conn.process(out.dgram(), now())); // Try writing a new header block. Now, headers will be added to the dynamic table again, // because instructions can be sent. @@ -1613,7 +1611,7 @@ mod tests { .send_encoder_updates(&mut encoder.conn) .unwrap(); let out = encoder.conn.process_output(now()); - mem::drop(encoder.peer_conn.process(out.dgram(), now())); + drop(encoder.peer_conn.process(out.dgram(), now())); // receive an insert count increment. recv_instruction(&mut encoder, &[0x01]); diff --git a/neqo-transport/src/cid.rs b/neqo-transport/src/cid.rs index 666a3cf3a6..72587da5ba 100644 --- a/neqo-transport/src/cid.rs +++ b/neqo-transport/src/cid.rs @@ -10,7 +10,7 @@ use std::{ borrow::Borrow, cell::{Ref, RefCell}, cmp::{max, min}, - ops::Deref as _, + ops::Deref, rc::Rc, }; @@ -93,7 +93,7 @@ impl<'a> From> for ConnectionId { } } -impl std::ops::Deref for ConnectionId { +impl Deref for ConnectionId { type Target = [u8]; fn deref(&self) -> &Self::Target { @@ -142,7 +142,7 @@ impl<'a, T: AsRef<[u8]> + ?Sized> From<&'a T> for ConnectionIdRef<'a> { } } -impl std::ops::Deref for ConnectionIdRef<'_> { +impl Deref for ConnectionIdRef<'_> { type Target = [u8]; fn deref(&self) -> &Self::Target { diff --git a/neqo-transport/src/connection/mod.rs b/neqo-transport/src/connection/mod.rs index cf2b6218b8..d5943b40c5 100644 --- a/neqo-transport/src/connection/mod.rs +++ b/neqo-transport/src/connection/mod.rs @@ -1823,7 +1823,7 @@ impl Connection { self.setup_handshake_path(path, now); } else { // Otherwise try to get a usable connection ID. - mem::drop(self.ensure_permanent(path, now)); + drop(self.ensure_permanent(path, now)); } } } @@ -2100,7 +2100,7 @@ impl Connection { let pn = tx.next_pn(); let unacked_range = largest_acknowledged.map_or_else(|| pn + 1, |la| (pn - la) << 1); // Count how many bytes in this range are non-zero. - let pn_len = mem::size_of::() + let pn_len = std::mem::size_of::() - usize::try_from(unacked_range.leading_zeros() / 8).unwrap(); assert!( pn_len > 0, @@ -3595,7 +3595,7 @@ impl ::std::fmt::Display for Connection { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { write!(f, "{:?} ", self.role)?; if let Some(cid) = self.odcid() { - std::fmt::Display::fmt(&cid, f) + fmt::Display::fmt(&cid, f) } else { write!(f, "...") } diff --git a/neqo-transport/src/connection/tests/ackrate.rs b/neqo-transport/src/connection/tests/ackrate.rs index 8d7a560d2b..b1bded087e 100644 --- a/neqo-transport/src/connection/tests/ackrate.rs +++ b/neqo-transport/src/connection/tests/ackrate.rs @@ -4,7 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{mem, time::Duration}; +use std::time::Duration; use test_fixture::{assertions, DEFAULT_ADDR_V4}; @@ -94,7 +94,7 @@ fn ack_rate_persistent_congestion() { let stream = client.stream_create(StreamType::UniDi).unwrap(); let (dgrams, mut now) = fill_cwnd(&mut client, stream, now); now += RTT / 2; - mem::drop(ack_bytes(&mut server, stream, dgrams, now)); + drop(ack_bytes(&mut server, stream, dgrams, now)); let now = induce_persistent_congestion(&mut client, &mut server, stream, now); diff --git a/neqo-transport/src/connection/tests/cc.rs b/neqo-transport/src/connection/tests/cc.rs index 09bcefb7a4..97e5eae93f 100644 --- a/neqo-transport/src/connection/tests/cc.rs +++ b/neqo-transport/src/connection/tests/cc.rs @@ -4,7 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{mem, time::Duration}; +use std::time::Duration; use neqo_common::{qdebug, qinfo, Datagram, IpTosEcn}; @@ -304,7 +304,7 @@ fn cc_slow_start_to_persistent_congestion_no_acks() { // Server: Receive and generate ack now += DEFAULT_RTT / 2; - mem::drop(ack_bytes(&mut server, stream, c_tx_dgrams, now)); + drop(ack_bytes(&mut server, stream, c_tx_dgrams, now)); // ACK lost. induce_persistent_congestion(&mut client, &mut server, stream, now); @@ -355,7 +355,7 @@ fn cc_persistent_congestion_to_slow_start() { // Server: Receive and generate ack now += Duration::from_millis(10); - mem::drop(ack_bytes(&mut server, stream, c_tx_dgrams, now)); + drop(ack_bytes(&mut server, stream, c_tx_dgrams, now)); // ACK lost. diff --git a/neqo-transport/src/connection/tests/handshake.rs b/neqo-transport/src/connection/tests/handshake.rs index 5c21d418d4..c9ff3a5f41 100644 --- a/neqo-transport/src/connection/tests/handshake.rs +++ b/neqo-transport/src/connection/tests/handshake.rs @@ -6,7 +6,6 @@ use std::{ cell::RefCell, - mem, net::{IpAddr, Ipv6Addr, SocketAddr}, rc::Rc, time::Duration, @@ -251,8 +250,8 @@ fn crypto_frame_split() { // after the first or second server packet. assert!(client3.as_dgram_ref().is_some() ^ client4.as_dgram_ref().is_some()); - mem::drop(server.process(client3.dgram(), now())); - mem::drop(server.process(client4.dgram(), now())); + drop(server.process(client3.dgram(), now())); + drop(server.process(client4.dgram(), now())); assert_eq!(*client.state(), State::Connected); assert_eq!(*server.state(), State::Confirmed); @@ -371,7 +370,7 @@ fn reorder_05rtt_with_0rtt() { // Send ClientHello and some 0-RTT. let c1 = send_something(&mut client, now); - assertions::assert_coalesced_0rtt(&c1[..]); + assert_coalesced_0rtt(&c1[..]); // Drop the 0-RTT from the coalesced datagram, so that the server // acknowledges the next 0-RTT packet. let (c1, _) = split_datagram(&c1); @@ -379,7 +378,7 @@ fn reorder_05rtt_with_0rtt() { // Handle the first packet and send 0.5-RTT in response. Drop the response. now += RTT / 2; - mem::drop(server.process(Some(c1), now).dgram().unwrap()); + drop(server.process(Some(c1), now).dgram().unwrap()); // The gap in 0-RTT will result in this 0.5 RTT containing an ACK. server.process_input(c2, now); let s2 = send_something(&mut server, now); @@ -452,7 +451,7 @@ fn coalesce_05rtt() { // packet until authentication completes though. So it saves it. now += RTT / 2; assert_eq!(client.stats().dropped_rx, 0); - mem::drop(client.process(s2, now).dgram()); + drop(client.process(s2, now).dgram()); // This packet will contain an ACK, but we can ignore it. assert_eq!(client.stats().dropped_rx, 0); assert_eq!(client.stats().packets_rx, 3); @@ -473,7 +472,7 @@ fn coalesce_05rtt() { assert!(s3.is_some()); assert_eq!(*server.state(), State::Confirmed); now += RTT / 2; - mem::drop(client.process(s3, now).dgram()); + drop(client.process(s3, now).dgram()); assert_eq!(*client.state(), State::Confirmed); assert_eq!(client.stats().dropped_rx, 0); // No dropped packets. @@ -861,7 +860,7 @@ fn drop_handshake_packet_from_wrong_address() { let (s_in, s_hs) = split_datagram(&out.dgram().unwrap()); // Pass the initial packet. - mem::drop(client.process(Some(s_in), now()).dgram()); + drop(client.process(Some(s_in), now()).dgram()); let p = s_hs.unwrap(); let dgram = Datagram::new( diff --git a/neqo-transport/src/connection/tests/idle.rs b/neqo-transport/src/connection/tests/idle.rs index 024d0f9157..3d209f049d 100644 --- a/neqo-transport/src/connection/tests/idle.rs +++ b/neqo-transport/src/connection/tests/idle.rs @@ -4,10 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{ - mem, - time::{Duration, Instant}, -}; +use std::time::{Duration, Instant}; use neqo_common::{qtrace, Encoder}; use test_fixture::{now, split_datagram}; @@ -44,10 +41,10 @@ fn test_idle_timeout(client: &mut Connection, server: &mut Connection, timeout: assert_eq!(res, Output::Callback(timeout)); // Still connected after timeout-1 seconds. Idle timer not reset - mem::drop(client.process_output(now + timeout.checked_sub(Duration::from_secs(1)).unwrap())); + drop(client.process_output(now + timeout.checked_sub(Duration::from_secs(1)).unwrap())); assert!(matches!(client.state(), State::Confirmed)); - mem::drop(client.process_output(now + timeout)); + drop(client.process_output(now + timeout)); // Not connected after timeout. assert!(matches!(client.state(), State::Closed(_))); @@ -220,10 +217,10 @@ fn idle_send_packet2() { // First transmission at t=GAP. now += GAP; - mem::drop(send_something(&mut client, now)); + drop(send_something(&mut client, now)); // Second transmission at t=2*GAP. - mem::drop(send_something(&mut client, now + GAP)); + drop(send_something(&mut client, now + GAP)); assert!((GAP * 2 + DELTA) < default_timeout()); // Still connected just before GAP + default_timeout(). @@ -266,16 +263,16 @@ fn idle_recv_packet() { assert_eq!(server.stream_send(stream, b"world").unwrap(), 5); let out = server.process_output(now); assert_ne!(out.as_dgram_ref(), None); - mem::drop(client.process(out.dgram(), now)); + drop(client.process(out.dgram(), now)); assert!(matches!(client.state(), State::Confirmed)); // Add a little less than the idle timeout and we're still connected. now += default_timeout() - FUDGE; - mem::drop(client.process_output(now)); + drop(client.process_output(now)); assert!(matches!(client.state(), State::Confirmed)); now += FUDGE; - mem::drop(client.process_output(now)); + drop(client.process_output(now)); assert!(matches!(client.state(), State::Closed(_))); } @@ -303,7 +300,7 @@ fn idle_caching() { let dgram = client.process_output(middle).dgram(); // Get the server to send its first probe and throw that away. - mem::drop(server.process_output(middle).dgram()); + drop(server.process_output(middle).dgram()); // Now let the server process the RTX'ed client Initial. This causes the server // to send CRYPTO frames again, so manually extract and discard those. server.process_input(dgram.unwrap(), middle); @@ -339,7 +336,7 @@ fn idle_caching() { let dgram = server.process_output(end).dgram(); let (initial, _) = split_datagram(&dgram.unwrap()); neqo_common::qwarn!("client ingests initial, finally"); - mem::drop(client.process(Some(initial), end)); + drop(client.process(Some(initial), end)); maybe_authenticate(&mut client); let dgram = client.process_output(end).dgram(); let dgram = server.process(dgram, end).dgram(); diff --git a/neqo-transport/src/connection/tests/keys.rs b/neqo-transport/src/connection/tests/keys.rs index 59bbc2f24c..d8686b7943 100644 --- a/neqo-transport/src/connection/tests/keys.rs +++ b/neqo-transport/src/connection/tests/keys.rs @@ -4,8 +4,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::mem; - use neqo_common::{qdebug, Datagram}; use test_fixture::now; @@ -30,7 +28,7 @@ fn check_discarded( dups: usize, ) { // Make sure to flush any saved datagrams before doing this. - mem::drop(peer.process_output(now())); + drop(peer.process_output(now())); let before = peer.stats(); let out = peer.process(Some(pkt.clone()), now()); @@ -145,7 +143,7 @@ fn key_update_client() { let dgram = client.process_output(now).dgram(); assert!(dgram.is_some()); // Drop this packet. assert_eq!(client.get_epochs(), (Some(4), Some(3))); - mem::drop(server.process_output(now)); + drop(server.process_output(now)); assert_eq!(server.get_epochs(), (Some(4), Some(4))); // Even though the server has updated, it hasn't received an ACK yet. @@ -170,7 +168,7 @@ fn key_update_client() { assert_update_blocked(&mut server); now += AT_LEAST_PTO; - mem::drop(client.process_output(now)); + drop(client.process_output(now)); assert_eq!(client.get_epochs(), (Some(4), Some(4))); } @@ -186,7 +184,7 @@ fn key_update_consecutive() { // Server sends something. // Send twice and drop the first to induce an ACK from the client. - mem::drop(send_something(&mut server, now)); // Drop this. + drop(send_something(&mut server, now)); // Drop this. // Another packet from the server will cause the client to ACK and update keys. let dgram = send_and_receive(&mut server, &mut client, now); @@ -198,7 +196,7 @@ fn key_update_consecutive() { assert_eq!(server.get_epochs(), (Some(4), Some(3))); // Now move the server temporarily into the future so that it // rotates the keys. The client stays in the present. - mem::drop(server.process_output(now + AT_LEAST_PTO)); + drop(server.process_output(now + AT_LEAST_PTO)); assert_eq!(server.get_epochs(), (Some(4), Some(4))); } else { panic!("server should have a timer set"); @@ -304,7 +302,7 @@ fn automatic_update_write_keys() { connect_force_idle(&mut client, &mut server); overwrite_invocations(UPDATE_WRITE_KEYS_AT); - mem::drop(send_something(&mut client, now())); + drop(send_something(&mut client, now())); assert_eq!(client.get_epochs(), (Some(4), Some(3))); } @@ -316,10 +314,10 @@ fn automatic_update_write_keys_later() { overwrite_invocations(UPDATE_WRITE_KEYS_AT + 2); // No update after the first. - mem::drop(send_something(&mut client, now())); + drop(send_something(&mut client, now())); assert_eq!(client.get_epochs(), (Some(3), Some(3))); // The second will update though. - mem::drop(send_something(&mut client, now())); + drop(send_something(&mut client, now())); assert_eq!(client.get_epochs(), (Some(4), Some(3))); } diff --git a/neqo-transport/src/connection/tests/migration.rs b/neqo-transport/src/connection/tests/migration.rs index 1f83ced0b6..283564b86a 100644 --- a/neqo-transport/src/connection/tests/migration.rs +++ b/neqo-transport/src/connection/tests/migration.rs @@ -6,7 +6,6 @@ use std::{ cell::RefCell, - mem, net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}, rc::Rc, time::{Duration, Instant}, @@ -1229,7 +1228,7 @@ fn error_on_new_path_with_no_connection_id() { // See issue #1697. We had a crash when the client had a temporary path and // process_output is called. let closing_frames = client.stats().frame_tx.connection_close; - mem::drop(client.process_output(now())); + drop(client.process_output(now())); assert!(matches!( client.state(), State::Closing { diff --git a/neqo-transport/src/connection/tests/mod.rs b/neqo-transport/src/connection/tests/mod.rs index 7e75ac1379..0183d0482b 100644 --- a/neqo-transport/src/connection/tests/mod.rs +++ b/neqo-transport/src/connection/tests/mod.rs @@ -180,7 +180,7 @@ pub fn rttvar_after_n_updates(n: usize, rtt: Duration) -> Duration { /// This inserts a PING frame into packets. struct PingWriter {} -impl crate::connection::test_internal::FrameWriter for PingWriter { +impl test_internal::FrameWriter for PingWriter { fn write_frames(&mut self, builder: &mut PacketBuilder) { builder.encode_varint(FRAME_TYPE_PING); } diff --git a/neqo-transport/src/connection/tests/priority.rs b/neqo-transport/src/connection/tests/priority.rs index 9ae9ae4778..e770d08f31 100644 --- a/neqo-transport/src/connection/tests/priority.rs +++ b/neqo-transport/src/connection/tests/priority.rs @@ -4,7 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{cell::RefCell, mem, rc::Rc}; +use std::{cell::RefCell, rc::Rc}; use neqo_common::event::Provider as _; use test_fixture::now; @@ -243,7 +243,7 @@ fn critical() { // Critical beats everything but HANDSHAKE_DONE. let stats_before = server.stats().frame_tx; - mem::drop(fill_cwnd(&mut server, id, now)); + drop(fill_cwnd(&mut server, id, now)); let stats_after = server.stats().frame_tx; assert_eq!(stats_after.crypto, stats_before.crypto); assert_eq!(stats_after.streams_blocked, 0); @@ -295,7 +295,7 @@ fn important() { // Important beats everything but flow control. let stats_before = server.stats().frame_tx; - mem::drop(fill_cwnd(&mut server, id, now)); + drop(fill_cwnd(&mut server, id, now)); let stats_after = server.stats().frame_tx; assert_eq!(stats_after.crypto, stats_before.crypto); assert_eq!(stats_after.streams_blocked, 1); @@ -350,7 +350,7 @@ fn high_normal() { // but they beat CRYPTO/NEW_TOKEN. let stats_before = server.stats().frame_tx; server.send_ticket(now, &[]).unwrap(); - mem::drop(fill_cwnd(&mut server, id, now)); + drop(fill_cwnd(&mut server, id, now)); let stats_after = server.stats().frame_tx; assert_eq!(stats_after.crypto, stats_before.crypto); assert_eq!(stats_after.streams_blocked, 1); @@ -387,7 +387,7 @@ fn low() { // The resulting CRYPTO frame beats out the stream data. let stats_before = server.stats().frame_tx; server.send_ticket(now, &vec![0; server.plpmtu()]).unwrap(); - mem::drop(server.process_output(now)); + drop(server.process_output(now)); let stats_after = server.stats().frame_tx; assert_eq!(stats_after.crypto, stats_before.crypto + 1); assert_eq!(stats_after.stream, stats_before.stream); @@ -396,7 +396,7 @@ fn low() { // it is very hard to ensure that the STREAM frame won't also fit. // However, we can ensure that the next packet doesn't consist of just STREAM. let stats_before = server.stats().frame_tx; - mem::drop(server.process_output(now)); + drop(server.process_output(now)); let stats_after = server.stats().frame_tx; assert_eq!(stats_after.crypto, stats_before.crypto + 1); assert_eq!(stats_after.new_token, 1); diff --git a/neqo-transport/src/connection/tests/recovery.rs b/neqo-transport/src/connection/tests/recovery.rs index f3c319bdec..7c3b89d252 100644 --- a/neqo-transport/src/connection/tests/recovery.rs +++ b/neqo-transport/src/connection/tests/recovery.rs @@ -4,10 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{ - mem, - time::{Duration, Instant}, -}; +use std::time::{Duration, Instant}; use neqo_common::qdebug; use neqo_crypto::AuthenticationStatus; @@ -346,7 +343,7 @@ fn pto_handshake_frames() { let pkt = client.process(pkt.dgram(), now); now += Duration::from_millis(10); - mem::drop(server.process(pkt.dgram(), now)); + drop(server.process(pkt.dgram(), now)); now += Duration::from_millis(10); client.authenticated(AuthenticationStatus::Ok, now); @@ -443,7 +440,7 @@ fn loss_recovery_crash() { let now = now(); // The server sends something, but we will drop this. - mem::drop(send_something(&mut server, now)); + drop(send_something(&mut server, now)); // Then send something again, but let it through. let ack = send_and_receive(&mut server, &mut client, now); @@ -459,7 +456,7 @@ fn loss_recovery_crash() { assert!(dgram.is_some()); // This crashes. - mem::drop(send_something(&mut server, now + AT_LEAST_PTO)); + drop(send_something(&mut server, now + AT_LEAST_PTO)); } // If we receive packets after the PTO timer has fired, we won't clear @@ -474,7 +471,7 @@ fn ack_after_pto() { let mut now = now(); // The client sends and is forced into a PTO. - mem::drop(send_something(&mut client, now)); + drop(send_something(&mut client, now)); // Jump forward to the PTO and drain the PTO packets. now += AT_LEAST_PTO; @@ -490,7 +487,7 @@ fn ack_after_pto() { // delivery is just the thing. // Note: The server can't ACK anything here, but none of what // the client has sent so far has been transferred. - mem::drop(send_something(&mut server, now)); + drop(send_something(&mut server, now)); let dgram = send_something(&mut server, now); // The client is now after a PTO, but if it receives something diff --git a/neqo-transport/src/connection/tests/resumption.rs b/neqo-transport/src/connection/tests/resumption.rs index 50b469b7f8..7b976712fe 100644 --- a/neqo-transport/src/connection/tests/resumption.rs +++ b/neqo-transport/src/connection/tests/resumption.rs @@ -4,7 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{cell::RefCell, mem, rc::Rc, time::Duration}; +use std::{cell::RefCell, rc::Rc, time::Duration}; use neqo_common::{Datagram, Decoder, Role}; use neqo_crypto::AuthenticationStatus; @@ -249,19 +249,19 @@ fn two_tickets_on_timer() { // We need to wait for release_resumption_token_timer to expire. The timer will be // set to 3 * PTO let mut now = now() + 3 * client.pto(); - mem::drop(client.process_output(now)); + drop(client.process_output(now)); let mut recv_tokens = get_tokens(&mut client); assert_eq!(recv_tokens.len(), 1); let token1 = recv_tokens.pop().unwrap(); // Wai for anottheer 3 * PTO to get the nex okeen. now += 3 * client.pto(); - mem::drop(client.process_output(now)); + drop(client.process_output(now)); let mut recv_tokens = get_tokens(&mut client); assert_eq!(recv_tokens.len(), 1); let token2 = recv_tokens.pop().unwrap(); // Wait for 3 * PTO, but now there are no more tokens. now += 3 * client.pto(); - mem::drop(client.process_output(now)); + drop(client.process_output(now)); assert_eq!(get_tokens(&mut client).len(), 0); assert_ne!(token1.as_ref(), token2.as_ref()); @@ -343,7 +343,7 @@ fn resume_after_packet() { let token = exchange_ticket(&mut client, &mut server, now()); let mut client = default_client(); - mem::drop(client.process_output(now()).dgram().unwrap()); + drop(client.process_output(now()).dgram().unwrap()); assert_eq!( client.enable_resumption(now(), token).unwrap_err(), Error::ConnectionState diff --git a/neqo-transport/src/connection/tests/stream.rs b/neqo-transport/src/connection/tests/stream.rs index 5b81e65653..b900c50382 100644 --- a/neqo-transport/src/connection/tests/stream.rs +++ b/neqo-transport/src/connection/tests/stream.rs @@ -4,7 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{cmp::max, collections::HashMap, mem}; +use std::{cmp::max, collections::HashMap}; use neqo_common::{event::Provider as _, qdebug}; use test_fixture::now; @@ -37,7 +37,7 @@ fn stream_create() { let out = server.process(out.dgram(), now()); let out = client.process(out.dgram(), now()); - mem::drop(server.process(out.dgram(), now())); + drop(server.process(out.dgram(), now())); assert!(maybe_authenticate(&mut client)); let out = client.process_output(now()); @@ -47,7 +47,7 @@ fn stream_create() { assert_eq!(client.stream_create(StreamType::BiDi).unwrap(), 0); assert_eq!(client.stream_create(StreamType::BiDi).unwrap(), 4); - mem::drop(server.process(out.dgram(), now())); + drop(server.process(out.dgram(), now())); // server now in State::Connected assert_eq!(server.stream_create(StreamType::UniDi).unwrap(), 3); assert_eq!(server.stream_create(StreamType::UniDi).unwrap(), 7); @@ -318,11 +318,11 @@ fn report_fin_when_stream_closed_wo_data() { let stream_id = client.stream_create(StreamType::BiDi).unwrap(); client.stream_send(stream_id, &[0x00]).unwrap(); let out = client.process_output(now()); - mem::drop(server.process(out.dgram(), now())); + drop(server.process(out.dgram(), now())); server.stream_close_send(stream_id).unwrap(); let out = server.process_output(now()); - mem::drop(client.process(out.dgram(), now())); + drop(client.process(out.dgram(), now())); let stream_readable = |e| matches!(e, ConnectionEvent::RecvStreamReadable { .. }); assert!(client.events().any(stream_readable)); } @@ -512,7 +512,7 @@ fn do_not_accept_data_after_stop_sending() { let stream_id = client.stream_create(StreamType::BiDi).unwrap(); client.stream_send(stream_id, &[0x00]).unwrap(); let out = client.process_output(now()); - mem::drop(server.process(out.dgram(), now())); + drop(server.process(out.dgram(), now())); let stream_readable = |e| matches!(e, ConnectionEvent::RecvStreamReadable { .. }); assert!(server.events().any(stream_readable)); @@ -532,7 +532,7 @@ fn do_not_accept_data_after_stop_sending() { let out = server.process(out_second_data_frame.dgram(), now()); assert!(!server.events().any(stream_readable)); - mem::drop(client.process(out.dgram(), now())); + drop(client.process(out.dgram(), now())); assert_eq!( Err(Error::FinalSizeError), client.stream_send(stream_id, &[0x00]) @@ -755,7 +755,7 @@ fn after_fin_is_read_conn_events_for_stream_should_be_removed() { let out = server.process_output(now()).dgram(); assert!(out.is_some()); - mem::drop(client.process(out, now())); + drop(client.process(out, now())); // read from the stream before checking connection events. let mut buf = vec![0; 4000]; @@ -780,7 +780,7 @@ fn after_stream_stop_sending_is_called_conn_events_for_stream_should_be_removed( let out = server.process_output(now()).dgram(); assert!(out.is_some()); - mem::drop(client.process(out, now())); + drop(client.process(out, now())); // send stop sending. client @@ -914,7 +914,7 @@ fn no_dupdata_readable_events() { let stream_id = client.stream_create(StreamType::BiDi).unwrap(); client.stream_send(stream_id, &[0x00]).unwrap(); let out = client.process_output(now()); - mem::drop(server.process(out.dgram(), now())); + drop(server.process(out.dgram(), now())); // We have a data_readable event. let stream_readable = |e| matches!(e, ConnectionEvent::RecvStreamReadable { .. }); @@ -924,7 +924,7 @@ fn no_dupdata_readable_events() { // therefore there should not be a new DataReadable event. client.stream_send(stream_id, &[0x00]).unwrap(); let out_second_data_frame = client.process_output(now()); - mem::drop(server.process(out_second_data_frame.dgram(), now())); + drop(server.process(out_second_data_frame.dgram(), now())); assert!(!server.events().any(stream_readable)); // One more frame with a fin will not produce a new DataReadable event, because the @@ -932,7 +932,7 @@ fn no_dupdata_readable_events() { client.stream_send(stream_id, &[0x00]).unwrap(); client.stream_close_send(stream_id).unwrap(); let out_third_data_frame = client.process_output(now()); - mem::drop(server.process(out_third_data_frame.dgram(), now())); + drop(server.process(out_third_data_frame.dgram(), now())); assert!(!server.events().any(stream_readable)); } @@ -946,7 +946,7 @@ fn no_dupdata_readable_events_empty_last_frame() { let stream_id = client.stream_create(StreamType::BiDi).unwrap(); client.stream_send(stream_id, &[0x00]).unwrap(); let out = client.process_output(now()); - mem::drop(server.process(out.dgram(), now())); + drop(server.process(out.dgram(), now())); // We have a data_readable event. let stream_readable = |e| matches!(e, ConnectionEvent::RecvStreamReadable { .. }); @@ -956,7 +956,7 @@ fn no_dupdata_readable_events_empty_last_frame() { // the previous stream data has not been read yet. client.stream_close_send(stream_id).unwrap(); let out_second_data_frame = client.process_output(now()); - mem::drop(server.process(out_second_data_frame.dgram(), now())); + drop(server.process(out_second_data_frame.dgram(), now())); assert!(!server.events().any(stream_readable)); } @@ -978,7 +978,7 @@ fn change_flow_control(stream_type: StreamType, new_fc: u64) { // Send the stream to the client. let out = server.process_output(now()); - mem::drop(client.process(out.dgram(), now())); + drop(client.process(out.dgram(), now())); // change max_stream_data for stream_id. client.set_stream_max_data(stream_id, new_fc).unwrap(); @@ -1000,7 +1000,7 @@ fn change_flow_control(stream_type: StreamType, new_fc: u64) { // Exchange packets so that client gets all data. let out4 = client.process(out3.dgram(), now()); let out5 = server.process(out4.dgram(), now()); - mem::drop(client.process(out5.dgram(), now())); + drop(client.process(out5.dgram(), now())); // read all data by client let mut buf = [0x0; 10000]; @@ -1008,7 +1008,7 @@ fn change_flow_control(stream_type: StreamType, new_fc: u64) { assert_eq!(u64::try_from(read).unwrap(), max(RECV_BUFFER_START, new_fc)); let out4 = client.process_output(now()); - mem::drop(server.process(out4.dgram(), now())); + drop(server.process(out4.dgram(), now())); let written3 = server.stream_send(stream_id, &[0x0; 10000]).unwrap(); assert_eq!(u64::try_from(written3).unwrap(), new_fc); @@ -1240,7 +1240,7 @@ fn connect_w_different_limit(bidi_limit: u64, unidi_limit: u64) { let out = server.process(out.dgram(), now()); let out = client.process(out.dgram(), now()); - mem::drop(server.process(out.dgram(), now())); + drop(server.process(out.dgram(), now())); assert!(maybe_authenticate(&mut client)); diff --git a/neqo-transport/src/connection/tests/vn.rs b/neqo-transport/src/connection/tests/vn.rs index 896944be0a..60fafd56aa 100644 --- a/neqo-transport/src/connection/tests/vn.rs +++ b/neqo-transport/src/connection/tests/vn.rs @@ -4,7 +4,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{mem, time::Duration}; +use std::time::Duration; use neqo_common::{event::Provider as _, Decoder, Encoder}; use test_fixture::{assertions, datagram, now}; @@ -27,11 +27,11 @@ const INITIAL_PTO: Duration = Duration::from_millis(300); fn unknown_version() { let mut client = default_client(); // Start the handshake. - mem::drop(client.process_output(now()).dgram()); + drop(client.process_output(now()).dgram()); let mut unknown_version_packet = vec![0x80, 0x1a, 0x1a, 0x1a, 0x1a]; unknown_version_packet.resize(MIN_INITIAL_PACKET_SIZE, 0x0); - mem::drop(client.process(Some(datagram(unknown_version_packet)), now())); + drop(client.process(Some(datagram(unknown_version_packet)), now())); assert_eq!(1, client.stats().dropped_rx); } diff --git a/neqo-transport/src/lib.rs b/neqo-transport/src/lib.rs index 4d795ae49b..45e3e9d118 100644 --- a/neqo-transport/src/lib.rs +++ b/neqo-transport/src/lib.rs @@ -250,4 +250,4 @@ impl From for CloseReason { } } -pub type Res = std::result::Result; +pub type Res = Result; diff --git a/neqo-transport/src/path.rs b/neqo-transport/src/path.rs index 9ab572eb04..79337182c7 100644 --- a/neqo-transport/src/path.rs +++ b/neqo-transport/src/path.rs @@ -9,7 +9,6 @@ use std::{ cell::RefCell, fmt::{self, Display}, - mem, net::SocketAddr, rc::Rc, time::{Duration, Instant}, @@ -200,7 +199,7 @@ impl Paths { path.borrow_mut().set_ecn_baseline(baseline); if force || path.borrow().is_valid() { path.borrow_mut().set_valid(now); - mem::drop(self.select_primary(path, now)); + drop(self.select_primary(path, now)); self.migration_target = None; } else { self.migration_target = Some(Rc::clone(path)); @@ -243,7 +242,7 @@ impl Paths { // Need a clone as `fallback` is borrowed from `self`. let path = Rc::clone(fallback); qinfo!([path.borrow()], "Failing over after primary path failed"); - mem::drop(self.select_primary(&path, now)); + drop(self.select_primary(&path, now)); true } else { false @@ -320,7 +319,7 @@ impl Paths { .is_some_and(|target| Rc::ptr_eq(target, p)) { let primary = self.migration_target.take(); - mem::drop(self.select_primary(&primary.unwrap(), now)); + drop(self.select_primary(&primary.unwrap(), now)); return true; } break; diff --git a/neqo-transport/src/recovery/mod.rs b/neqo-transport/src/recovery/mod.rs index 47f4a896d5..ffe1e4ee92 100644 --- a/neqo-transport/src/recovery/mod.rs +++ b/neqo-transport/src/recovery/mod.rs @@ -16,7 +16,6 @@ mod token; use std::{ cmp::{max, min}, - convert::TryFrom as _, ops::RangeInclusive, time::{Duration, Instant}, }; @@ -969,7 +968,6 @@ impl ::std::fmt::Display for LossRecovery { mod tests { use std::{ cell::RefCell, - convert::TryInto as _, ops::{Deref, DerefMut, RangeInclusive}, rc::Rc, time::{Duration, Instant}, diff --git a/neqo-transport/src/recovery/sent.rs b/neqo-transport/src/recovery/sent.rs index f465bcb8e6..a9f775599c 100644 --- a/neqo-transport/src/recovery/sent.rs +++ b/neqo-transport/src/recovery/sent.rs @@ -305,7 +305,6 @@ impl SentPackets { mod tests { use std::{ cell::OnceCell, - convert::TryFrom as _, time::{Duration, Instant}, }; @@ -366,7 +365,7 @@ mod tests { let mut it = store.into_iter(); assert_eq!(idx, it.next().unwrap().pn()); assert!(it.next().is_none()); - std::mem::drop(it); + drop(it); assert_eq!(pkts.len(), 2); } diff --git a/neqo-transport/src/tparams.rs b/neqo-transport/src/tparams.rs index 723492c448..2ecfb5b3a6 100644 --- a/neqo-transport/src/tparams.rs +++ b/neqo-transport/src/tparams.rs @@ -30,7 +30,7 @@ use crate::{ pub type TransportParameterId = u64; macro_rules! tpids { { $($n:ident = $v:expr),+ $(,)? } => { - $(pub const $n: TransportParameterId = $v as TransportParameterId;)+ + $(pub const $n: TransportParameterId = $v;)+ /// A complete list of internal transport parameters. #[cfg(not(test))] diff --git a/neqo-transport/tests/common/mod.rs b/neqo-transport/tests/common/mod.rs index 794edd7d97..f8b9c98d6a 100644 --- a/neqo-transport/tests/common/mod.rs +++ b/neqo-transport/tests/common/mod.rs @@ -112,7 +112,7 @@ pub fn generate_ticket(server: &mut Server) -> ResumptionToken { // Have the client close the connection and then let the server clean up. client.close(now(), 0, "got a ticket"); let out = client.process_output(now()); - mem::drop(server.process(out.dgram(), now())); + drop(server.process(out.dgram(), now())); // Calling active_connections clears the set of active connections. assert_eq!(server.active_connections().len(), 1); ticket diff --git a/neqo-transport/tests/retry.rs b/neqo-transport/tests/retry.rs index 0dc083859b..99abfd96b9 100644 --- a/neqo-transport/tests/retry.rs +++ b/neqo-transport/tests/retry.rs @@ -9,7 +9,6 @@ mod common; use std::{ - mem, net::{IpAddr, Ipv4Addr, SocketAddr}, time::Duration, }; @@ -44,7 +43,7 @@ fn retry_basic() { assert!(dgram.is_some()); let dgram = server.process(dgram, now()).dgram(); // Initial, HS assert!(dgram.is_some()); - mem::drop(client.process(dgram, now()).dgram()); // Ingest, drop any ACK. + drop(client.process(dgram, now()).dgram()); // Ingest, drop any ACK. client.authenticated(AuthenticationStatus::Ok, now()); let dgram = client.process_output(now()).dgram(); // Send Finished assert!(dgram.is_some()); diff --git a/neqo-transport/tests/server.rs b/neqo-transport/tests/server.rs index 8ff6511e0b..c0a10b9afb 100644 --- a/neqo-transport/tests/server.rs +++ b/neqo-transport/tests/server.rs @@ -6,7 +6,7 @@ mod common; -use std::{cell::RefCell, mem, net::SocketAddr, rc::Rc, time::Duration}; +use std::{cell::RefCell, net::SocketAddr, rc::Rc, time::Duration}; use common::{connect, connected_server, default_server, find_ticket, generate_ticket, new_server}; use neqo_common::{qtrace, Datagram, Decoder, Encoder, Role}; @@ -227,7 +227,7 @@ fn drop_non_initial() { let mut server = default_server(); // This is big enough to look like an Initial, but it uses the Retry type. - let mut header = neqo_common::Encoder::with_capacity(MIN_INITIAL_PACKET_SIZE); + let mut header = Encoder::with_capacity(MIN_INITIAL_PACKET_SIZE); header .encode_byte(0xfa) .encode_uint(4, Version::default().wire_version()) @@ -246,7 +246,7 @@ fn drop_short_initial() { let mut server = default_server(); // This too small to be an Initial, but it is otherwise plausible. - let mut header = neqo_common::Encoder::with_capacity(1199); + let mut header = Encoder::with_capacity(1199); header .encode_byte(0xca) .encode_uint(4, Version::default().wire_version()) @@ -264,7 +264,7 @@ fn drop_short_header_packet_for_unknown_connection() { const CID: &[u8] = &[55; 8]; // not a real connection ID let mut server = default_server(); - let mut header = neqo_common::Encoder::with_capacity(MIN_INITIAL_PACKET_SIZE); + let mut header = Encoder::with_capacity(MIN_INITIAL_PACKET_SIZE); header .encode_byte(0x40) // short header .encode_vec(1, CID) @@ -318,12 +318,12 @@ fn zero_rtt() { let c4 = client_send(); // 0-RTT packets that arrive before the handshake get dropped. - mem::drop(server.process(Some(c2), now)); + drop(server.process(Some(c2), now)); assert!(server.active_connections().is_empty()); // Now handshake and let another 0-RTT packet in. let shs = server.process(Some(c1), now); - mem::drop(server.process(Some(c3), now)); + drop(server.process(Some(c3), now)); // The server will have received two STREAM frames now if it processed both packets. // `ActiveConnectionRef` `Hash` implementation doesn’t access any of the interior mutable types. #[allow(clippy::mutable_key_type)] @@ -345,10 +345,10 @@ fn zero_rtt() { // a little so that the pacer doesn't prevent the Finished from being sent. now += now - start_time; let cfin = client.process(shs.dgram(), now); - mem::drop(server.process(cfin.dgram(), now)); + drop(server.process(cfin.dgram(), now)); // The server will drop this last 0-RTT packet. - mem::drop(server.process(Some(c4), now)); + drop(server.process(Some(c4), now)); // `ActiveConnectionRef` `Hash` implementation doesn’t access any of the interior mutable types. #[allow(clippy::mutable_key_type)] let active = server.active_connections(); diff --git a/neqo-udp/src/lib.rs b/neqo-udp/src/lib.rs index ab272b5559..ef57a996f8 100644 --- a/neqo-udp/src/lib.rs +++ b/neqo-udp/src/lib.rs @@ -193,7 +193,7 @@ impl Socket { /// Create a new [`Socket`] given a raw file descriptor managed externally. pub fn new(socket: S) -> Result { Ok(Self { - state: quinn_udp::UdpSocketState::new((&socket).into())?, + state: UdpSocketState::new((&socket).into())?, inner: socket, }) } diff --git a/test-fixture/src/lib.rs b/test-fixture/src/lib.rs index 2efb21cfef..f41c4c843d 100644 --- a/test-fixture/src/lib.rs +++ b/test-fixture/src/lib.rs @@ -403,7 +403,7 @@ pub fn new_neqo_qlog() -> (NeqoQlog, SharedVec) { None, None, None, - std::time::Instant::now(), + Instant::now(), trace, EventImportance::Base, Box::new(buf), From e5770cecc68b2f4674c4dee8d00f969fb96ad4f4 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Fri, 10 Jan 2025 09:41:07 +0200 Subject: [PATCH 18/18] chore: Enable the `semicolon_inside_block` lint (#2328) This is what we mostly use in the code. Signed-off-by: Lars Eggert --- Cargo.toml | 1 + neqo-crypto/src/agent.rs | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3271443073..90e22c2c2b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,6 +66,7 @@ pathbuf_init_then_push = "warn" redundant_type_annotations = "warn" ref_patterns = "warn" renamed_function_params = "warn" +semicolon_inside_block = "warn" try_err = "warn" unneeded_field_pattern = "warn" unused_trait_names = "warn" diff --git a/neqo-crypto/src/agent.rs b/neqo-crypto/src/agent.rs index 11289a61eb..bba2c84cb9 100644 --- a/neqo-crypto/src/agent.rs +++ b/neqo-crypto/src/agent.rs @@ -337,7 +337,9 @@ impl SecretAgent { ssl::SSL_ImportFD(null_mut(), base_fd.cast()) }; if fd.is_null() { - unsafe { prio::PR_Close(base_fd) }; + unsafe { + prio::PR_Close(base_fd); + } return Err(Error::CreateSslSocket); } Ok(fd) @@ -758,11 +760,15 @@ impl SecretAgent { if self.raw == Some(true) { // Need to hold the record list in scope until the close is done. let _records = self.setup_raw().expect("Can only close"); - unsafe { prio::PR_Close(self.fd.cast()) }; + unsafe { + prio::PR_Close(self.fd.cast()); + } } else { // Need to hold the IO wrapper in scope until the close is done. let _io = self.io.wrap(&[]); - unsafe { prio::PR_Close(self.fd.cast()) }; + unsafe { + prio::PR_Close(self.fd.cast()); + } }; let _output = self.io.take_output(); self.fd = null_mut();