Skip to content

Commit

Permalink
[Rust] Upgrade to Rust version 1.72.1
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshLind committed Sep 28, 2023
1 parent bfcc03a commit edcae56
Show file tree
Hide file tree
Showing 76 changed files with 154 additions and 132 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ homepage = "https://aptoslabs.com"
license = "Apache-2.0"
publish = false
repository = "https://github.com/aptos-labs/aptos-core"
rust-version = "1.71.1"
rust-version = "1.72.1"

[workspace.dependencies]
# Internal crate dependencies.
Expand Down
2 changes: 1 addition & 1 deletion api/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ impl Context {

transactions_and_outputs
.into_iter()
.zip(infos.into_iter())
.zip(infos)
.enumerate()
.map(|(i, ((txn, txn_output), info))| {
let version = start_version + i as u64;
Expand Down
2 changes: 2 additions & 0 deletions api/src/tests/transaction_vector_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0

#![allow(clippy::arc_with_non_send_sync)]

/***************************************************************************************
*
* Purpose of transaction vector test
Expand Down
2 changes: 2 additions & 0 deletions api/test-context/src/golden_output.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0

#![allow(clippy::arc_with_non_send_sync)]

use goldenfile::Mint;
use std::{
fmt::Debug,
Expand Down
2 changes: 1 addition & 1 deletion api/types/src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ impl<'a, R: MoveResolver + ?Sized> MoveConverter<'a, R> {
);
arg_types
.into_iter()
.zip(args.into_iter())
.zip(args)
.enumerate()
.map(|(i, (arg_type, arg))| {
self.try_into_vm_value(&arg_type.clone().try_into()?, arg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn generate_upgrade_proposals(
) -> Result<Vec<(String, String)>> {
const APTOS_GIT_PATH: &str = "https://github.com/aptos-labs/aptos-core.git";

let mut package_path_list = vec![
let mut package_path_list = [
("0x1", "aptos-move/framework/move-stdlib"),
("0x1", "aptos-move/framework/aptos-stdlib"),
("0x1", "aptos-move/framework/aptos-framework"),
Expand Down
1 change: 1 addition & 0 deletions aptos-move/aptos-sdk-builder/src/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub fn output(out: &mut dyn Write, abis: &[EntryABI], local_types: bool) -> Resu
writeln!(emitter.out, "#![allow(dead_code)]")?;
writeln!(emitter.out, "#![allow(unused_imports)]")?;
writeln!(emitter.out, "#![allow(clippy::too_many_arguments)]")?;
writeln!(emitter.out, "#![allow(clippy::arc_with_non_send_sync)]")?;

emitter.output_script_call_enum_with_imports(abis)?;

Expand Down
2 changes: 1 addition & 1 deletion aptos-move/aptos-vm-types/src/change_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ impl VMChangeSet {
.into_iter()
.map(into_write)
.collect::<anyhow::Result<HashMap<StateKey, WriteOp>, VMStatus>>()?;
aggregator_write_set.extend(materialized_aggregator_delta_set.into_iter());
aggregator_write_set.extend(materialized_aggregator_delta_set);

Ok(Self {
resource_write_set,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ impl<S: StateView + Sync + Send + 'static> LocalExecutorService<S> {
.unzip();
let executor_shards = command_rxs
.into_iter()
.zip(result_txs.into_iter())
.zip(cross_shard_msg_rxs.into_iter())
.zip(result_txs)
.zip(cross_shard_msg_rxs)
.enumerate()
.map(|(shard_id, ((command_rx, result_tx), cross_shard_rxs))| {
let cross_shard_client = LocalCrossShardClient::new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ pub(crate) fn construct_args(
if types.len() != args.len() {
return Err(invalid_signature());
}
for (ty, arg) in types.iter().zip(args.into_iter()) {
for (ty, arg) in types.iter().zip(args) {
let arg = construct_arg(
session,
&ty.subst(ty_args).unwrap(),
Expand Down
4 changes: 2 additions & 2 deletions aptos-move/block-executor/src/proptest_types/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@ impl<V: Into<Vec<u8>> + Arbitrary + Clone + Debug + Eq + Sync + Send> Transactio
allow_deletes,
)
.into_iter()
.zip(reads.into_iter())
.zip(gas.into_iter())
.zip(reads)
.zip(gas)
.map(|(((writes, deltas), reads), gas)| MockIncarnation {
reads,
writes,
Expand Down
10 changes: 5 additions & 5 deletions aptos-move/e2e-move-tests/src/tests/string_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,13 @@ fn string_args_bad_utf8() {
tests.push(("0xcafe::test::hi", args, abort_info()));

// vector of strings
let bad = vec![0xC3u8, 0x28u8];
let bad = [0xC3u8, 0x28u8];
let s_vec = vec![&bad[..], "hello".as_bytes(), "world".as_bytes()];
let i = 0u64;
let args = vec![bcs::to_bytes(&s_vec).unwrap(), bcs::to_bytes(&i).unwrap()];
tests.push(("0xcafe::test::str_vec", args, abort_info()));

let bad = vec![0xC3u8, 0x28u8];
let bad = [0xC3u8, 0x28u8];
let s_vec = vec![&bad[..], "hello".as_bytes(), "world".as_bytes()];
let args = vec![bcs::to_bytes(&s_vec).unwrap(), bcs::to_bytes(&i).unwrap()];
tests.push(("0xcafe::test::str_vec", args, abort_info()));
Expand All @@ -333,7 +333,7 @@ fn string_args_bad_utf8() {
let i = 0u64;
let j = 0u64;

let bad = vec![0x40u8, 0xFEu8];
let bad = [0x40u8, 0xFEu8];
let s_vec = vec![
vec![&bad[..], "hello".as_bytes(), "world".as_bytes()],
vec![
Expand All @@ -354,7 +354,7 @@ fn string_args_bad_utf8() {
];
tests.push(("0xcafe::test::str_vec_vec", args, abort_info()));

let bad = vec![0xF0u8, 0x28u8, 0x8Cu8, 0x28u8];
let bad = [0xF0u8, 0x28u8, 0x8Cu8, 0x28u8];
let s_vec = vec![
vec![
"hi there!".as_bytes(),
Expand All @@ -375,7 +375,7 @@ fn string_args_bad_utf8() {
];
tests.push(("0xcafe::test::str_vec_vec", args, abort_info()));

let bad = vec![0x60u8, 0xFFu8];
let bad = [0x60u8, 0xFFu8];
let s_vec = vec![
vec![
"hi there!".as_bytes(),
Expand Down
2 changes: 2 additions & 0 deletions aptos-move/e2e-tests/src/account_universe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Parts of the project are originally copyright © Meta Platforms, Inc.
// SPDX-License-Identifier: Apache-2.0

#![allow(clippy::arc_with_non_send_sync)]

//! A model to test properties of common Aptos transactions.
//!
//! The structs and functions in this module together form a simplified *model* of how common Aptos
Expand Down
2 changes: 2 additions & 0 deletions aptos-move/e2e-tests/src/account_universe/create_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Parts of the project are originally copyright © Meta Platforms, Inc.
// SPDX-License-Identifier: Apache-2.0

#![allow(clippy::arc_with_non_send_sync)]

use crate::{
account::{Account, AccountData},
account_universe::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::arc_with_non_send_sync)]
use aptos_types::{
account_address::AccountAddress,
transaction::{EntryFunction, TransactionPayload},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::arc_with_non_send_sync)]
use aptos_types::{
account_address::AccountAddress,
transaction::{EntryFunction, TransactionPayload},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::arc_with_non_send_sync)]
use aptos_types::{
account_address::AccountAddress,
transaction::{EntryFunction, TransactionPayload},
Expand Down
2 changes: 1 addition & 1 deletion aptos-move/framework/src/natives/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ fn native_request_publish(
allowed
.entry(destination)
.or_default()
.extend(expected_modules.clone().into_iter());
.extend(expected_modules.clone());
allowed
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,9 @@ pub(crate) fn native_double_scalar_mul(
point_data.get_point(&handle2),
];

let scalars = vec![scalar1, scalar2];
let scalars = [scalar1, scalar2];

let result = RistrettoPoint::vartime_multiscalar_mul(scalars.iter(), points.into_iter());
let result = RistrettoPoint::vartime_multiscalar_mul(scalars.iter(), points);

let result_handle = point_data.safe_add_point(result)?;

Expand Down Expand Up @@ -629,7 +629,7 @@ pub(crate) fn safe_native_multi_scalar_mul_no_floating_point(
// 1. Strauss, when n <= 190, see https://www.jstor.org/stable/2310929
// 2. Pippinger, when n > 190, which roughly requires O(n / log_2 n) scalar multiplications
// For simplicity, we estimate the complexity as O(n / log_2 n)
RistrettoPoint::vartime_multiscalar_mul(scalars.iter(), points.into_iter())
RistrettoPoint::vartime_multiscalar_mul(scalars.iter(), points)
};

let mut point_data_mut = context
Expand Down
2 changes: 1 addition & 1 deletion consensus/consensus-types/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub enum DataStatus {
impl DataStatus {
pub fn extend(&mut self, other: DataStatus) {
match (self, other) {
(DataStatus::Requested(v1), DataStatus::Requested(v2)) => v1.extend(v2.into_iter()),
(DataStatus::Requested(v1), DataStatus::Requested(v2)) => v1.extend(v2),
(_, _) => unreachable!(),
}
}
Expand Down
2 changes: 2 additions & 0 deletions consensus/safety-rules/src/fuzzing_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Parts of the project are originally copyright © Meta Platforms, Inc.
// SPDX-License-Identifier: Apache-2.0

#![allow(clippy::arc_with_non_send_sync)]

use crate::serializer::SafetyRulesInput;
#[cfg(any(test, feature = "fuzzing"))]
use aptos_consensus_types::block::Block;
Expand Down
2 changes: 1 addition & 1 deletion consensus/src/dag/dag_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ impl Dag {
}

fn reachable_filter(start: Vec<HashValue>) -> impl FnMut(&Arc<CertifiedNode>) -> bool {
let mut reachable: HashSet<HashValue> = HashSet::from_iter(start.into_iter());
let mut reachable: HashSet<HashValue> = HashSet::from_iter(start);
move |node| {
if reachable.contains(&node.digest()) {
for parent in node.parents() {
Expand Down
2 changes: 1 addition & 1 deletion consensus/src/experimental/tests/buffer_manager_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,6 @@ fn buffer_manager_sync_test() {
// we should only see batches[dropped_batches..num_batches]
assert_results(batches.drain(dropped_batches..).collect(), &mut result_rx).await;

assert!(matches!(result_rx.next().now_or_never(), None));
assert!(result_rx.next().now_or_never().is_none());
});
}
2 changes: 1 addition & 1 deletion crates/aptos-crypto/benches/ristretto255.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn multi_scalar_mul<M: Measurement>(g: &mut BenchmarkGroup<M>, n: usize) {
|(points, scalars)| {
RistrettoPoint::vartime_multiscalar_mul(
scalars.iter(),
points.iter().collect::<Vec<&RistrettoPoint>>().into_iter(),
points.iter().collect::<Vec<&RistrettoPoint>>(),
)
},
)
Expand Down
2 changes: 1 addition & 1 deletion crates/aptos-crypto/src/unit_tests/hash_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn test_from_slice() {
assert!(HashValue::from_slice(zero_byte_vec).is_err());
}
{
let bytes = vec![1; 123];
let bytes = [1; 123];
assert!(HashValue::from_slice(&bytes[..]).is_err());
}
}
Expand Down
13 changes: 5 additions & 8 deletions crates/aptos-crypto/src/unit_tests/multi_ed25519_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ fn test_multi_ed25519_signature_serialization() {
// We can construct signatures from 32 single signatures.
let sigs_32 = vec![single_signature.clone(); 32];
let indices = 0..32;
let sig32_tuple = sigs_32.into_iter().zip(indices.into_iter()).collect();
let sig32_tuple = sigs_32.into_iter().zip(indices).collect();

let multi_sig32 = MultiEd25519Signature::new(sig32_tuple);
assert!(multi_sig32.is_ok());
Expand All @@ -224,7 +224,7 @@ fn test_multi_ed25519_signature_serialization() {
// Fail to construct a MultiEd25519Signature object from 33 or more single signatures.
let sigs_33 = vec![single_signature.clone(); 33];
let indices = 0..33;
let sig33_tuple = sigs_33.into_iter().zip(indices.into_iter()).collect();
let sig33_tuple = sigs_33.into_iter().zip(indices).collect();

let multi_sig33 = MultiEd25519Signature::new(sig33_tuple);
assert!(multi_sig33.is_err());
Expand All @@ -239,7 +239,7 @@ fn test_multi_ed25519_signature_serialization() {
let sig3_tuple = sigs_3
.clone()
.into_iter()
.zip(indices_with_duplicate.into_iter())
.zip(indices_with_duplicate)
.collect();

let multi_sig3 = MultiEd25519Signature::new(sig3_tuple);
Expand All @@ -251,10 +251,7 @@ fn test_multi_ed25519_signature_serialization() {

// Fail to construct a MultiEd25519Signature object if an index is out of range.
let indices_with_out_of_range = vec![0u8, 33u8, 1u8];
let sig3_tuple = sigs_3
.into_iter()
.zip(indices_with_out_of_range.into_iter())
.collect();
let sig3_tuple = sigs_3.into_iter().zip(indices_with_out_of_range).collect();

let multi_sig3 = MultiEd25519Signature::new(sig3_tuple);
assert!(multi_sig3.is_err());
Expand Down Expand Up @@ -511,7 +508,7 @@ fn test_invalid_multi_ed25519_signature_bitmap() {
#[test]
#[ignore]
fn test_sample_multisig() {
let test_cases = vec![(1, 1), (1, 2), (2, 2), (2, 3), (3, 10), (15, 32)]
let test_cases = [(1, 1), (1, 2), (2, 2), (2, 3), (3, 10), (15, 32)]
.iter()
.map(|(k, n)| (*k as usize, *n as usize))
.collect::<Vec<(usize, usize)>>();
Expand Down
Loading

0 comments on commit edcae56

Please sign in to comment.