Skip to content

Commit

Permalink
chore: bump rust version to latest nightly (#3571)
Browse files Browse the repository at this point in the history
  • Loading branch information
StackOverflowExcept1on authored Feb 2, 2024
1 parent 2edc91c commit a1c7bf7
Show file tree
Hide file tree
Showing 37 changed files with 77 additions and 74 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
4 changes: 2 additions & 2 deletions common/src/gas_provider/property_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type Balance = u64;
type Funds = u128;

std::thread_local! {
static TOTAL_ISSUANCE: RefCell<Option<Balance>> = RefCell::new(None);
static TOTAL_ISSUANCE: RefCell<Option<Balance>> = const { RefCell::new(None) };
}

#[derive(Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -177,7 +177,7 @@ impl<T> From<ReservationKey> for GasNodeId<T, ReservationKey> {
}

std::thread_local! {
static GAS_TREE_NODES: RefCell<BTreeMap<Key, GasNode>> = RefCell::new(BTreeMap::new());
static GAS_TREE_NODES: RefCell<BTreeMap<Key, GasNode>> = const { RefCell::new(BTreeMap::new()) };
}

struct GasTreeNodesWrap;
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
2 changes: 1 addition & 1 deletion examples/constructor/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ static mut SCHEME: Option<Scheme> = None;
fn process_fn<'a>(f: impl Fn(&'a Scheme) -> Option<&'a Vec<Call>>) {
let scheme = unsafe { SCHEME.as_ref() }.expect("Should be set before access");
let calls = f(scheme)
.map(Clone::clone)
.cloned()
.unwrap_or_else(|| msg::load().expect("Failed to load payload"));

let mut res = None;
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/fungible-token/tests/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async fn stress_test() -> Result<()> {
.encode();

let (message_id, program_id, _hash) = api
.upload_program_bytes(WASM_BINARY.to_vec(), [137u8], init_msg, MAX_GAS_LIMIT, 0)
.upload_program_bytes(WASM_BINARY, [137u8], init_msg, MAX_GAS_LIMIT, 0)
.await?;

assert!(listener.message_processed(message_id).await?.succeed());
Expand Down Expand Up @@ -229,7 +229,7 @@ async fn stress_transfer() -> Result<()> {

let salt: u8 = rng.gen();
let (message_id, program_id, _hash) = api
.upload_program_bytes(WASM_BINARY.to_vec(), [salt], init_msg, MAX_GAS_LIMIT, 0)
.upload_program_bytes(WASM_BINARY, [salt], init_msg, MAX_GAS_LIMIT, 0)
.await
.unwrap();

Expand Down
2 changes: 1 addition & 1 deletion examples/new-meta/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extern "C" fn handle() {
let res = unsafe { &WALLETS }
.iter()
.find(|w| w.id.decimal == message_in.id.decimal)
.map(Clone::clone);
.cloned();

let message_out = MessageOut { res };

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
7 changes: 1 addition & 6 deletions gcli/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,12 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! Common utils for integration tests
pub use self::{
args::Args,
node::{Convert, NodeExec},
result::{Error, Result},
};
pub use self::{args::Args, node::NodeExec, result::Result};
use gear_core::ids::{CodeId, ProgramId};
use gsdk::{
ext::{sp_core::crypto::Ss58Codec, sp_runtime::AccountId32},
testing::Node,
};
pub use scale_info::scale::Encode;
use std::{
iter::IntoIterator,
process::{Command, Output},
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
7 changes: 5 additions & 2 deletions gsdk/src/testing/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ impl Node {
return Err(Error::EmptyStderr);
};

for line in BufReader::new(stderr).lines().flatten() {
for line in BufReader::new(stderr)
.lines()
.map_while(|result| result.ok())
{
if line.contains(log) {
return Ok(line);
}
Expand All @@ -91,7 +94,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
2 changes: 1 addition & 1 deletion gstd/src/async_runtime/signals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl WakeSignals {
self.signals.contains_key(&reply_to)
}

pub fn poll(&mut self, reply_to: MessageId, cx: &Context<'_>) -> ReplyPoll {
pub fn poll(&mut self, reply_to: MessageId, cx: &mut Context<'_>) -> ReplyPoll {
match self.signals.remove(&reply_to) {
None => ReplyPoll::None,
Some(mut signal @ WakeSignal { payload: None, .. }) => {
Expand Down
5 changes: 3 additions & 2 deletions gstd/src/macros/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ macro_rules! debug {
#[macro_export]
macro_rules! dbg {
() => {
$crate::debug!("[{}:{}]", $crate::prelude::file!(), $crate::prelude::line!())
$crate::debug!("[{}:{}:{}]", $crate::prelude::file!(), $crate::prelude::line!(), $crate::prelude::column!())
};
($val:expr $(,)?) => {
match $val {
tmp => {
$crate::debug!("[{}:{}] {} = {:#?}",
$crate::debug!("[{}:{}:{}] {} = {:#?}",
$crate::prelude::file!(),
$crate::prelude::line!(),
$crate::prelude::column!(),
$crate::prelude::stringify!($val),
&tmp,
);
Expand Down
2 changes: 1 addition & 1 deletion gstd/src/msg/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use core::{
use futures::future::FusedFuture;
use scale_info::scale::Decode;

fn poll<F, R>(waiting_reply_to: MessageId, cx: &Context<'_>, f: F) -> Poll<Result<R>>
fn poll<F, R>(waiting_reply_to: MessageId, cx: &mut Context<'_>, f: F) -> Poll<Result<R>>
where
F: Fn(Vec<u8>) -> Result<R>,
{
Expand Down
3 changes: 2 additions & 1 deletion gstd/tests/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mod sys {
}

#[test]
#[allow(static_mut_ref)]
fn test_debug() {
let value = 42;

Expand All @@ -28,6 +29,6 @@ fn test_debug() {
crate::dbg!(value);
assert_eq!(
unsafe { &DEBUG_MSG },
b"[gstd/tests/debug.rs:28] value = 42"
b"[gstd/tests/debug.rs:29:5] value = 42"
);
}
6 changes: 3 additions & 3 deletions pallets/gear-voucher/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ benchmarks! {
issue {
// Origin account.
let origin = benchmarking::account::<T::AccountId>("origin", 0, 0);
CurrencyOf::<T>::deposit_creating(
let _ = CurrencyOf::<T>::deposit_creating(
&origin,
100_000_000_000_000_u128.unique_saturated_into()
);
Expand Down Expand Up @@ -72,7 +72,7 @@ benchmarks! {
revoke {
// Origin account.
let origin = benchmarking::account::<T::AccountId>("origin", 0, 0);
CurrencyOf::<T>::deposit_creating(
let _ = CurrencyOf::<T>::deposit_creating(
&origin,
100_000_000_000_000_u128.unique_saturated_into()
);
Expand Down Expand Up @@ -102,7 +102,7 @@ benchmarks! {
update {
// Origin account.
let origin = benchmarking::account::<T::AccountId>("origin", 0, 0);
CurrencyOf::<T>::deposit_creating(
let _ = CurrencyOf::<T>::deposit_creating(
&origin,
100_000_000_000_000_u128.unique_saturated_into()
);
Expand Down
10 changes: 5 additions & 5 deletions pallets/gear/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,9 @@ benchmarks! {

claim_value {
let caller = benchmarking::account("caller", 0, 0);
CurrencyOf::<T>::deposit_creating(&caller, 100_000_000_000_000_u128.unique_saturated_into());
let _ = CurrencyOf::<T>::deposit_creating(&caller, 100_000_000_000_000_u128.unique_saturated_into());
let program_id = benchmarking::account::<T::AccountId>("program", 0, 100);
CurrencyOf::<T>::deposit_creating(&program_id, 100_000_000_000_000_u128.unique_saturated_into());
let _ = CurrencyOf::<T>::deposit_creating(&program_id, 100_000_000_000_000_u128.unique_saturated_into());
let code = benchmarking::generate_wasm(16.into()).unwrap();
benchmarking::set_program::<ProgramStorageOf::<T>, _>(program_id.clone().cast(), code, 1.into());
let original_message_id = benchmarking::account::<T::AccountId>("message", 0, 100).cast();
Expand Down Expand Up @@ -527,7 +527,7 @@ benchmarks! {
send_message {
let p in 0 .. MAX_PAYLOAD_LEN;
let caller = benchmarking::account("caller", 0, 0);
CurrencyOf::<T>::deposit_creating(&caller, 100_000_000_000_000_u128.unique_saturated_into());
let _ = CurrencyOf::<T>::deposit_creating(&caller, 100_000_000_000_000_u128.unique_saturated_into());
let minimum_balance = CurrencyOf::<T>::minimum_balance();
let program_id = benchmarking::account::<T::AccountId>("program", 0, 100).cast();
let code = benchmarking::generate_wasm(16.into()).unwrap();
Expand All @@ -543,10 +543,10 @@ benchmarks! {
send_reply {
let p in 0 .. MAX_PAYLOAD_LEN;
let caller = benchmarking::account("caller", 0, 0);
CurrencyOf::<T>::deposit_creating(&caller, 100_000_000_000_000_u128.unique_saturated_into());
let _ = CurrencyOf::<T>::deposit_creating(&caller, 100_000_000_000_000_u128.unique_saturated_into());
let minimum_balance = CurrencyOf::<T>::minimum_balance();
let program_id = benchmarking::account::<T::AccountId>("program", 0, 100);
CurrencyOf::<T>::deposit_creating(&program_id, 100_000_000_000_000_u128.unique_saturated_into());
let _ = CurrencyOf::<T>::deposit_creating(&program_id, 100_000_000_000_000_u128.unique_saturated_into());
let code = benchmarking::generate_wasm(16.into()).unwrap();
benchmarking::set_program::<ProgramStorageOf::<T>, _>(program_id.clone().cast(), code, 1.into());
let original_message_id = benchmarking::account::<T::AccountId>("message", 0, 100).cast();
Expand Down
15 changes: 10 additions & 5 deletions pallets/gear/src/benchmarking/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ where
use demo_delayed_sender::WASM_BINARY;

let caller = benchmarking::account("caller", 0, 0);
CurrencyOf::<T>::deposit_creating(&caller, 200_000_000_000_000u128.unique_saturated_into());
let _ =
CurrencyOf::<T>::deposit_creating(&caller, 200_000_000_000_000u128.unique_saturated_into());

init_block::<T>(None);

Expand Down Expand Up @@ -53,7 +54,8 @@ where
use demo_reserve_gas::{InitAction, WASM_BINARY};

let caller = benchmarking::account("caller", 0, 0);
CurrencyOf::<T>::deposit_creating(&caller, 200_000_000_000_000u128.unique_saturated_into());
let _ =
CurrencyOf::<T>::deposit_creating(&caller, 200_000_000_000_000u128.unique_saturated_into());

init_block::<T>(None);

Expand Down Expand Up @@ -120,7 +122,8 @@ where
use demo_constructor::{Call, Calls, Scheme, WASM_BINARY};

let caller = benchmarking::account("caller", 0, 0);
CurrencyOf::<T>::deposit_creating(&caller, 200_000_000_000_000u128.unique_saturated_into());
let _ =
CurrencyOf::<T>::deposit_creating(&caller, 200_000_000_000_000u128.unique_saturated_into());

init_block::<T>(None);

Expand Down Expand Up @@ -176,7 +179,8 @@ where
use demo_waiter::{Command, WaitSubcommand, WASM_BINARY};

let caller = benchmarking::account("caller", 0, 0);
CurrencyOf::<T>::deposit_creating(&caller, 200_000_000_000_000u128.unique_saturated_into());
let _ =
CurrencyOf::<T>::deposit_creating(&caller, 200_000_000_000_000u128.unique_saturated_into());

init_block::<T>(None);

Expand Down Expand Up @@ -226,7 +230,8 @@ where
use demo_waiter::{Command, WaitSubcommand, WASM_BINARY};

let caller = benchmarking::account("caller", 0, 0);
CurrencyOf::<T>::deposit_creating(&caller, 200_000_000_000_000u128.unique_saturated_into());
let _ =
CurrencyOf::<T>::deposit_creating(&caller, 200_000_000_000_000u128.unique_saturated_into());

init_block::<T>(None);

Expand Down
Loading

0 comments on commit a1c7bf7

Please sign in to comment.