diff --git a/clients/client-core/src/client/received_buffer.rs b/clients/client-core/src/client/received_buffer.rs index 8d5a5e07a3..8c1ef59df6 100644 --- a/clients/client-core/src/client/received_buffer.rs +++ b/clients/client-core/src/client/received_buffer.rs @@ -165,7 +165,7 @@ impl ReceivedMessagesBuffer { // while we're at it, also empty the buffer if we happened to receive anything while // no sender was connected - let stored_messages = std::mem::replace(&mut guard.messages, Vec::new()); + let stored_messages = std::mem::take(&mut guard.messages); if !stored_messages.is_empty() { if let Err(err) = sender.unbounded_send(stored_messages) { error!( diff --git a/clients/native/websocket-requests/src/responses.rs b/clients/native/websocket-requests/src/responses.rs index 06e602ef39..473449a65f 100644 --- a/clients/native/websocket-requests/src/responses.rs +++ b/clients/native/websocket-requests/src/responses.rs @@ -15,6 +15,8 @@ // all variable size data is always prefixed with u64 length // tags are u8 +#![allow(unknown_lints)] // due to using `clippy::branches_sharing_code` which does not exist on `stable` just yet + use crate::error::{self, ErrorKind}; use crate::text::ServerResponseText; use nymsphinx::addressing::clients::Recipient; @@ -96,6 +98,8 @@ impl ServerResponse { } }; + // this is a false positive as even though the code is the same, it refers to different things + #[allow(clippy::branches_sharing_code)] if with_reply_surb { let reply_surb_len = u64::from_be_bytes(b[2..2 + size_of::()].as_ref().try_into().unwrap()); diff --git a/clients/webassembly/src/client/mod.rs b/clients/webassembly/src/client/mod.rs index 67a4e6bc04..b991599fde 100644 --- a/clients/webassembly/src/client/mod.rs +++ b/clients/webassembly/src/client/mod.rs @@ -246,7 +246,7 @@ impl NymClient { let validator_client = validator_client::Client::new(validator_client_config); match validator_client.get_active_topology().await { - Err(err) => panic!(err), + Err(err) => panic!("{}", err), Ok(topology) => { let nym_topology: NymTopology = topology.into(); let version = env!("CARGO_PKG_VERSION"); diff --git a/common/crypto/src/asymmetric/encryption/mod.rs b/common/crypto/src/asymmetric/encryption/mod.rs index f54fcbc77d..595daa8713 100644 --- a/common/crypto/src/asymmetric/encryption/mod.rs +++ b/common/crypto/src/asymmetric/encryption/mod.rs @@ -107,7 +107,7 @@ impl PemStorableKeyPair for KeyPair { pub struct PublicKey(x25519_dalek::PublicKey); impl PublicKey { - pub fn to_bytes(&self) -> [u8; PUBLIC_KEY_SIZE] { + pub fn to_bytes(self) -> [u8; PUBLIC_KEY_SIZE] { *self.0.as_bytes() } @@ -120,8 +120,8 @@ impl PublicKey { Ok(Self(x25519_dalek::PublicKey::from(bytes))) } - pub fn to_base58_string(&self) -> String { - bs58::encode(&self.to_bytes()).into_string() + pub fn to_base58_string(self) -> String { + bs58::encode(self.to_bytes()).into_string() } pub fn from_base58_string>(val: S) -> Result { @@ -138,7 +138,7 @@ impl PemStorableKey for PublicKey { } fn to_bytes(&self) -> Vec { - self.to_bytes().to_vec() + (*self).to_bytes().to_vec() } fn from_bytes(bytes: &[u8]) -> Result { @@ -209,7 +209,7 @@ impl From for nymsphinx_types::PublicKey { impl<'a> From<&'a PublicKey> for nymsphinx_types::PublicKey { fn from(key: &'a PublicKey) -> Self { - nymsphinx_types::PublicKey::from(key.to_bytes()) + nymsphinx_types::PublicKey::from((*key).to_bytes()) } } diff --git a/common/crypto/src/asymmetric/identity/mod.rs b/common/crypto/src/asymmetric/identity/mod.rs index e057e413fc..b31ec8fd06 100644 --- a/common/crypto/src/asymmetric/identity/mod.rs +++ b/common/crypto/src/asymmetric/identity/mod.rs @@ -116,7 +116,7 @@ impl PublicKey { } /// Convert this public key to a byte array. - pub fn to_bytes(&self) -> [u8; PUBLIC_KEY_LENGTH] { + pub fn to_bytes(self) -> [u8; PUBLIC_KEY_LENGTH] { self.0.to_bytes() } @@ -124,8 +124,8 @@ impl PublicKey { Ok(PublicKey(ed25519_dalek::PublicKey::from_bytes(b)?)) } - pub fn to_base58_string(&self) -> String { - bs58::encode(&self.to_bytes()).into_string() + pub fn to_base58_string(self) -> String { + bs58::encode(self.to_bytes()).into_string() } pub fn from_base58_string>(val: S) -> Result { @@ -146,7 +146,7 @@ impl PemStorableKey for PublicKey { } fn to_bytes(&self) -> Vec { - self.to_bytes().to_vec() + (*self).to_bytes().to_vec() } fn from_bytes(bytes: &[u8]) -> Result { diff --git a/common/crypto/src/symmetric/stream_cipher.rs b/common/crypto/src/symmetric/stream_cipher.rs index ce6200e6ed..0c135891fd 100644 --- a/common/crypto/src/symmetric/stream_cipher.rs +++ b/common/crypto/src/symmetric/stream_cipher.rs @@ -1,9 +1,6 @@ // Copyright 2020 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -#![allow(renamed_and_removed_lints)] -#![allow(unknown_lints)] // beta-nightly -#![allow(clippy::unknown_clippy_lints)] // `clippy::upper_case_acronyms` does not exist on stable just yet use cipher::stream::{Nonce, StreamCipher, SyncStreamCipher}; use generic_array::{typenum::Unsigned, GenericArray}; use rand::{CryptoRng, RngCore}; diff --git a/common/nymsphinx/addressing/src/clients.rs b/common/nymsphinx/addressing/src/clients.rs index 4b80b604c0..93588f0e7d 100644 --- a/common/nymsphinx/addressing/src/clients.rs +++ b/common/nymsphinx/addressing/src/clients.rs @@ -154,7 +154,7 @@ impl Recipient { &self.gateway } - pub fn to_bytes(&self) -> [u8; Self::LEN] { + pub fn to_bytes(self) -> [u8; Self::LEN] { let mut out = [0u8; Self::LEN]; out[..CLIENT_IDENTITY_SIZE].copy_from_slice(&self.client_identity.to_bytes()); out[CLIENT_IDENTITY_SIZE..CLIENT_IDENTITY_SIZE + CLIENT_ENCRYPTION_KEY_SIZE] diff --git a/gateway/gateway-requests/src/authentication/encrypted_address.rs b/gateway/gateway-requests/src/authentication/encrypted_address.rs index 149393bd0e..fea5562aaf 100644 --- a/gateway/gateway-requests/src/authentication/encrypted_address.rs +++ b/gateway/gateway-requests/src/authentication/encrypted_address.rs @@ -48,7 +48,7 @@ impl EncryptedAddressBytes { EncryptedAddressBytes(bytes) } - pub fn to_bytes(&self) -> [u8; ENCRYPTED_ADDRESS_SIZE] { + pub fn to_bytes(self) -> [u8; ENCRYPTED_ADDRESS_SIZE] { self.0 } @@ -73,7 +73,7 @@ impl EncryptedAddressBytes { Ok(EncryptedAddressBytes(enc_address)) } - pub fn to_base58_string(&self) -> String { + pub fn to_base58_string(self) -> String { bs58::encode(self.0).into_string() } } diff --git a/gateway/gateway-requests/src/authentication/iv.rs b/gateway/gateway-requests/src/authentication/iv.rs index 2e9d7c73f4..a0964c96bf 100644 --- a/gateway/gateway-requests/src/authentication/iv.rs +++ b/gateway/gateway-requests/src/authentication/iv.rs @@ -1,9 +1,6 @@ // Copyright 2020 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -#![allow(renamed_and_removed_lints)] -#![allow(unknown_lints)] // beta-nightly -#![allow(clippy::unknown_clippy_lints)] // `clippy::upper_case_acronyms` does not exist on stable just yet use crypto::generic_array::{typenum::Unsigned, GenericArray}; use crypto::symmetric::stream_cipher::{random_iv, NewStreamCipher, IV}; use nymsphinx::params::GatewayEncryptionAlgorithm; diff --git a/mixnode/src/node/metrics.rs b/mixnode/src/node/metrics.rs index 0f1e4c89bf..e1dc0188a4 100644 --- a/mixnode/src/node/metrics.rs +++ b/mixnode/src/node/metrics.rs @@ -59,7 +59,7 @@ impl MixMetrics { let mut unlocked = self.inner.sent.lock().await; let received = self.inner.received.swap(0, Ordering::SeqCst); - let sent = std::mem::replace(unlocked.deref_mut(), HashMap::new()); + let sent = std::mem::take(unlocked.deref_mut()); (received, sent) } diff --git a/network-monitor/src/test_packet.rs b/network-monitor/src/test_packet.rs index 6b48702d01..ebc1df18a2 100644 --- a/network-monitor/src/test_packet.rs +++ b/network-monitor/src/test_packet.rs @@ -121,7 +121,7 @@ impl TestPacket { self.pub_key.to_base58_string() } - pub(crate) fn to_bytes(&self) -> Vec { + pub(crate) fn to_bytes(self) -> Vec { self.nonce .to_be_bytes() .iter()