From 17c41033e298c423806a77dd474535c77cdf275e Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Thu, 9 Jan 2025 19:51:09 +0200 Subject: [PATCH] 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() {