diff --git a/common/numerated/src/interval.rs b/common/numerated/src/interval.rs index 8a5d7a20dd7..a817e354882 100644 --- a/common/numerated/src/interval.rs +++ b/common/numerated/src/interval.rs @@ -441,7 +441,7 @@ mod tests { #[test] fn size() { assert_eq!(Interval::::try_from(11..111).unwrap().size(), Some(100),); - assert_eq!(Interval::::try_from(..1).unwrap().size(), Some(1),); + assert_eq!(Interval::::from(..1).size(), Some(1),); assert_eq!(Interval::::from(..=1).size(), Some(2)); assert_eq!(Interval::::from(1..).size(), Some(255)); assert_eq!(Interval::::from(0..).size(), None); @@ -452,7 +452,7 @@ mod tests { Interval::::try_from(11..111).unwrap().raw_size(), Some(100), ); - assert_eq!(Interval::::try_from(..1).unwrap().raw_size(), Some(1),); + assert_eq!(Interval::::from(..1).raw_size(), Some(1),); assert_eq!(Interval::::from(..=1).raw_size(), Some(2)); assert_eq!(Interval::::from(1..).raw_size(), Some(255)); assert_eq!(Interval::::from(0..).raw_size(), None); @@ -460,7 +460,7 @@ mod tests { assert_eq!(Interval::::try_from(1..1).unwrap().raw_size(), Some(0)); assert_eq!(Interval::::try_from(-1..99).unwrap().size(), Some(-28)); // corresponds to 100 numeration - assert_eq!(Interval::::try_from(..1).unwrap().size(), Some(1)); // corresponds to 129 numeration + assert_eq!(Interval::::from(..1).size(), Some(1)); // corresponds to 129 numeration assert_eq!(Interval::::from(..=1).size(), Some(2)); // corresponds to 130 numeration assert_eq!(Interval::::from(1..).size(), Some(-1)); // corresponds to 127 numeration assert_eq!(Interval::::from(0..).size(), Some(0)); // corresponds to 128 numeration @@ -471,7 +471,7 @@ mod tests { Interval::::try_from(-1..99).unwrap().raw_size(), Some(100) ); - assert_eq!(Interval::::try_from(..1).unwrap().raw_size(), Some(129)); + assert_eq!(Interval::::from(..1).raw_size(), Some(129)); assert_eq!(Interval::::from(..=1).raw_size(), Some(130)); assert_eq!(Interval::::from(1..).raw_size(), Some(127)); assert_eq!(Interval::::from(0..).raw_size(), Some(128)); diff --git a/examples/constructor/src/builder.rs b/examples/constructor/src/builder.rs index a11b94f0640..8d8dff7c6e5 100644 --- a/examples/constructor/src/builder.rs +++ b/examples/constructor/src/builder.rs @@ -46,8 +46,6 @@ impl Calls { self } - // TODO #3452: remove this on next rust update - #[allow(clippy::useless_conversion)] pub fn add_from_iter(mut self, calls: impl Iterator) -> Self { self.0.extend(calls.into_iter()); self diff --git a/examples/fungible-token/src/wasm.rs b/examples/fungible-token/src/wasm.rs index 9840581aeab..1d90cd7dba4 100644 --- a/examples/fungible-token/src/wasm.rs +++ b/examples/fungible-token/src/wasm.rs @@ -170,10 +170,10 @@ extern "C" fn state() { decimals, } = state; - let balances = balances.into_iter().map(|(k, v)| (k, v)).collect(); + let balances = balances.into_iter().collect(); let allowances = allowances .into_iter() - .map(|(id, allowance)| (id, allowance.into_iter().map(|(k, v)| (k, v)).collect())) + .map(|(id, allowance)| (id, allowance.into_iter().collect())) .collect(); let payload = IoFungibleToken { name, diff --git a/examples/node/src/wasm.rs b/examples/node/src/wasm.rs index 83c9acefa07..a5d014f0807 100644 --- a/examples/node/src/wasm.rs +++ b/examples/node/src/wasm.rs @@ -143,7 +143,7 @@ fn process(request: Request) -> Reply { transition.query_list = state().sub_nodes.iter().cloned().collect(); let first_sub_node = *transition .query_list - .get(0) + .first() .expect("Checked above that sub_nodes is not empty; qed"); transition.last_sent_message_id = msg::send(first_sub_node, request, 0).unwrap(); @@ -176,7 +176,7 @@ fn process(request: Request) -> Reply { if let TransitionState::Ready = transition.state { let first_sub_node = *transition .query_list - .get(0) + .first() .expect("Checked above that sub_nodes is not empty; qed"); transition.query_index = 0; diff --git a/gcli/tests/common/mod.rs b/gcli/tests/common/mod.rs index 78494bb3d1b..cd3dee9147d 100644 --- a/gcli/tests/common/mod.rs +++ b/gcli/tests/common/mod.rs @@ -17,11 +17,7 @@ // along with this program. If not, see . //! Common utils for integration tests -pub use self::{ - args::Args, - result::{Error, Result}, - traits::{Convert, NodeExec}, -}; +pub use self::{args::Args, result::Result, traits::NodeExec}; use gear_core::ids::{CodeId, ProgramId}; use gsdk::{ ext::{sp_core::crypto::Ss58Codec, sp_runtime::AccountId32}, @@ -39,8 +35,6 @@ mod result; pub mod traits; mod prelude { - pub use scale_info::scale::Encode; - pub const ALICE_SS58_ADDRESS: &str = "kGkLEU3e3XXkJp2WK4eNpVmSab5xUNL9QtmLPh8QfCL2EgotW"; } diff --git a/gclient/src/api/listener/mod.rs b/gclient/src/api/listener/mod.rs index 4faf3c3b515..0e489c1ecfd 100644 --- a/gclient/src/api/listener/mod.rs +++ b/gclient/src/api/listener/mod.rs @@ -21,7 +21,6 @@ mod subscription; pub use gsdk::metadata::{gear::Event as GearEvent, Event}; pub use iterator::*; -pub use subscription::*; use crate::{Error, Result}; use async_trait::async_trait; diff --git a/gclient/src/api/storage/mod.rs b/gclient/src/api/storage/mod.rs index 52efb1e3ea2..7cd05ec9495 100644 --- a/gclient/src/api/storage/mod.rs +++ b/gclient/src/api/storage/mod.rs @@ -19,8 +19,6 @@ pub(crate) mod account_id; mod block; -pub use block::*; - use super::{GearApi, Result}; use crate::Error; use account_id::IntoAccountId32; diff --git a/gclient/src/lib.rs b/gclient/src/lib.rs index 1a09bd621a8..bde9c37149b 100644 --- a/gclient/src/lib.rs +++ b/gclient/src/lib.rs @@ -135,7 +135,7 @@ mod api; mod utils; mod ws; -pub use api::{calls::*, error::*, listener::*, GearApi}; +pub use api::{error::*, listener::*, GearApi}; pub use gsdk::metadata::errors; pub use utils::*; pub use ws::WSAddress; diff --git a/gsdk/src/storage.rs b/gsdk/src/storage.rs index 5642a050db0..c3b7b14d3f6 100644 --- a/gsdk/src/storage.rs +++ b/gsdk/src/storage.rs @@ -360,8 +360,7 @@ impl Api { ], ); - let data: Option<(UserStoredMessage, Interval)> = self.fetch_storage(&addr).await.ok(); - Ok(data.map(|(m, i)| (m, i))) + Ok(self.fetch_storage(&addr).await.ok()) } /// Get all mailbox messages or for the provided `address`. diff --git a/gsdk/src/testing/node.rs b/gsdk/src/testing/node.rs index 6dcade77aaf..ff5e9467314 100644 --- a/gsdk/src/testing/node.rs +++ b/gsdk/src/testing/node.rs @@ -70,7 +70,7 @@ impl Node { pub fn wait_for_log_record(&mut self, log: &str) -> Result { let stderr = self.process.stderr.as_mut(); let reader = BufReader::new(stderr.ok_or(Error::EmptyStderr)?); - for line in reader.lines().flatten() { + for line in reader.lines().map_while(|result| result.ok()) { if line.contains(log) { return Ok(line); } @@ -83,7 +83,7 @@ impl Node { pub fn print_logs(&mut self) { let stderr = self.process.stderr.as_mut(); let reader = BufReader::new(stderr.expect("Unable to get stderr")); - for line in reader.lines().flatten() { + for line in reader.lines().map_while(|result| result.ok()) { println!("{line}"); } } diff --git a/pallets/gear/src/manager/mod.rs b/pallets/gear/src/manager/mod.rs index 4973d70a7f6..84ee9b1bff8 100644 --- a/pallets/gear/src/manager/mod.rs +++ b/pallets/gear/src/manager/mod.rs @@ -49,7 +49,6 @@ mod journal; mod task; use gear_core_errors::{ReplyCode, SignalCode}; -pub use journal::*; pub use task::*; use crate::{ diff --git a/runtime/vara/src/lib.rs b/runtime/vara/src/lib.rs index 784f3a7b435..c1e3f2458f9 100644 --- a/runtime/vara/src/lib.rs +++ b/runtime/vara/src/lib.rs @@ -266,8 +266,7 @@ impl pallet_babe::Config for Runtime { type WeightInfo = (); type MaxAuthorities = MaxAuthorities; - type KeyOwnerProof = - >::Proof; + type KeyOwnerProof = sp_session::MembershipProof; type EquivocationReportSystem = pallet_babe::EquivocationReportSystem; } @@ -278,7 +277,7 @@ impl pallet_grandpa::Config for Runtime { type WeightInfo = (); type MaxAuthorities = MaxAuthorities; type MaxSetIdSessionEntries = MaxSetIdSessionEntries; - type KeyOwnerProof = >::Proof; + type KeyOwnerProof = sp_session::MembershipProof; type EquivocationReportSystem = pallet_grandpa::EquivocationReportSystem; } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index a7adebc0c1e..90810b8b6e8 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2023-09-05" +channel = "nightly-2023-12-07" components = [ "llvm-tools" ] targets = [ "wasm32-unknown-unknown" ] profile = "default" diff --git a/scripts/src/clippy.sh b/scripts/src/clippy.sh index 0133a609d66..b70925273ea 100755 --- a/scripts/src/clippy.sh +++ b/scripts/src/clippy.sh @@ -20,14 +20,13 @@ EOF } gear_clippy() { - # TODO #3452: remove `-A clippy::needless_pass_by_ref_mut` on next rust update EXCLUDE_PACKAGES="--exclude vara-runtime --exclude runtime-fuzzer --exclude runtime-fuzzer-fuzz" INCLUDE_PACKAGES="-p vara-runtime -p runtime-fuzzer -p runtime-fuzzer-fuzz" - __GEAR_WASM_BUILDER_NO_BUILD=1 SKIP_WASM_BUILD=1 SKIP_VARA_RUNTIME_WASM_BUILD=1 cargo clippy --workspace "$@" $EXCLUDE_PACKAGES -- --no-deps -D warnings -A clippy::needless_pass_by_ref_mut - __GEAR_WASM_BUILDER_NO_BUILD=1 SKIP_WASM_BUILD=1 SKIP_VARA_RUNTIME_WASM_BUILD=1 cargo clippy $INCLUDE_PACKAGES --all-features -- --no-deps -D warnings -A clippy::needless_pass_by_ref_mut + __GEAR_WASM_BUILDER_NO_BUILD=1 SKIP_WASM_BUILD=1 SKIP_VARA_RUNTIME_WASM_BUILD=1 cargo clippy --workspace "$@" $EXCLUDE_PACKAGES -- --no-deps -D warnings + __GEAR_WASM_BUILDER_NO_BUILD=1 SKIP_WASM_BUILD=1 SKIP_VARA_RUNTIME_WASM_BUILD=1 cargo clippy $INCLUDE_PACKAGES --all-features -- --no-deps -D warnings } examples_clippy() { - __GEAR_WASM_BUILDER_NO_BUILD=1 SKIP_WASM_BUILD=1 SKIP_VARA_RUNTIME_WASM_BUILD=1 cargo clippy -p "demo-*" -p test-syscalls --no-default-features "$@" -- --no-deps -D warnings -A clippy::needless_pass_by_ref_mut + __GEAR_WASM_BUILDER_NO_BUILD=1 SKIP_WASM_BUILD=1 SKIP_VARA_RUNTIME_WASM_BUILD=1 cargo clippy -p "demo-*" -p test-syscalls --no-default-features "$@" -- --no-deps -D warnings } diff --git a/utils/gear-replay-cli/src/lib.rs b/utils/gear-replay-cli/src/lib.rs index 1f54a00d61f..a4cc4b125ff 100644 --- a/utils/gear-replay-cli/src/lib.rs +++ b/utils/gear-replay-cli/src/lib.rs @@ -103,7 +103,7 @@ pub async fn run() -> sc_cli::Result<()> { true => VARA_SS58_PREFIX, false => GEAR_SS58_PREFIX, }; - sp_core::crypto::set_default_ss58_version(ss58_prefix.try_into().unwrap()); + sp_core::crypto::set_default_ss58_version(ss58_prefix.into()); match &options.command { Command::ReplayBlock(cmd) => { diff --git a/utils/runtime-fuzzer/src/runtime/mod.rs b/utils/runtime-fuzzer/src/runtime/mod.rs index cebf312c3a7..21365af3f34 100644 --- a/utils/runtime-fuzzer/src/runtime/mod.rs +++ b/utils/runtime-fuzzer/src/runtime/mod.rs @@ -31,7 +31,7 @@ use vara_runtime::{ }; pub use account::{account, alice}; -pub use block::{default_gas_limit, run_to_block, run_to_next_block}; +pub use block::{default_gas_limit, run_to_next_block}; pub use mailbox::get_mailbox_messages; mod account; diff --git a/utils/validator-checks/src/blocks_production.rs b/utils/validator-checks/src/blocks_production.rs index 3a251fc95b9..7635df4cb08 100644 --- a/utils/validator-checks/src/blocks_production.rs +++ b/utils/validator-checks/src/blocks_production.rs @@ -35,7 +35,7 @@ impl BlocksProduction { } let logs = &block.header().digest.logs; - if let Some(DigestItem::PreRuntime(engine, bytes)) = logs.get(0) { + if let Some(DigestItem::PreRuntime(engine, bytes)) = logs.first() { if *engine == BABE_ENGINE_ID { if let Some(author) = BabePreDigest::decode(&mut bytes.as_ref()) .ok() diff --git a/utils/validator-checks/src/result.rs b/utils/validator-checks/src/result.rs index feb286d403c..fe91997c943 100644 --- a/utils/validator-checks/src/result.rs +++ b/utils/validator-checks/src/result.rs @@ -15,7 +15,7 @@ pub enum Error { EnvLogger(#[from] log::SetLoggerError), /// Decoding ss58 address failed. #[error(transparent)] - PublicError(#[from] gsdk::ext::sp_core::crypto::PublicError), + PublicKey(#[from] gsdk::ext::sp_core::crypto::PublicError), /// Blocks production validation failed. #[error("Some validators didn't produce blocks.")] BlocksProduction, diff --git a/utils/wasm-gen/src/tests.rs b/utils/wasm-gen/src/tests.rs index 8db5c816e40..b8f7163b571 100644 --- a/utils/wasm-gen/src/tests.rs +++ b/utils/wasm-gen/src/tests.rs @@ -184,7 +184,7 @@ fn injecting_addresses_works() { .entries(); let first_addr_offset = entries - .get(0) + .first() .and_then(|segment| segment.offset().as_ref()) .map(|expr| &expr.code()[0]) .expect("checked");