From a41329c027b41dd4836518cc33d6493f41ab7274 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Tue, 23 Apr 2024 04:31:27 -0400 Subject: [PATCH] Update clippy now that redundant imports has been reverted --- .github/nightly-version | 2 +- coins/monero/src/wallet/address.rs | 15 ++++++------ common/db/src/parity_db.rs | 2 +- coordinator/tributary/src/provided.rs | 4 ++-- crypto/dalek-ff-group/Cargo.toml | 2 +- crypto/dkg/Cargo.toml | 2 +- crypto/dleq/Cargo.toml | 2 +- crypto/ed448/Cargo.toml | 2 +- processor/src/networks/bitcoin.rs | 6 ++--- processor/src/networks/ethereum.rs | 23 ++++++++++--------- substrate/abi/Cargo.toml | 2 +- substrate/client/src/networks/bitcoin.rs | 8 +++---- substrate/client/src/networks/monero.rs | 8 +++---- substrate/coins/pallet/Cargo.toml | 2 +- substrate/coins/primitives/Cargo.toml | 2 +- substrate/dex/pallet/Cargo.toml | 2 +- substrate/dex/pallet/src/benchmarking.rs | 2 +- substrate/in-instructions/pallet/src/lib.rs | 2 +- .../in-instructions/primitives/Cargo.toml | 2 +- substrate/primitives/Cargo.toml | 2 +- 20 files changed, 46 insertions(+), 46 deletions(-) diff --git a/.github/nightly-version b/.github/nightly-version index 4a8f1e33b..e2e82b485 100644 --- a/.github/nightly-version +++ b/.github/nightly-version @@ -1 +1 @@ -nightly-2024-02-07 +nightly-2024-04-23 diff --git a/coins/monero/src/wallet/address.rs b/coins/monero/src/wallet/address.rs index 9c79942bc..5eec80917 100644 --- a/coins/monero/src/wallet/address.rs +++ b/coins/monero/src/wallet/address.rs @@ -1,5 +1,4 @@ -use core::{marker::PhantomData, fmt::Debug}; -use std_shims::string::{String, ToString}; +use core::{marker::PhantomData, fmt}; use zeroize::Zeroize; @@ -81,7 +80,7 @@ impl AddressType { } /// A type which returns the byte for a given address. -pub trait AddressBytes: Clone + Copy + PartialEq + Eq + Debug { +pub trait AddressBytes: Clone + Copy + PartialEq + Eq + fmt::Debug { fn network_bytes(network: Network) -> (u8, u8, u8, u8); } @@ -191,8 +190,8 @@ pub struct Address { pub view: EdwardsPoint, } -impl core::fmt::Debug for Address { - fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> { +impl fmt::Debug for Address { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { fmt .debug_struct("Address") .field("meta", &self.meta) @@ -212,8 +211,8 @@ impl Zeroize for Address { } } -impl ToString for Address { - fn to_string(&self) -> String { +impl fmt::Display for Address { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut data = vec![self.meta.to_byte()]; data.extend(self.spend.compress().to_bytes()); data.extend(self.view.compress().to_bytes()); @@ -226,7 +225,7 @@ impl ToString for Address { if let Some(id) = self.meta.kind.payment_id() { data.extend(id); } - encode_check(&data).unwrap() + write!(f, "{}", encode_check(&data).unwrap()) } } diff --git a/common/db/src/parity_db.rs b/common/db/src/parity_db.rs index 06fd0c7c0..8c9134684 100644 --- a/common/db/src/parity_db.rs +++ b/common/db/src/parity_db.rs @@ -11,7 +11,7 @@ impl Get for Transaction<'_> { let mut res = self.0.get(&key); for change in &self.1 { if change.1 == key.as_ref() { - res = change.2.clone(); + res.clone_from(&change.2); } } res diff --git a/coordinator/tributary/src/provided.rs b/coordinator/tributary/src/provided.rs index 103286afb..27c5f3cda 100644 --- a/coordinator/tributary/src/provided.rs +++ b/coordinator/tributary/src/provided.rs @@ -74,7 +74,7 @@ impl ProvidedTransactions { panic!("provided transaction saved to disk wasn't provided"); }; - if res.transactions.get(order).is_none() { + if !res.transactions.contains_key(order) { res.transactions.insert(order, VecDeque::new()); } res.transactions.get_mut(order).unwrap().push_back(tx); @@ -135,7 +135,7 @@ impl ProvidedTransactions { txn.put(current_provided_key, currently_provided); txn.commit(); - if self.transactions.get(order).is_none() { + if !self.transactions.contains_key(order) { self.transactions.insert(order, VecDeque::new()); } self.transactions.get_mut(order).unwrap().push_back(tx); diff --git a/crypto/dalek-ff-group/Cargo.toml b/crypto/dalek-ff-group/Cargo.toml index 0fe4bce0b..d8a92194c 100644 --- a/crypto/dalek-ff-group/Cargo.toml +++ b/crypto/dalek-ff-group/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/serai-dex/serai/tree/develop/crypto/dalek-ff-gr authors = ["Luke Parker "] keywords = ["curve25519", "ed25519", "ristretto", "dalek", "group"] edition = "2021" -rust-version = "1.65" +rust-version = "1.66" [package.metadata.docs.rs] all-features = true diff --git a/crypto/dkg/Cargo.toml b/crypto/dkg/Cargo.toml index a8d3f0a8d..bf308705e 100644 --- a/crypto/dkg/Cargo.toml +++ b/crypto/dkg/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/serai-dex/serai/tree/develop/crypto/dkg" authors = ["Luke Parker "] keywords = ["dkg", "multisig", "threshold", "ff", "group"] edition = "2021" -rust-version = "1.70" +rust-version = "1.74" [package.metadata.docs.rs] all-features = true diff --git a/crypto/dleq/Cargo.toml b/crypto/dleq/Cargo.toml index 7d8c87e9c..c9d525e18 100644 --- a/crypto/dleq/Cargo.toml +++ b/crypto/dleq/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT" repository = "https://github.com/serai-dex/serai/tree/develop/crypto/dleq" authors = ["Luke Parker "] edition = "2021" -rust-version = "1.73" +rust-version = "1.74" [package.metadata.docs.rs] all-features = true diff --git a/crypto/ed448/Cargo.toml b/crypto/ed448/Cargo.toml index 2302d7b3b..b0d0026e2 100644 --- a/crypto/ed448/Cargo.toml +++ b/crypto/ed448/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/serai-dex/serai/tree/develop/crypto/ed448" authors = ["Luke Parker "] keywords = ["ed448", "ff", "group"] edition = "2021" -rust-version = "1.65" +rust-version = "1.66" [package.metadata.docs.rs] all-features = true diff --git a/processor/src/networks/bitcoin.rs b/processor/src/networks/bitcoin.rs index 96f769499..3f8174e45 100644 --- a/processor/src/networks/bitcoin.rs +++ b/processor/src/networks/bitcoin.rs @@ -517,7 +517,7 @@ impl Bitcoin { if witness.len() >= 2 { let redeem_script = ScriptBuf::from_bytes(witness.last().unwrap().clone()); if Self::segwit_data_pattern(&redeem_script) == Some(true) { - data = witness[witness.len() - 2].clone(); // len() - 1 is the redeem_script + data.clone_from(&witness[witness.len() - 2]); // len() - 1 is the redeem_script break; } } @@ -731,9 +731,9 @@ impl Network for Bitcoin { let data = Self::extract_serai_data(tx); for output in &mut outputs { if output.kind == OutputType::External { - output.data = data.clone(); + output.data.clone_from(&data); } - output.presumed_origin = presumed_origin.clone(); + output.presumed_origin.clone_from(&presumed_origin); } } diff --git a/processor/src/networks/ethereum.rs b/processor/src/networks/ethereum.rs index 360519804..35979f301 100644 --- a/processor/src/networks/ethereum.rs +++ b/processor/src/networks/ethereum.rs @@ -1,4 +1,4 @@ -use core::{fmt::Debug, time::Duration}; +use core::{fmt, time::Duration}; use std::{ sync::Arc, collections::{HashSet, HashMap}, @@ -108,9 +108,10 @@ impl TryInto> for Address { Ok(self.0.to_vec()) } } -impl ToString for Address { - fn to_string(&self) -> String { - ethereum_serai::alloy_core::primitives::Address::from(self.0).to_string() + +impl fmt::Display for Address { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + ethereum_serai::alloy_core::primitives::Address::from(self.0).fmt(f) } } @@ -122,7 +123,7 @@ impl SignableTransaction for RouterCommand { } #[async_trait] -impl TransactionTrait> for Transaction { +impl TransactionTrait> for Transaction { type Id = [u8; 32]; fn id(&self) -> Self::Id { self.hash.0 @@ -155,7 +156,7 @@ impl Epoch { } #[async_trait] -impl Block> for Epoch { +impl Block> for Epoch { type Id = [u8; 32]; fn id(&self) -> [u8; 32] { self.end_hash @@ -168,7 +169,7 @@ impl Block> for Epoch { } } -impl Output> for EthereumInInstruction { +impl Output> for EthereumInInstruction { type Id = [u8; 32]; fn kind(&self) -> OutputType { @@ -281,7 +282,7 @@ impl EventualityTrait for Eventuality { } #[derive(Clone, Debug)] -pub struct Ethereum { +pub struct Ethereum { // This DB is solely used to access the first key generated, as needed to determine the Router's // address. Accordingly, all methods present are consistent to a Serai chain with a finalized // first key (regardless of local state), and this is safe. @@ -290,12 +291,12 @@ pub struct Ethereum { deployer: Deployer, router: Arc>>, } -impl PartialEq for Ethereum { +impl PartialEq for Ethereum { fn eq(&self, _other: &Ethereum) -> bool { true } } -impl Ethereum { +impl Ethereum { pub async fn new(db: D, url: String) -> Self { let provider = Arc::new(RootProvider::new( ClientBuilder::default().transport(SimpleRequest::new(url), true), @@ -360,7 +361,7 @@ impl Ethereum { } #[async_trait] -impl Network for Ethereum { +impl Network for Ethereum { type Curve = Secp256k1; type Transaction = Transaction; diff --git a/substrate/abi/Cargo.toml b/substrate/abi/Cargo.toml index 043504868..3aac979ac 100644 --- a/substrate/abi/Cargo.toml +++ b/substrate/abi/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT" repository = "https://github.com/serai-dex/serai/tree/develop/substrate/abi" authors = ["Luke Parker "] edition = "2021" -rust-version = "1.69" +rust-version = "1.74" [package.metadata.docs.rs] all-features = true diff --git a/substrate/client/src/networks/bitcoin.rs b/substrate/client/src/networks/bitcoin.rs index 42cf41bfc..5ea37898a 100644 --- a/substrate/client/src/networks/bitcoin.rs +++ b/substrate/client/src/networks/bitcoin.rs @@ -1,4 +1,4 @@ -use core::str::FromStr; +use core::{str::FromStr, fmt}; use scale::{Encode, Decode}; @@ -35,9 +35,9 @@ impl FromStr for Address { } } -impl ToString for Address { - fn to_string(&self) -> String { - self.0.to_string() +impl fmt::Display for Address { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.0.fmt(f) } } diff --git a/substrate/client/src/networks/monero.rs b/substrate/client/src/networks/monero.rs index e2268ec2e..5b43860e9 100644 --- a/substrate/client/src/networks/monero.rs +++ b/substrate/client/src/networks/monero.rs @@ -1,4 +1,4 @@ -use core::str::FromStr; +use core::{str::FromStr, fmt}; use scale::{Encode, Decode}; @@ -24,9 +24,9 @@ impl FromStr for Address { } } -impl ToString for Address { - fn to_string(&self) -> String { - self.0.to_string() +impl fmt::Display for Address { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.0.fmt(f) } } diff --git a/substrate/coins/pallet/Cargo.toml b/substrate/coins/pallet/Cargo.toml index 75011add0..da9a27f6d 100644 --- a/substrate/coins/pallet/Cargo.toml +++ b/substrate/coins/pallet/Cargo.toml @@ -6,7 +6,7 @@ license = "AGPL-3.0-only" repository = "https://github.com/serai-dex/serai/tree/develop/substrate/coins/pallet" authors = ["Akil Demir "] edition = "2021" -rust-version = "1.70" +rust-version = "1.74" [package.metadata.docs.rs] all-features = true diff --git a/substrate/coins/primitives/Cargo.toml b/substrate/coins/primitives/Cargo.toml index 322016da1..ec906929d 100644 --- a/substrate/coins/primitives/Cargo.toml +++ b/substrate/coins/primitives/Cargo.toml @@ -5,7 +5,7 @@ description = "Serai coins primitives" license = "MIT" authors = ["Luke Parker "] edition = "2021" -rust-version = "1.69" +rust-version = "1.74" [package.metadata.docs.rs] all-features = true diff --git a/substrate/dex/pallet/Cargo.toml b/substrate/dex/pallet/Cargo.toml index 6a2eadb8a..e2ed39288 100644 --- a/substrate/dex/pallet/Cargo.toml +++ b/substrate/dex/pallet/Cargo.toml @@ -6,7 +6,7 @@ license = "AGPL-3.0-only" repository = "https://github.com/serai-dex/serai/tree/develop/substrate/dex/pallet" authors = ["Parity Technologies , Akil Demir "] edition = "2021" -rust-version = "1.70" +rust-version = "1.74" [package.metadata.docs.rs] all-features = true diff --git a/substrate/dex/pallet/src/benchmarking.rs b/substrate/dex/pallet/src/benchmarking.rs index a00b6edcd..fb23b12a4 100644 --- a/substrate/dex/pallet/src/benchmarking.rs +++ b/substrate/dex/pallet/src/benchmarking.rs @@ -43,7 +43,7 @@ fn create_coin(coin: &Coin) -> (T::AccountId, AccountIdLookupOf) { let caller_lookup = T::Lookup::unlookup(caller); assert_ok!(Coins::::mint( caller, - Balance { coin: Coin::native(), amount: Amount(SubstrateAmount::max_value().div(1000u64)) } + Balance { coin: Coin::native(), amount: Amount(SubstrateAmount::MAX.div(1000u64)) } )); assert_ok!(Coins::::mint( caller, diff --git a/substrate/in-instructions/pallet/src/lib.rs b/substrate/in-instructions/pallet/src/lib.rs index 3ec63ae58..955a54df7 100644 --- a/substrate/in-instructions/pallet/src/lib.rs +++ b/substrate/in-instructions/pallet/src/lib.rs @@ -10,7 +10,7 @@ pub use in_instructions_primitives as primitives; use primitives::*; // TODO: Investigate why Substrate generates these -#[allow(clippy::cast_possible_truncation, clippy::no_effect_underscore_binding)] +#[allow(clippy::cast_possible_truncation, clippy::no_effect_underscore_binding, clippy::empty_docs)] #[frame_support::pallet] pub mod pallet { use sp_std::vec; diff --git a/substrate/in-instructions/primitives/Cargo.toml b/substrate/in-instructions/primitives/Cargo.toml index f579f59d4..545511347 100644 --- a/substrate/in-instructions/primitives/Cargo.toml +++ b/substrate/in-instructions/primitives/Cargo.toml @@ -5,7 +5,7 @@ description = "Serai instructions library, enabling encoding and decoding" license = "MIT" authors = ["Luke Parker "] edition = "2021" -rust-version = "1.69" +rust-version = "1.74" [package.metadata.docs.rs] all-features = true diff --git a/substrate/primitives/Cargo.toml b/substrate/primitives/Cargo.toml index 22fc47097..0e1e8f387 100644 --- a/substrate/primitives/Cargo.toml +++ b/substrate/primitives/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT" repository = "https://github.com/serai-dex/serai/tree/develop/substrate/primitives" authors = ["Luke Parker "] edition = "2021" -rust-version = "1.69" +rust-version = "1.74" [package.metadata.docs.rs] all-features = true