Skip to content

Commit

Permalink
chore: support rust 1.76
Browse files Browse the repository at this point in the history
  • Loading branch information
StackOverflowExcept1on committed Dec 7, 2023
1 parent 37fba1c commit d2d9cda
Show file tree
Hide file tree
Showing 19 changed files with 24 additions and 39 deletions.
8 changes: 4 additions & 4 deletions common/numerated/src/interval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ mod tests {
#[test]
fn size() {
assert_eq!(Interval::<u8>::try_from(11..111).unwrap().size(), Some(100),);
assert_eq!(Interval::<u8>::try_from(..1).unwrap().size(), Some(1),);
assert_eq!(Interval::<u8>::from(..1).size(), Some(1),);
assert_eq!(Interval::<u8>::from(..=1).size(), Some(2));
assert_eq!(Interval::<u8>::from(1..).size(), Some(255));
assert_eq!(Interval::<u8>::from(0..).size(), None);
Expand All @@ -452,15 +452,15 @@ mod tests {
Interval::<u8>::try_from(11..111).unwrap().raw_size(),
Some(100),
);
assert_eq!(Interval::<u8>::try_from(..1).unwrap().raw_size(), Some(1),);
assert_eq!(Interval::<u8>::from(..1).raw_size(), Some(1),);
assert_eq!(Interval::<u8>::from(..=1).raw_size(), Some(2));
assert_eq!(Interval::<u8>::from(1..).raw_size(), Some(255));
assert_eq!(Interval::<u8>::from(0..).raw_size(), None);
assert_eq!(Interval::<u8>::from(..).raw_size(), None);
assert_eq!(Interval::<u8>::try_from(1..1).unwrap().raw_size(), Some(0));

assert_eq!(Interval::<i8>::try_from(-1..99).unwrap().size(), Some(-28)); // corresponds to 100 numeration
assert_eq!(Interval::<i8>::try_from(..1).unwrap().size(), Some(1)); // corresponds to 129 numeration
assert_eq!(Interval::<i8>::from(..1).size(), Some(1)); // corresponds to 129 numeration
assert_eq!(Interval::<i8>::from(..=1).size(), Some(2)); // corresponds to 130 numeration
assert_eq!(Interval::<i8>::from(1..).size(), Some(-1)); // corresponds to 127 numeration
assert_eq!(Interval::<i8>::from(0..).size(), Some(0)); // corresponds to 128 numeration
Expand All @@ -471,7 +471,7 @@ mod tests {
Interval::<i8>::try_from(-1..99).unwrap().raw_size(),
Some(100)
);
assert_eq!(Interval::<i8>::try_from(..1).unwrap().raw_size(), Some(129));
assert_eq!(Interval::<i8>::from(..1).raw_size(), Some(129));
assert_eq!(Interval::<i8>::from(..=1).raw_size(), Some(130));
assert_eq!(Interval::<i8>::from(1..).raw_size(), Some(127));
assert_eq!(Interval::<i8>::from(0..).raw_size(), Some(128));
Expand Down
2 changes: 0 additions & 2 deletions examples/constructor/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Item = Call>) -> Self {
self.0.extend(calls.into_iter());
self
Expand Down
4 changes: 2 additions & 2 deletions examples/fungible-token/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions examples/node/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 1 addition & 7 deletions gcli/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! 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},
Expand All @@ -39,8 +35,6 @@ mod result;
pub mod traits;

mod prelude {
pub use scale_info::scale::Encode;

pub const ALICE_SS58_ADDRESS: &str = "kGkLEU3e3XXkJp2WK4eNpVmSab5xUNL9QtmLPh8QfCL2EgotW";
}

Expand Down
1 change: 0 additions & 1 deletion gclient/src/api/listener/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions gclient/src/api/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion gclient/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
3 changes: 1 addition & 2 deletions gsdk/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,7 @@ impl Api {
],
);

let data: Option<(UserStoredMessage, Interval<u32>)> = 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`.
Expand Down
4 changes: 2 additions & 2 deletions gsdk/src/testing/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl Node {
pub fn wait_for_log_record(&mut self, log: &str) -> Result<String> {
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);
}
Expand All @@ -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}");
}
}
Expand Down
1 change: 0 additions & 1 deletion pallets/gear/src/manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ mod journal;
mod task;

use gear_core_errors::{ReplyCode, SignalCode};
pub use journal::*;
pub use task::*;

use crate::{
Expand Down
5 changes: 2 additions & 3 deletions runtime/vara/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ impl pallet_babe::Config for Runtime {
type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;

type KeyOwnerProof =
<Historical as KeyOwnerProofSystem<(KeyTypeId, pallet_babe::AuthorityId)>>::Proof;
type KeyOwnerProof = sp_session::MembershipProof;
type EquivocationReportSystem =
pallet_babe::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
}
Expand All @@ -278,7 +277,7 @@ impl pallet_grandpa::Config for Runtime {
type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;
type MaxSetIdSessionEntries = MaxSetIdSessionEntries;
type KeyOwnerProof = <Historical as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;
type KeyOwnerProof = sp_session::MembershipProof;
type EquivocationReportSystem =
pallet_grandpa::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
}
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "nightly-2023-09-05"
channel = "nightly-2023-12-07"
components = [ "llvm-tools" ]
targets = [ "wasm32-unknown-unknown" ]
profile = "default"
7 changes: 3 additions & 4 deletions scripts/src/clippy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion utils/gear-replay-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion utils/runtime-fuzzer/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion utils/validator-checks/src/blocks_production.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion utils/validator-checks/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion utils/wasm-gen/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit d2d9cda

Please sign in to comment.