From 0076d5f4690dd8508adedf787816cb6404ac2ff6 Mon Sep 17 00:00:00 2001 From: satyamacn Date: Fri, 17 Mar 2023 06:39:26 +0000 Subject: [PATCH] upgrade rust toolchain 1.62.1 && edition 2021 && cargo clippy --fix --- devtools/x-core/Cargo.toml | 2 +- devtools/x-lint/Cargo.toml | 2 +- devtools/x/Cargo.toml | 2 +- devtools/x/src/lint/guppy.rs | 13 ++++++------ language/benchmarks/Cargo.toml | 2 +- .../diem-framework/crates/cli/Cargo.toml | 2 +- .../crates/crypto-derive/Cargo.toml | 2 +- .../diem-framework/crates/crypto/Cargo.toml | 2 +- .../diem-framework/crates/natives/Cargo.toml | 2 +- language/evm/extract-ethereum-abi/Cargo.toml | 2 +- language/evm/move-ethereum-abi/Cargo.toml | 2 +- language/evm/move-to-yul/Cargo.toml | 2 +- .../evm/move-to-yul/src/abi_move_metadata.rs | 4 ++-- language/evm/move-to-yul/src/context.rs | 5 ++--- .../move-to-yul/src/dispatcher_generator.rs | 18 ++++++++-------- language/evm/move-to-yul/src/solidity_ty.rs | 2 +- language/evm/move-to-yul/src/vectors.rs | 2 +- language/evm/move-to-yul/tests/testsuite.rs | 16 ++++++++------ language/move-analyzer/Cargo.toml | 2 +- language/move-binary-format/Cargo.toml | 2 +- .../serializer-tests/Cargo.toml | 2 +- language/move-borrow-graph/Cargo.toml | 2 +- language/move-borrow-graph/src/references.rs | 2 +- language/move-bytecode-verifier/Cargo.toml | 2 +- .../bytecode-verifier-tests/Cargo.toml | 2 +- .../invalid-mutations/Cargo.toml | 2 +- .../transactional-tests/Cargo.toml | 2 +- language/move-command-line-common/Cargo.toml | 2 +- language/move-compiler/Cargo.toml | 2 +- language/move-compiler/src/diagnostics/mod.rs | 8 +++---- language/move-compiler/src/expansion/ast.rs | 2 +- .../move-compiler/src/naming/translate.rs | 2 +- .../transactional-tests/Cargo.toml | 2 +- language/move-core/types/Cargo.toml | 2 +- language/move-ir-compiler/Cargo.toml | 2 +- .../move-bytecode-source-map/Cargo.toml | 2 +- .../move-ir-to-bytecode/Cargo.toml | 2 +- .../move-ir-to-bytecode/src/compiler.rs | 15 +++++++------ .../move-ir-to-bytecode/syntax/Cargo.toml | 2 +- .../src/unit_tests/function_tests.rs | 7 ++++--- .../transactional-tests/Cargo.toml | 2 +- language/move-ir/types/Cargo.toml | 2 +- language/move-model/Cargo.toml | 2 +- language/move-prover/Cargo.toml | 2 +- .../move-prover/boogie-backend/Cargo.toml | 2 +- language/move-prover/bytecode/Cargo.toml | 2 +- language/move-prover/bytecode/src/lib.rs | 5 +++-- .../src/well_formed_instrumentation.rs | 2 +- .../interpreter-testsuite/Cargo.toml | 2 +- language/move-prover/interpreter/Cargo.toml | 2 +- .../move-prover/interpreter/crypto/Cargo.toml | 2 +- language/move-prover/interpreter/src/lib.rs | 6 ++++-- language/move-prover/lab/Cargo.toml | 2 +- language/move-prover/lab/src/plot.rs | 3 +-- language/move-prover/move-abigen/Cargo.toml | 2 +- language/move-prover/move-docgen/Cargo.toml | 2 +- .../move-prover/move-docgen/src/docgen.rs | 9 +++++++- .../move-prover/move-errmapgen/Cargo.toml | 2 +- language/move-prover/mutation/Cargo.toml | 2 +- language/move-prover/test-utils/Cargo.toml | 2 +- .../move-prover/tools/spec-flatten/Cargo.toml | 2 +- language/move-symbol-pool/Cargo.toml | 2 +- language/move-vm/integration-tests/Cargo.toml | 2 +- language/move-vm/runtime/Cargo.toml | 2 +- language/move-vm/runtime/src/tracing.rs | 2 +- language/move-vm/test-utils/Cargo.toml | 2 +- .../move-vm/transactional-tests/Cargo.toml | 2 +- language/move-vm/types/Cargo.toml | 2 +- .../module-generation/Cargo.toml | 2 +- .../testing-infra/test-generation/Cargo.toml | 2 +- .../test-generation/src/transitions.rs | 6 +++--- .../transactional-test-runner/Cargo.toml | 2 +- .../src/framework.rs | 21 ++++++++++++------- language/tools/move-bytecode-utils/Cargo.toml | 2 +- .../tools/move-bytecode-viewer/Cargo.toml | 2 +- .../src/bytecode_viewer.rs | 2 +- language/tools/move-cli/Cargo.toml | 2 +- .../move-cli/src/sandbox/commands/test.rs | 7 ++++--- .../src/sandbox/utils/on_disk_state_view.rs | 2 +- language/tools/move-coverage/Cargo.toml | 2 +- language/tools/move-disassembler/Cargo.toml | 2 +- language/tools/move-explain/Cargo.toml | 2 +- language/tools/move-package/Cargo.toml | 2 +- .../tools/move-resource-viewer/Cargo.toml | 2 +- language/tools/move-unit-test/Cargo.toml | 2 +- .../tools/move-unit-test/src/test_reporter.rs | 2 +- .../tools/move-unit-test/src/test_runner.rs | 2 +- language/tools/read-write-set/Cargo.toml | 2 +- .../tools/read-write-set/dynamic/Cargo.toml | 2 +- .../tools/read-write-set/types/Cargo.toml | 2 +- rust-toolchain | 2 +- rustfmt.toml | 2 +- x.toml | 8 +++++++ 93 files changed, 168 insertions(+), 137 deletions(-) diff --git a/devtools/x-core/Cargo.toml b/devtools/x-core/Cargo.toml index cad7367c3a..710b0b403a 100644 --- a/devtools/x-core/Cargo.toml +++ b/devtools/x-core/Cargo.toml @@ -3,7 +3,7 @@ name = "x-core" version = "0.1.0" authors = ["Diem Association "] description = "Core data structures used by x" -edition = "2018" +edition = "2021" publish = false license = "Apache-2.0" diff --git a/devtools/x-lint/Cargo.toml b/devtools/x-lint/Cargo.toml index 4174311b85..69ddfb7c08 100644 --- a/devtools/x-lint/Cargo.toml +++ b/devtools/x-lint/Cargo.toml @@ -3,7 +3,7 @@ name = "x-lint" version = "0.1.0" authors = ["Diem Association "] description = "Lint engine for x" -edition = "2018" +edition = "2021" publish = false license = "Apache-2.0" diff --git a/devtools/x/Cargo.toml b/devtools/x/Cargo.toml index 2d9c9498ea..81da9cb0b1 100644 --- a/devtools/x/Cargo.toml +++ b/devtools/x/Cargo.toml @@ -3,7 +3,7 @@ name = "x" version = "0.1.0" authors = ["Diem Association "] description = "Diem extended cargo tasks" -edition = "2018" +edition = "2021" publish = false license = "Apache-2.0" diff --git a/devtools/x/src/lint/guppy.rs b/devtools/x/src/lint/guppy.rs index a2b68b2a5a..6a633f58c2 100644 --- a/devtools/x/src/lint/guppy.rs +++ b/devtools/x/src/lint/guppy.rs @@ -13,6 +13,7 @@ use guppy::{ }; use std::{ collections::{BTreeMap, HashMap}, + fmt::Write as FmtWrite, iter, }; use x_core::{WorkspaceStatus, XCoreContext}; @@ -269,9 +270,7 @@ impl<'cfg> ProjectLinter for DirectDepDups<'cfg> { if versions.len() > 1 { let mut msg = format!("duplicate direct dependency '{}':\n", direct_dep); for (version, packages) in versions { - msg.push_str(&format!(" * {} (", version)); - msg.push_str(&packages.join(", ")); - msg.push_str(")\n"); + writeln!(&mut msg, " * {} ({})", version, &packages.join(", ")).unwrap(); } out.write(LintLevel::Error, msg); } @@ -360,12 +359,14 @@ impl<'cfg> PackageLinter for OverlayFeatures<'cfg> { if !overlays.is_empty() { let mut msg = "overlay features enabled by default:\n".to_string(); for (from_feature, to_package, to_feature) in overlays { - msg.push_str(&format!( - " * {} -> {}/{}\n", + writeln!( + &mut msg, + " * {} -> {}/{}", feature_str(from_feature), to_package, feature_str(to_feature) - )); + ) + .unwrap(); } msg.push_str("Use a line in the [features] section instead.\n"); out.write(LintLevel::Error, msg); diff --git a/language/benchmarks/Cargo.toml b/language/benchmarks/Cargo.toml index 8398914568..c2becf96cb 100644 --- a/language/benchmarks/Cargo.toml +++ b/language/benchmarks/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0.52" diff --git a/language/documentation/examples/diem-framework/crates/cli/Cargo.toml b/language/documentation/examples/diem-framework/crates/cli/Cargo.toml index 7976e01e29..5a23c9a88d 100644 --- a/language/documentation/examples/diem-framework/crates/cli/Cargo.toml +++ b/language/documentation/examples/diem-framework/crates/cli/Cargo.toml @@ -5,7 +5,7 @@ description = "CLI frontend for the Move compiler and VM (with Diem Framework)" authors = ["Diem Association "] license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0.52" diff --git a/language/documentation/examples/diem-framework/crates/crypto-derive/Cargo.toml b/language/documentation/examples/diem-framework/crates/crypto-derive/Cargo.toml index efae300ae2..cd5d74589c 100644 --- a/language/documentation/examples/diem-framework/crates/crypto-derive/Cargo.toml +++ b/language/documentation/examples/diem-framework/crates/crypto-derive/Cargo.toml @@ -3,7 +3,7 @@ name = "diem-crypto-derive" version = "0.0.3" authors = ["Diem Association "] publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [lib] diff --git a/language/documentation/examples/diem-framework/crates/crypto/Cargo.toml b/language/documentation/examples/diem-framework/crates/crypto/Cargo.toml index ceba097221..4f81b5a1cd 100644 --- a/language/documentation/examples/diem-framework/crates/crypto/Cargo.toml +++ b/language/documentation/examples/diem-framework/crates/crypto/Cargo.toml @@ -3,7 +3,7 @@ name = "diem-crypto" version = "0.0.3" authors = ["Diem Association "] publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [dependencies] diff --git a/language/documentation/examples/diem-framework/crates/natives/Cargo.toml b/language/documentation/examples/diem-framework/crates/natives/Cargo.toml index f59df07096..cc2867982a 100644 --- a/language/documentation/examples/diem-framework/crates/natives/Cargo.toml +++ b/language/documentation/examples/diem-framework/crates/natives/Cargo.toml @@ -3,7 +3,7 @@ name = "diem-framework-natives" version = "0.0.0" authors = ["Diem Association "] publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [dependencies] diff --git a/language/evm/extract-ethereum-abi/Cargo.toml b/language/evm/extract-ethereum-abi/Cargo.toml index d40acabe04..7ae124f1be 100644 --- a/language/evm/extract-ethereum-abi/Cargo.toml +++ b/language/evm/extract-ethereum-abi/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Diem Association "] description = "Extract Etherem ABI" publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [dependencies] diff --git a/language/evm/move-ethereum-abi/Cargo.toml b/language/evm/move-ethereum-abi/Cargo.toml index c837746ad9..329e78cec5 100644 --- a/language/evm/move-ethereum-abi/Cargo.toml +++ b/language/evm/move-ethereum-abi/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Diem Association "] description = "Move Ethereum ABI" publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [dependencies] diff --git a/language/evm/move-to-yul/Cargo.toml b/language/evm/move-to-yul/Cargo.toml index 34f28a7dcf..40b2798ec6 100644 --- a/language/evm/move-to-yul/Cargo.toml +++ b/language/evm/move-to-yul/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Diem Association "] description = "Move Solidity Generator" publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [dependencies] diff --git a/language/evm/move-to-yul/src/abi_move_metadata.rs b/language/evm/move-to-yul/src/abi_move_metadata.rs index 3509b1021d..ada28f2069 100644 --- a/language/evm/move-to-yul/src/abi_move_metadata.rs +++ b/language/evm/move-to-yul/src/abi_move_metadata.rs @@ -25,7 +25,7 @@ pub(crate) fn generate_abi_move_metadata(ctx: &Context, receive: bool, fallback: let st_env = ctx.env.get_struct(key.to_qualified_id()); event_map.insert( st_env.get_identifier().unwrap().to_string(), - from_event_sig(ctx.event_signature_map.borrow().get(&key).unwrap()), + from_event_sig(ctx.event_signature_map.borrow().get(key).unwrap()), ); } @@ -33,7 +33,7 @@ pub(crate) fn generate_abi_move_metadata(ctx: &Context, receive: bool, fallback: let mut func_map = BTreeMap::new(); for (key, (solidity_sig, attr)) in ctx.callable_function_map.borrow().iter() { let fun = ctx.env.get_function(key.to_qualified_id()); - let abi_sig = from_solidity_sig(&solidity_sig, Some(*attr), "function"); + let abi_sig = from_solidity_sig(solidity_sig, Some(*attr), "function"); func_map.insert(fun.get_identifier().to_string(), abi_sig); } diff --git a/language/evm/move-to-yul/src/context.rs b/language/evm/move-to-yul/src/context.rs index 319cdd3fbb..5dc9461ee8 100644 --- a/language/evm/move-to-yul/src/context.rs +++ b/language/evm/move-to-yul/src/context.rs @@ -353,8 +353,7 @@ impl<'a> Context<'a> { fn get_target_structs(&self, p: impl Fn(&StructEnv) -> bool) -> Vec> { self.env .get_modules() - .map(|m| m.into_structs().filter(|f| p(f))) - .flatten() + .flat_map(|m| m.into_structs().filter(|f| p(f))) .collect() } @@ -607,7 +606,7 @@ impl<'a> Context<'a> { .get_local_name(idx) .display(target.symbol_pool()) .to_string() - .replace("#", "_") + .replace('#', "_") } /// Make name for a result. diff --git a/language/evm/move-to-yul/src/dispatcher_generator.rs b/language/evm/move-to-yul/src/dispatcher_generator.rs index 833bb5d38b..6aa3b06979 100644 --- a/language/evm/move-to-yul/src/dispatcher_generator.rs +++ b/language/evm/move-to-yul/src/dispatcher_generator.rs @@ -260,8 +260,8 @@ impl Generator { /// Generate optional receive function. fn optional_receive(&mut self, ctx: &Context, receive: &Option>) -> bool { if let Some(receive) = receive { - ctx.check_no_generics(&receive); - if !attributes::is_payable_fun(&receive) { + ctx.check_no_generics(receive); + if !attributes::is_payable_fun(receive) { ctx.env .error(&receive.get_loc(), "receive function must be payable") } @@ -308,8 +308,8 @@ impl Generator { fallback: &Option>, ) { if let Some(fallback) = fallback { - ctx.check_no_generics(&fallback); - if !attributes::is_payable_fun(&fallback) { + ctx.check_no_generics(fallback); + if !attributes::is_payable_fun(fallback) { self.generate_call_value_check(ctx, REVERT_ERR_NON_PAYABLE_FUN); } let fun_id = &fallback @@ -559,7 +559,7 @@ impl Generator { ); }); head_pos += ty_size; - let memory_func = ctx.memory_store_builtin_fun(&move_ty); + let memory_func = ctx.memory_store_builtin_fun(move_ty); if local_typ_var.len() == 1 { gen.call_builtin( ctx, @@ -1453,7 +1453,7 @@ impl Generator { { let is_static = ty.is_static(); let local_typ_var = vec![ret_var[stack_pos].clone()]; - let memory_func = ctx.memory_load_builtin_fun(&move_ty); + let memory_func = ctx.memory_load_builtin_fun(move_ty); if local_typ_var.len() == 1 { emitln!( ctx.writer, @@ -1473,7 +1473,7 @@ impl Generator { ctx, &ty.clone(), &SignatureDataLocation::Memory, - &move_ty, + move_ty, sub_option.clone() ), local_typ_var[0].clone() @@ -1487,7 +1487,7 @@ impl Generator { ctx, &ty.clone(), &SignatureDataLocation::Memory, - &move_ty, + move_ty, sub_option.clone() ), local_typ_var[0].clone(), @@ -1506,7 +1506,7 @@ impl Generator { ctx, &ty.clone(), &SignatureDataLocation::Memory, - &move_ty, + move_ty, sub_option.clone() ), local_typ_var[0].clone() diff --git a/language/evm/move-to-yul/src/solidity_ty.rs b/language/evm/move-to-yul/src/solidity_ty.rs index c09d017dd6..9283af7c46 100644 --- a/language/evm/move-to-yul/src/solidity_ty.rs +++ b/language/evm/move-to-yul/src/solidity_ty.rs @@ -397,7 +397,7 @@ impl SolidityType { let error_msg = "illegal type name"; return Err(anyhow!(error_msg)); } - ctx.check_or_create_struct_abi(&trimmed_ty_str) + ctx.check_or_create_struct_abi(trimmed_ty_str) } } diff --git a/language/evm/move-to-yul/src/vectors.rs b/language/evm/move-to-yul/src/vectors.rs index 1586aa5ab7..0fd14a3a15 100644 --- a/language/evm/move-to-yul/src/vectors.rs +++ b/language/evm/move-to-yul/src/vectors.rs @@ -1050,7 +1050,7 @@ fn define_destroy_empty_fun( /// Generate equality method for the vector type. pub(crate) fn equality_fun(gen: &mut Generator, ctx: &Context, ty: &Type) { - let elem_type = get_elem_type(&ty).unwrap(); + let elem_type = get_elem_type(ty).unwrap(); if ctx.type_allocates_memory(&elem_type) { emitln!( ctx.writer, diff --git a/language/evm/move-to-yul/tests/testsuite.rs b/language/evm/move-to-yul/tests/testsuite.rs index 86029f55fc..c0e49c8cc2 100644 --- a/language/evm/move-to-yul/tests/testsuite.rs +++ b/language/evm/move-to-yul/tests/testsuite.rs @@ -18,6 +18,7 @@ use move_to_yul::{generator::Generator, options::Options}; use primitive_types::{H160, U256}; use std::{ collections::BTreeMap, + fmt::Write, path::{Path, PathBuf}, }; @@ -115,16 +116,19 @@ fn run_tests( let mut res = String::new(); res.push_str("!! Unit tests\n\n"); for (fun, source) in test_cases { - res.push_str(&format!( - "// test of {}\n", + writeln!( + &mut res, + "// test of {}", env.get_function(*fun).get_full_name_str() - )); + ) + .unwrap(); res.push_str(source); - res.push_str(&format!( - "===> Test result of {}: {}\n\n", + writeln!( + &mut res, + "===> Test result of {}: {}\n", env.get_function(*fun).get_full_name_str(), execute_test(env, source)? - )); + )?; } Ok(res) } diff --git a/language/move-analyzer/Cargo.toml b/language/move-analyzer/Cargo.toml index c15d5ea4de..ea1ca98156 100644 --- a/language/move-analyzer/Cargo.toml +++ b/language/move-analyzer/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0.52" diff --git a/language/move-binary-format/Cargo.toml b/language/move-binary-format/Cargo.toml index 0ae756af37..25ea04cdf2 100644 --- a/language/move-binary-format/Cargo.toml +++ b/language/move-binary-format/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = ["crates-io"] -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0.52" diff --git a/language/move-binary-format/serializer-tests/Cargo.toml b/language/move-binary-format/serializer-tests/Cargo.toml index a7a85baba6..1cd9077992 100644 --- a/language/move-binary-format/serializer-tests/Cargo.toml +++ b/language/move-binary-format/serializer-tests/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dev-dependencies] proptest = "1.0.0" diff --git a/language/move-borrow-graph/Cargo.toml b/language/move-borrow-graph/Cargo.toml index 5e2285b2ef..891b9be448 100644 --- a/language/move-borrow-graph/Cargo.toml +++ b/language/move-borrow-graph/Cargo.toml @@ -3,5 +3,5 @@ name = "move-borrow-graph" version = "0.0.1" authors = ["Diem Association "] publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" diff --git a/language/move-borrow-graph/src/references.rs b/language/move-borrow-graph/src/references.rs index c26d788a9e..fffd418a72 100644 --- a/language/move-borrow-graph/src/references.rs +++ b/language/move-borrow-graph/src/references.rs @@ -228,7 +228,7 @@ impl Debug for BorrowEdge { // Iteration //********************************************************************************************** -impl<'a, Loc: Copy, Lbl: Clone + Ord> IntoIterator for BorrowEdgeSet { +impl IntoIterator for BorrowEdgeSet { type Item = BorrowEdge; type IntoIter = std::collections::btree_set::IntoIter>; diff --git a/language/move-bytecode-verifier/Cargo.toml b/language/move-bytecode-verifier/Cargo.toml index c85640fbeb..5049b4be10 100644 --- a/language/move-bytecode-verifier/Cargo.toml +++ b/language/move-bytecode-verifier/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0.52" diff --git a/language/move-bytecode-verifier/bytecode-verifier-tests/Cargo.toml b/language/move-bytecode-verifier/bytecode-verifier-tests/Cargo.toml index 7ba9a30293..8b256d6d88 100644 --- a/language/move-bytecode-verifier/bytecode-verifier-tests/Cargo.toml +++ b/language/move-bytecode-verifier/bytecode-verifier-tests/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dev-dependencies] petgraph = "0.5.1" diff --git a/language/move-bytecode-verifier/invalid-mutations/Cargo.toml b/language/move-bytecode-verifier/invalid-mutations/Cargo.toml index 5f6fc2617c..ed46af714c 100644 --- a/language/move-bytecode-verifier/invalid-mutations/Cargo.toml +++ b/language/move-bytecode-verifier/invalid-mutations/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "invalid-mutations" version = "0.1.0" -edition = "2018" +edition = "2021" authors = ["Diem Association "] description = "Diem invalid mutations" repository = "https://github.com/diem/diem" diff --git a/language/move-bytecode-verifier/transactional-tests/Cargo.toml b/language/move-bytecode-verifier/transactional-tests/Cargo.toml index 403f8f1b8f..e30e2600e0 100644 --- a/language/move-bytecode-verifier/transactional-tests/Cargo.toml +++ b/language/move-bytecode-verifier/transactional-tests/Cargo.toml @@ -3,7 +3,7 @@ name = "bytecode-verifier-transactional-tests" version = "0.1.0" authors = ["Diem Association "] publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [dev-dependencies] diff --git a/language/move-command-line-common/Cargo.toml b/language/move-command-line-common/Cargo.toml index b46997d364..361d3431c2 100644 --- a/language/move-command-line-common/Cargo.toml +++ b/language/move-command-line-common/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0.52" diff --git a/language/move-compiler/Cargo.toml b/language/move-compiler/Cargo.toml index 0eb2706c1f..f8ca566a53 100644 --- a/language/move-compiler/Cargo.toml +++ b/language/move-compiler/Cargo.toml @@ -4,7 +4,7 @@ version = "0.0.1" authors = ["Diem Association "] description = "The definition of the Move source language, and its compiler" publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [dependencies] diff --git a/language/move-compiler/src/diagnostics/mod.rs b/language/move-compiler/src/diagnostics/mod.rs index 4f0bc598ed..9833bb162b 100644 --- a/language/move-compiler/src/diagnostics/mod.rs +++ b/language/move-compiler/src/diagnostics/mod.rs @@ -319,8 +319,8 @@ impl Diagnostic { macro_rules! diag { ($code: expr, $primary: expr $(,)?) => {{ #[allow(unused)] - use crate::diagnostics::codes::*; - crate::diagnostics::Diagnostic::new( + use $crate::diagnostics::codes::*; + $crate::diagnostics::Diagnostic::new( $code, $primary, std::iter::empty::<(move_ir_types::location::Loc, String)>(), @@ -329,8 +329,8 @@ macro_rules! diag { }}; ($code: expr, $primary: expr, $($secondary: expr),+ $(,)?) => {{ #[allow(unused)] - use crate::diagnostics::codes::*; - crate::diagnostics::Diagnostic::new( + use $crate::diagnostics::codes::*; + $crate::diagnostics::Diagnostic::new( $code, $primary, vec![$($secondary, )*], diff --git a/language/move-compiler/src/expansion/ast.rs b/language/move-compiler/src/expansion/ast.rs index f5a0b9f239..27363822e6 100644 --- a/language/move-compiler/src/expansion/ast.rs +++ b/language/move-compiler/src/expansion/ast.rs @@ -724,7 +724,7 @@ impl Iterator for AbilitySetIntoIter { } } -impl<'a> IntoIterator for AbilitySet { +impl IntoIterator for AbilitySet { type Item = Ability; type IntoIter = AbilitySetIntoIter; diff --git a/language/move-compiler/src/naming/translate.rs b/language/move-compiler/src/naming/translate.rs index 4d0669cb7f..2145f4f83e 100644 --- a/language/move-compiler/src/naming/translate.rs +++ b/language/move-compiler/src/naming/translate.rs @@ -505,7 +505,7 @@ fn function( acquires, body, }; - fake_natives::function(&mut context.env, module_opt, name, &f); + fake_natives::function(context.env, module_opt, name, &f); f } diff --git a/language/move-compiler/transactional-tests/Cargo.toml b/language/move-compiler/transactional-tests/Cargo.toml index deae23755f..241db23c7f 100644 --- a/language/move-compiler/transactional-tests/Cargo.toml +++ b/language/move-compiler/transactional-tests/Cargo.toml @@ -3,7 +3,7 @@ name = "move-compiler-transactional-tests" version = "0.1.0" authors = ["Diem Association "] publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [dev-dependencies] diff --git a/language/move-core/types/Cargo.toml b/language/move-core/types/Cargo.toml index 49815fb706..3fe0e8d2de 100644 --- a/language/move-core/types/Cargo.toml +++ b/language/move-core/types/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = ["crates-io"] -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0.52" diff --git a/language/move-ir-compiler/Cargo.toml b/language/move-ir-compiler/Cargo.toml index 79387bae2e..8b3513a8d8 100644 --- a/language/move-ir-compiler/Cargo.toml +++ b/language/move-ir-compiler/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0.52" diff --git a/language/move-ir-compiler/move-bytecode-source-map/Cargo.toml b/language/move-ir-compiler/move-bytecode-source-map/Cargo.toml index 7a20d53e1c..9f5bbaacfc 100644 --- a/language/move-ir-compiler/move-bytecode-source-map/Cargo.toml +++ b/language/move-ir-compiler/move-bytecode-source-map/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Diem Association "] license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0.52" diff --git a/language/move-ir-compiler/move-ir-to-bytecode/Cargo.toml b/language/move-ir-compiler/move-ir-to-bytecode/Cargo.toml index 755d11ef40..51b95fde27 100644 --- a/language/move-ir-compiler/move-ir-to-bytecode/Cargo.toml +++ b/language/move-ir-compiler/move-ir-to-bytecode/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0.52" diff --git a/language/move-ir-compiler/move-ir-to-bytecode/src/compiler.rs b/language/move-ir-compiler/move-ir-to-bytecode/src/compiler.rs index 9a2253fd1f..2725797b8a 100644 --- a/language/move-ir-compiler/move-ir-to-bytecode/src/compiler.rs +++ b/language/move-ir-compiler/move-ir-to-bytecode/src/compiler.rs @@ -26,6 +26,7 @@ use std::{ hash_map::Entry::{Occupied, Vacant}, BTreeSet, HashMap, HashSet, }, + fmt::Write, }; macro_rules! record_src_loc { @@ -194,24 +195,26 @@ fn label_verification_error( ) -> Result<()> { let mut message = "Invalid block labels".to_string(); if !redeclared.is_empty() { - message.push_str(&format!( + write!( + &mut message, ", labels were declared twice ({})", redeclared .iter() .map(|l| l.to_string()) .collect::>() - .join(", "), - )); + .join(", ") + )?; } if !undeclared.is_empty() { - message.push_str(&format!( + write!( + &mut message, ", labels were used without being declared ({})", undeclared .iter() .map(|l| l.to_string()) .collect::>() - .join(", "), - )); + .join(", ") + )?; } bail!(message); } diff --git a/language/move-ir-compiler/move-ir-to-bytecode/syntax/Cargo.toml b/language/move-ir-compiler/move-ir-to-bytecode/syntax/Cargo.toml index 0f5d7a4377..0180317793 100644 --- a/language/move-ir-compiler/move-ir-to-bytecode/syntax/Cargo.toml +++ b/language/move-ir-compiler/move-ir-to-bytecode/syntax/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0.52" diff --git a/language/move-ir-compiler/src/unit_tests/function_tests.rs b/language/move-ir-compiler/src/unit_tests/function_tests.rs index a701418292..cc9413f139 100644 --- a/language/move-ir-compiler/src/unit_tests/function_tests.rs +++ b/language/move-ir-compiler/src/unit_tests/function_tests.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use crate::unit_tests::testutils::compile_module_string; +use std::fmt::Write; fn generate_function(name: &str, num_formals: usize, num_locals: usize) -> String { let mut code = format!("public {}(", name); @@ -9,7 +10,7 @@ fn generate_function(name: &str, num_formals: usize, num_locals: usize) -> Strin code.reserve(30 * (num_formals + num_locals)); for i in 0..num_formals { - code.push_str(&format!("formal_{}: u64", i)); + write!(&mut code, "formal_{}: u64", i).unwrap(); if i < num_formals - 1 { code.push_str(", "); } @@ -18,11 +19,11 @@ fn generate_function(name: &str, num_formals: usize, num_locals: usize) -> Strin code.push_str(") {\n"); for i in 0..num_locals { - code.push_str(&format!("let x_{}: u64;\n", i)); + writeln!(&mut code, "let x_{}: u64;", i).unwrap(); } code.push_str("label b0:\n"); for i in 0..num_locals { - code.push_str(&format!("x_{} = {};\n", i, i)); + writeln!(&mut code, "x_{} = {};", i, i).unwrap(); } code.push_str("return;"); diff --git a/language/move-ir-compiler/transactional-tests/Cargo.toml b/language/move-ir-compiler/transactional-tests/Cargo.toml index 0fdf6a8d63..122e04c286 100644 --- a/language/move-ir-compiler/transactional-tests/Cargo.toml +++ b/language/move-ir-compiler/transactional-tests/Cargo.toml @@ -3,7 +3,7 @@ name = "move-ir-compiler-transactional-tests" version = "0.1.0" authors = ["Diem Association "] publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [dev-dependencies] diff --git a/language/move-ir/types/Cargo.toml b/language/move-ir/types/Cargo.toml index 67f9173e89..3839631e1c 100644 --- a/language/move-ir/types/Cargo.toml +++ b/language/move-ir/types/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/language/move-model/Cargo.toml b/language/move-model/Cargo.toml index 09aeb0d4dc..2a55c9d165 100644 --- a/language/move-model/Cargo.toml +++ b/language/move-model/Cargo.toml @@ -3,7 +3,7 @@ name = "move-model" version = "0.1.0" authors = ["Diem Association "] publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [dependencies] diff --git a/language/move-prover/Cargo.toml b/language/move-prover/Cargo.toml index d527848363..45f27ac1c7 100644 --- a/language/move-prover/Cargo.toml +++ b/language/move-prover/Cargo.toml @@ -3,7 +3,7 @@ name = "move-prover" version = "0.1.0" authors = ["Diem Association "] publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [dependencies] diff --git a/language/move-prover/boogie-backend/Cargo.toml b/language/move-prover/boogie-backend/Cargo.toml index 96b571961e..ebf44cc7f0 100644 --- a/language/move-prover/boogie-backend/Cargo.toml +++ b/language/move-prover/boogie-backend/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Diem Association "] description = "Move prover Boogie backend" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] async-trait = "0.1.42" diff --git a/language/move-prover/bytecode/Cargo.toml b/language/move-prover/bytecode/Cargo.toml index 1ee878e6ac..e802d8b236 100644 --- a/language/move-prover/bytecode/Cargo.toml +++ b/language/move-prover/bytecode/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] move-model = { path = "../../move-model" } diff --git a/language/move-prover/bytecode/src/lib.rs b/language/move-prover/bytecode/src/lib.rs index 20b9833695..af50941b60 100644 --- a/language/move-prover/bytecode/src/lib.rs +++ b/language/move-prover/bytecode/src/lib.rs @@ -5,6 +5,7 @@ use crate::function_target_pipeline::FunctionTargetsHolder; use move_model::model::GlobalEnv; +use std::fmt::Write; pub mod access_path; pub mod access_path_trie; @@ -53,13 +54,13 @@ pub fn print_targets_for_test( targets: &FunctionTargetsHolder, ) -> String { let mut text = String::new(); - text.push_str(&format!("============ {} ================\n", header)); + writeln!(&mut text, "============ {} ================", header).unwrap(); for module_env in env.get_modules() { for func_env in module_env.get_functions() { for (variant, target) in targets.get_targets(&func_env) { if !target.data.code.is_empty() || target.func_env.is_native_or_intrinsic() { target.register_annotation_formatters_for_test(); - text += &format!("\n[variant {}]\n{}\n", variant, target); + writeln!(&mut text, "\n[variant {}]\n{}", variant, target).unwrap(); } } } diff --git a/language/move-prover/bytecode/src/well_formed_instrumentation.rs b/language/move-prover/bytecode/src/well_formed_instrumentation.rs index 79ca1d5a04..9b10d56066 100644 --- a/language/move-prover/bytecode/src/well_formed_instrumentation.rs +++ b/language/move-prover/bytecode/src/well_formed_instrumentation.rs @@ -35,7 +35,7 @@ impl WellFormedInstrumentationProcessor { Box::new(Self {}) } } -#[allow(clippy::redundant-clone)] +#[allow(clippy::redundant_clone)] impl FunctionTargetProcessor for WellFormedInstrumentationProcessor { fn process( &self, diff --git a/language/move-prover/interpreter-testsuite/Cargo.toml b/language/move-prover/interpreter-testsuite/Cargo.toml index 31fec11941..83a268cdc2 100644 --- a/language/move-prover/interpreter-testsuite/Cargo.toml +++ b/language/move-prover/interpreter-testsuite/Cargo.toml @@ -3,7 +3,7 @@ name = "bytecode-interpreter-testsuite" version = "0.1.0" authors = ["Diem Association "] publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [dev-dependencies] diff --git a/language/move-prover/interpreter/Cargo.toml b/language/move-prover/interpreter/Cargo.toml index ce71900c71..40cd3a0019 100644 --- a/language/move-prover/interpreter/Cargo.toml +++ b/language/move-prover/interpreter/Cargo.toml @@ -3,7 +3,7 @@ name = "move-stackless-bytecode-interpreter" version = "0.1.0" authors = ["Diem Association "] publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [dependencies] diff --git a/language/move-prover/interpreter/crypto/Cargo.toml b/language/move-prover/interpreter/crypto/Cargo.toml index e703ce5d63..db309a5a83 100644 --- a/language/move-prover/interpreter/crypto/Cargo.toml +++ b/language/move-prover/interpreter/crypto/Cargo.toml @@ -3,7 +3,7 @@ name = "bytecode-interpreter-crypto" version = "0.1.0" authors = ["Diem Association "] publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [dependencies] diff --git a/language/move-prover/interpreter/src/lib.rs b/language/move-prover/interpreter/src/lib.rs index 7bbfd8d267..a289b25f06 100644 --- a/language/move-prover/interpreter/src/lib.rs +++ b/language/move-prover/interpreter/src/lib.rs @@ -4,6 +4,7 @@ use anyhow::{bail, Result}; use clap::Parser; use codespan_reporting::{diagnostic::Severity, term::termcolor::Buffer}; +use std::fmt::Write; use move_binary_format::errors::{Location, PartialVMError, PartialVMResult, VMResult}; use move_core_types::{ @@ -201,7 +202,7 @@ impl<'env> StacklessBytecodeInterpreter<'env> { for func_env in module_env.get_functions() { for (variant, target) in targets.get_targets(&func_env) { target.register_annotation_formatters_for_test(); - text += &format!("[variant {}]\n{}\n", variant, target); + writeln!(&mut text, "[variant {}]\n{}", variant, target).unwrap(); } } } @@ -338,7 +339,8 @@ fn verbose_stepwise_processing( for (_, target) in targets.get_targets(&func_env) { if !target.data.code.is_empty() { target.register_annotation_formatters_for_test(); - text += &format!("[{}-{}]\n{}\n", step, name, target); + + writeln!(&mut text, "[{}-{}]\n{}", step, name, target).unwrap(); } } } diff --git a/language/move-prover/lab/Cargo.toml b/language/move-prover/lab/Cargo.toml index e6ad76c0af..1457db23a7 100644 --- a/language/move-prover/lab/Cargo.toml +++ b/language/move-prover/lab/Cargo.toml @@ -3,7 +3,7 @@ name = "prover-lab" version = "0.1.0" authors = ["Diem Association "] publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [dependencies] diff --git a/language/move-prover/lab/src/plot.rs b/language/move-prover/lab/src/plot.rs index 4296908e89..f310531b13 100644 --- a/language/move-prover/lab/src/plot.rs +++ b/language/move-prover/lab/src/plot.rs @@ -154,8 +154,7 @@ pub fn plot_benchmarks_to_file(fname: &str, benchmarks: &[Benchmark]) -> anyhow: let data_points = joined.len() as u32; let max_duration = joined .iter() - .map(|(_, e)| e.iter().map(|(_, d)| *d)) - .flatten() + .flat_map(|(_, e)| e.iter().map(|(_, d)| *d)) .filter_map(|r| { if let Result::Duration(d) | Result::Error(d) = r { Some(d) diff --git a/language/move-prover/move-abigen/Cargo.toml b/language/move-prover/move-abigen/Cargo.toml index 5a28aaf10b..7d4f5c68b0 100644 --- a/language/move-prover/move-abigen/Cargo.toml +++ b/language/move-prover/move-abigen/Cargo.toml @@ -3,7 +3,7 @@ name = "move-abigen" version = "0.1.0" authors = ["Diem Association "] publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [dependencies] diff --git a/language/move-prover/move-docgen/Cargo.toml b/language/move-prover/move-docgen/Cargo.toml index 91a71f4ca2..e6968e4d78 100644 --- a/language/move-prover/move-docgen/Cargo.toml +++ b/language/move-prover/move-docgen/Cargo.toml @@ -3,7 +3,7 @@ name = "move-docgen" version = "0.1.0" authors = ["Diem Association "] publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [dependencies] diff --git a/language/move-prover/move-docgen/src/docgen.rs b/language/move-prover/move-docgen/src/docgen.rs index c9bd495e14..7d1f1c6421 100644 --- a/language/move-prover/move-docgen/src/docgen.rs +++ b/language/move-prover/move-docgen/src/docgen.rs @@ -25,6 +25,7 @@ use serde::{Deserialize, Serialize}; use std::{ cell::RefCell, collections::{BTreeMap, BTreeSet, VecDeque}, + fmt::Write as FmtWrite, fs::{self, File}, io::{Read, Write}, path::{Path, PathBuf}, @@ -1466,7 +1467,13 @@ impl<'env> Docgen<'env> { "Missing backtick found in {} while generating documentation for the following text: \"{}\"", self.current_module.as_ref().unwrap().get_name().display_full(self.env.symbol_pool()), text, ); - decorated_text += &format!("{}", self.decorate_code(&code)); + + write!( + &mut decorated_text, + "{}", + self.decorate_code(&code) + ) + .unwrap() } } else { decorated_text.push(chr); diff --git a/language/move-prover/move-errmapgen/Cargo.toml b/language/move-prover/move-errmapgen/Cargo.toml index 05754cf803..6ec7e33e79 100644 --- a/language/move-prover/move-errmapgen/Cargo.toml +++ b/language/move-prover/move-errmapgen/Cargo.toml @@ -3,7 +3,7 @@ name = "move-errmapgen" version = "0.1.0" authors = ["Diem Association "] publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [dependencies] diff --git a/language/move-prover/mutation/Cargo.toml b/language/move-prover/mutation/Cargo.toml index 77d4c4e5f1..9119f17d88 100644 --- a/language/move-prover/mutation/Cargo.toml +++ b/language/move-prover/mutation/Cargo.toml @@ -3,7 +3,7 @@ name = "prover-mutation" version = "0.1.0" authors = ["Diem Association "] publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [dependencies] diff --git a/language/move-prover/test-utils/Cargo.toml b/language/move-prover/test-utils/Cargo.toml index fc5ff22f1f..54796e4f9c 100644 --- a/language/move-prover/test-utils/Cargo.toml +++ b/language/move-prover/test-utils/Cargo.toml @@ -2,7 +2,7 @@ name = "move-prover-test-utils" version = "0.1.0" authors = ["Diem Association "] -edition = "2018" +edition = "2021" publish = false license = "Apache-2.0" diff --git a/language/move-prover/tools/spec-flatten/Cargo.toml b/language/move-prover/tools/spec-flatten/Cargo.toml index a24c5b9c96..2f974e4e67 100644 --- a/language/move-prover/tools/spec-flatten/Cargo.toml +++ b/language/move-prover/tools/spec-flatten/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Diem Association "] description = "Formal specification flattening tool" publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [dependencies] diff --git a/language/move-symbol-pool/Cargo.toml b/language/move-symbol-pool/Cargo.toml index 6cc5b14748..db132c8990 100644 --- a/language/move-symbol-pool/Cargo.toml +++ b/language/move-symbol-pool/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] once_cell = "1.7.2" diff --git a/language/move-vm/integration-tests/Cargo.toml b/language/move-vm/integration-tests/Cargo.toml index 67b82cf73e..47cf1da438 100644 --- a/language/move-vm/integration-tests/Cargo.toml +++ b/language/move-vm/integration-tests/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/language/move-vm/runtime/Cargo.toml b/language/move-vm/runtime/Cargo.toml index df81c5a70e..2517f3e66c 100644 --- a/language/move-vm/runtime/Cargo.toml +++ b/language/move-vm/runtime/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/language/move-vm/runtime/src/tracing.rs b/language/move-vm/runtime/src/tracing.rs index 86d2c4b114..4b14c419a6 100644 --- a/language/move-vm/runtime/src/tracing.rs +++ b/language/move-vm/runtime/src/tracing.rs @@ -94,7 +94,7 @@ macro_rules! trace { ($function_desc:expr, $locals:expr, $pc:expr, $instr:tt, $resolver:expr, $interp:expr) => { // Only include this code in debug releases #[cfg(any(debug_assertions, feature = "debugging"))] - crate::tracing::trace( + $crate::tracing::trace( &$function_desc, $locals, $pc, diff --git a/language/move-vm/test-utils/Cargo.toml b/language/move-vm/test-utils/Cargo.toml index 4d391dadc6..1d3b6919ce 100644 --- a/language/move-vm/test-utils/Cargo.toml +++ b/language/move-vm/test-utils/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/language/move-vm/transactional-tests/Cargo.toml b/language/move-vm/transactional-tests/Cargo.toml index 03777ae5d3..d29d297039 100644 --- a/language/move-vm/transactional-tests/Cargo.toml +++ b/language/move-vm/transactional-tests/Cargo.toml @@ -3,7 +3,7 @@ name = "move-vm-transactional-tests" version = "0.1.0" authors = ["Diem Association "] publish = false -edition = "2018" +edition = "2021" license = "Apache-2.0" [dev-dependencies] diff --git a/language/move-vm/types/Cargo.toml b/language/move-vm/types/Cargo.toml index 1ac48f4893..3c7309abf2 100644 --- a/language/move-vm/types/Cargo.toml +++ b/language/move-vm/types/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] once_cell = "1.7.2" diff --git a/language/testing-infra/module-generation/Cargo.toml b/language/testing-infra/module-generation/Cargo.toml index 3b4e4611c8..c3b1cb5459 100644 --- a/language/testing-infra/module-generation/Cargo.toml +++ b/language/testing-infra/module-generation/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] rand = "0.8.3" diff --git a/language/testing-infra/test-generation/Cargo.toml b/language/testing-infra/test-generation/Cargo.toml index 83ac8f35ff..ef532da8f4 100644 --- a/language/testing-infra/test-generation/Cargo.toml +++ b/language/testing-infra/test-generation/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] rand = "0.8.3" diff --git a/language/testing-infra/test-generation/src/transitions.rs b/language/testing-infra/test-generation/src/transitions.rs index cb2d4b6c0c..032a77de2d 100644 --- a/language/testing-infra/test-generation/src/transitions.rs +++ b/language/testing-infra/test-generation/src/transitions.rs @@ -1349,16 +1349,16 @@ macro_rules! state_never { #[macro_export] macro_rules! state_stack_bin_op { (#left) => { - Box::new(move |state| stack_bin_op(state, crate::transitions::StackBinOpResult::Left)) + Box::new(move |state| stack_bin_op(state, $crate::transitions::StackBinOpResult::Left)) }; (#right) => { - Box::new(move |state| stack_bin_op(state, crate::transitions::StackBinOpResult::Right)) + Box::new(move |state| stack_bin_op(state, $crate::transitions::StackBinOpResult::Right)) }; () => { state_stack_bin_op!(#left) }; ($e: expr) => { - Box::new(move |state| stack_bin_op(state, crate::transitions::StackBinOpResult::Other($e))) + Box::new(move |state| stack_bin_op(state, $crate::transitions::StackBinOpResult::Other($e))) } } diff --git a/language/testing-infra/transactional-test-runner/Cargo.toml b/language/testing-infra/transactional-test-runner/Cargo.toml index 798ecae63d..cb99bbcf4d 100644 --- a/language/testing-infra/transactional-test-runner/Cargo.toml +++ b/language/testing-infra/transactional-test-runner/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0.52" diff --git a/language/testing-infra/transactional-test-runner/src/framework.rs b/language/testing-infra/transactional-test-runner/src/framework.rs index 8a10535e1d..89417a0c87 100644 --- a/language/testing-infra/transactional-test-runner/src/framework.rs +++ b/language/testing-infra/transactional-test-runner/src/framework.rs @@ -40,7 +40,7 @@ use move_vm_runtime::session::SerializedReturnValues; use rayon::iter::Either; use std::{ collections::{BTreeMap, BTreeSet, VecDeque}, - fmt::Debug, + fmt::{Debug, Write as FmtWrite}, io::Write, path::Path, }; @@ -666,11 +666,13 @@ where .collect::>(); assert!(!tasks.is_empty()); let num_tasks = tasks.len(); - output.push_str(&format!( - "processed {} task{}\n", + writeln!( + &mut output, + "processed {} task{}", num_tasks, if num_tasks > 1 { "s" } else { "" } - )); + ) + .unwrap(); let first_task = tasks.pop_front().unwrap(); let init_opt = match &first_task.command { @@ -686,7 +688,7 @@ where let (mut adapter, result_opt) = Adapter::init(default_syntax, fully_compiled_program_opt, init_opt); if let Some(result) = result_opt { - output.push_str(&format!("\ninit:\n{}\n", result)) + writeln!(output, "\ninit:\n{}", result)?; } for task in tasks { handle_known_task(&mut output, &mut adapter, task); @@ -719,10 +721,13 @@ fn handle_known_task<'a, Adapter: MoveTestAdapter<'a>>( Err(e) => format!("Error: {}", e), }; assert!(!result_string.is_empty()); - output.push_str(&format!( - "\ntask {} '{}'. lines {}-{}:\n{}\n", + + writeln!( + output, + "\ntask {} '{}'. lines {}-{}:\n{}", task_number, task_name, start_line, stop_line, result_string - )); + ) + .unwrap(); } fn handle_expected_output(test_path: &Path, output: impl AsRef) -> Result<()> { diff --git a/language/tools/move-bytecode-utils/Cargo.toml b/language/tools/move-bytecode-utils/Cargo.toml index f42c6d15ec..fbf52faf22 100644 --- a/language/tools/move-bytecode-utils/Cargo.toml +++ b/language/tools/move-bytecode-utils/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0.52" diff --git a/language/tools/move-bytecode-viewer/Cargo.toml b/language/tools/move-bytecode-viewer/Cargo.toml index 82e2ab8d68..f639807070 100644 --- a/language/tools/move-bytecode-viewer/Cargo.toml +++ b/language/tools/move-bytecode-viewer/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Diem Association "] description = "Explore Move bytecode and how the source code compiles to it" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] clap = { version = "3.1.8", features = ["derive"] } diff --git a/language/tools/move-bytecode-viewer/src/bytecode_viewer.rs b/language/tools/move-bytecode-viewer/src/bytecode_viewer.rs index 82cdaad037..d5004d6fc8 100644 --- a/language/tools/move-bytecode-viewer/src/bytecode_viewer.rs +++ b/language/tools/move-bytecode-viewer/src/bytecode_viewer.rs @@ -106,6 +106,6 @@ impl LeftScreen for BytecodeViewer<'_> { } fn backing_string(&self) -> String { - self.lines.join("\n").replace("\t", " ") + self.lines.join("\n").replace('\t', " ") } } diff --git a/language/tools/move-cli/Cargo.toml b/language/tools/move-cli/Cargo.toml index 6149121d6a..8ec8ee0cff 100644 --- a/language/tools/move-cli/Cargo.toml +++ b/language/tools/move-cli/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0.52" diff --git a/language/tools/move-cli/src/sandbox/commands/test.rs b/language/tools/move-cli/src/sandbox/commands/test.rs index a13180444a..6041aae498 100644 --- a/language/tools/move-cli/src/sandbox/commands/test.rs +++ b/language/tools/move-cli/src/sandbox/commands/test.rs @@ -19,6 +19,7 @@ use move_package::{ use std::{ collections::{BTreeMap, HashMap}, env, + fmt::Write as FmtWrite, fs::{self, File}, io::{self, BufRead, Write}, path::{Path, PathBuf}, @@ -222,7 +223,7 @@ pub fn run_one( for args_line in args_file { let args_line = args_line?; - if let Some(external_cmd) = args_line.strip_prefix(">") { + if let Some(external_cmd) = args_line.strip_prefix('>') { let external_cmd = external_cmd.trim_start(); let mut cmd_iter = external_cmd.split_ascii_whitespace(); @@ -237,7 +238,7 @@ pub fn run_one( } let cmd_output = command.output()?; - output += &format!("External Command `{}`:\n", external_cmd); + writeln!(&mut output, "External Command `{}`:", external_cmd)?; output += std::str::from_utf8(&cmd_output.stdout)?; output += std::str::from_utf8(&cmd_output.stderr)?; @@ -268,7 +269,7 @@ pub fn run_one( } let cmd_output = cli_command_template().args(args_iter).output()?; - output += &format!("Command `{}`:\n", args_line); + writeln!(&mut output, "Command `{}`:", args_line)?; output += std::str::from_utf8(&cmd_output.stdout)?; output += std::str::from_utf8(&cmd_output.stderr)?; } diff --git a/language/tools/move-cli/src/sandbox/utils/on_disk_state_view.rs b/language/tools/move-cli/src/sandbox/utils/on_disk_state_view.rs index 8f6ea302ea..32380aa654 100644 --- a/language/tools/move-cli/src/sandbox/utils/on_disk_state_view.rs +++ b/language/tools/move-cli/src/sandbox/utils/on_disk_state_view.rs @@ -137,7 +137,7 @@ impl OnDiskStateView { return None; } let name = Identifier::new(p.file_stem().unwrap().to_str().unwrap()).unwrap(); - match p.parent().map(|parent| parent.parent()).flatten() { + match p.parent().and_then(|parent| parent.parent()) { Some(parent) => { let addr = AccountAddress::from_hex_literal(parent.file_stem().unwrap().to_str().unwrap()) diff --git a/language/tools/move-coverage/Cargo.toml b/language/tools/move-coverage/Cargo.toml index 89fcaaec5a..5aca8e138e 100644 --- a/language/tools/move-coverage/Cargo.toml +++ b/language/tools/move-coverage/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] once_cell = "1.7.2" diff --git a/language/tools/move-disassembler/Cargo.toml b/language/tools/move-disassembler/Cargo.toml index ec4587992a..3553844ebd 100644 --- a/language/tools/move-disassembler/Cargo.toml +++ b/language/tools/move-disassembler/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Diem Association "] description = "Print a human-readable version of Move bytecode (.mv files)" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0.52" diff --git a/language/tools/move-explain/Cargo.toml b/language/tools/move-explain/Cargo.toml index 8f9742396a..824cefdfac 100644 --- a/language/tools/move-explain/Cargo.toml +++ b/language/tools/move-explain/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] clap = { version = "3.1.8", features = ["derive"] } diff --git a/language/tools/move-package/Cargo.toml b/language/tools/move-package/Cargo.toml index 3fbd69206d..4cb647e676 100644 --- a/language/tools/move-package/Cargo.toml +++ b/language/tools/move-package/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Diem Association "] description = "Package and build system for Move code" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] toml = "0.5.8" diff --git a/language/tools/move-resource-viewer/Cargo.toml b/language/tools/move-resource-viewer/Cargo.toml index c4dcb2bb15..427b7c684a 100644 --- a/language/tools/move-resource-viewer/Cargo.toml +++ b/language/tools/move-resource-viewer/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] bcs = "0.1.2" diff --git a/language/tools/move-unit-test/Cargo.toml b/language/tools/move-unit-test/Cargo.toml index 8b4a964dc1..6c190f146b 100644 --- a/language/tools/move-unit-test/Cargo.toml +++ b/language/tools/move-unit-test/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0.52" diff --git a/language/tools/move-unit-test/src/test_reporter.rs b/language/tools/move-unit-test/src/test_reporter.rs index 08f18aa60c..fef7e17386 100644 --- a/language/tools/move-unit-test/src/test_reporter.rs +++ b/language/tools/move-unit-test/src/test_reporter.rs @@ -527,7 +527,7 @@ impl TestResults { "│ {}", test_failure .render_error(&self.test_plan) - .replace("\n", "\n│ ") + .replace('\n', "\n│ ") )?; writeln!(writer.lock().unwrap(), "└──────────────────\n")?; } diff --git a/language/tools/move-unit-test/src/test_runner.rs b/language/tools/move-unit-test/src/test_runner.rs index e0845f821f..00183dbca0 100644 --- a/language/tools/move-unit-test/src/test_runner.rs +++ b/language/tools/move-unit-test/src/test_runner.rs @@ -122,7 +122,7 @@ fn print_resources_and_extensions( writeln!( &mut buf, "\t{}", - format!("=> {}", annotator.view_resource(tag, resource)?).replace("\n", "\n\t") + format!("=> {}", annotator.view_resource(tag, resource)?).replace('\n', "\n\t") )?; } } diff --git a/language/tools/read-write-set/Cargo.toml b/language/tools/read-write-set/Cargo.toml index fda28ac073..790f684e0a 100644 --- a/language/tools/read-write-set/Cargo.toml +++ b/language/tools/read-write-set/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0.52" diff --git a/language/tools/read-write-set/dynamic/Cargo.toml b/language/tools/read-write-set/dynamic/Cargo.toml index 1ff84db9dd..206ca47818 100644 --- a/language/tools/read-write-set/dynamic/Cargo.toml +++ b/language/tools/read-write-set/dynamic/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0.52" diff --git a/language/tools/read-write-set/types/Cargo.toml b/language/tools/read-write-set/types/Cargo.toml index 4ed24a5322..fd2e99385d 100644 --- a/language/tools/read-write-set/types/Cargo.toml +++ b/language/tools/read-write-set/types/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = ["crates-io"] -edition = "2018" +edition = "2021" [dependencies] anyhow = "1.0.52" diff --git a/rust-toolchain b/rust-toolchain index bb120e876c..9405730420 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.59.0 +1.64.0 diff --git a/rustfmt.toml b/rustfmt.toml index 80eeb4054d..55797efb6b 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,2 +1,2 @@ -edition = "2018" +edition = "2021" use_field_init_shorthand = true diff --git a/x.toml b/x.toml index bd5c906f28..71eca39c87 100644 --- a/x.toml +++ b/x.toml @@ -61,6 +61,14 @@ allowed = [ "unused_must_use", "clippy::drop_copy", "clippy::ptr-arg", + "clippy::derive-partial-eq-without-eq", + "clippy::borrow-deref-ref", + "clippy::needless-return", + "clippy::let-and-return", + "clippy::manual-find", + "unused-parens", + "clippy::get-first", + "clippy::match-like-matches-macro", ] warn = [ "clippy::wildcard_dependencies",