Skip to content

Commit 4d20118

Browse files
satyamacnbors-diem
authored andcommitted
upgrade rust toolchain 1.62.1 && edition 2021 && cargo clippy --fix
Closes: #476
1 parent 52399be commit 4d20118

File tree

91 files changed

+159
-136
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+159
-136
lines changed

devtools/x-core/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "x-core"
33
version = "0.1.0"
44
authors = ["Diem Association <opensource@diem.com>"]
55
description = "Core data structures used by x"
6-
edition = "2018"
6+
edition = "2021"
77
publish = false
88
license = "Apache-2.0"
99

devtools/x-lint/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "x-lint"
33
version = "0.1.0"
44
authors = ["Diem Association <opensource@diem.com>"]
55
description = "Lint engine for x"
6-
edition = "2018"
6+
edition = "2021"
77
publish = false
88
license = "Apache-2.0"
99

devtools/x/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "x"
33
version = "0.1.0"
44
authors = ["Diem Association <opensource@diem.com>"]
55
description = "Diem extended cargo tasks"
6-
edition = "2018"
6+
edition = "2021"
77
publish = false
88
license = "Apache-2.0"
99

devtools/x/src/lint/guppy.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use guppy::{
1313
};
1414
use std::{
1515
collections::{BTreeMap, HashMap},
16+
fmt::Write as FmtWrite,
1617
iter,
1718
};
1819
use x_core::{WorkspaceStatus, XCoreContext};
@@ -269,9 +270,7 @@ impl<'cfg> ProjectLinter for DirectDepDups<'cfg> {
269270
if versions.len() > 1 {
270271
let mut msg = format!("duplicate direct dependency '{}':\n", direct_dep);
271272
for (version, packages) in versions {
272-
msg.push_str(&format!(" * {} (", version));
273-
msg.push_str(&packages.join(", "));
274-
msg.push_str(")\n");
273+
writeln!(&mut msg, " * {} ({})", version, &packages.join(", ")).unwrap();
275274
}
276275
out.write(LintLevel::Error, msg);
277276
}
@@ -360,12 +359,14 @@ impl<'cfg> PackageLinter for OverlayFeatures<'cfg> {
360359
if !overlays.is_empty() {
361360
let mut msg = "overlay features enabled by default:\n".to_string();
362361
for (from_feature, to_package, to_feature) in overlays {
363-
msg.push_str(&format!(
364-
" * {} -> {}/{}\n",
362+
writeln!(
363+
&mut msg,
364+
" * {} -> {}/{}",
365365
feature_str(from_feature),
366366
to_package,
367367
feature_str(to_feature)
368-
));
368+
)
369+
.unwrap();
369370
}
370371
msg.push_str("Use a line in the [features] section instead.\n");
371372
out.write(LintLevel::Error, msg);

language/benchmarks/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem"
77
homepage = "https://diem.com"
88
license = "Apache-2.0"
99
publish = false
10-
edition = "2018"
10+
edition = "2021"
1111

1212
[dependencies]
1313
anyhow = "1.0.52"

language/documentation/examples/diem-framework/crates/cli/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description = "CLI frontend for the Move compiler and VM (with Diem Framework)"
55
authors = ["Diem Association <opensource@diem.com>"]
66
license = "Apache-2.0"
77
publish = false
8-
edition = "2018"
8+
edition = "2021"
99

1010
[dependencies]
1111
anyhow = "1.0.52"

language/documentation/examples/diem-framework/crates/crypto-derive/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "diem-crypto-derive"
33
version = "0.0.3"
44
authors = ["Diem Association <opensource@diem.com>"]
55
publish = false
6-
edition = "2018"
6+
edition = "2021"
77
license = "Apache-2.0"
88

99
[lib]

language/documentation/examples/diem-framework/crates/crypto/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "diem-crypto"
33
version = "0.0.3"
44
authors = ["Diem Association <opensource@diem.com>"]
55
publish = false
6-
edition = "2018"
6+
edition = "2021"
77
license = "Apache-2.0"
88

99
[dependencies]

language/documentation/examples/diem-framework/crates/natives/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "diem-framework-natives"
33
version = "0.0.0"
44
authors = ["Diem Association <opensource@diem.com>"]
55
publish = false
6-
edition = "2018"
6+
edition = "2021"
77
license = "Apache-2.0"
88

99
[dependencies]

language/evm/extract-ethereum-abi/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
authors = ["Diem Association <opensource@diem.com>"]
55
description = "Extract Etherem ABI"
66
publish = false
7-
edition = "2018"
7+
edition = "2021"
88
license = "Apache-2.0"
99

1010
[dependencies]

language/evm/move-ethereum-abi/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
authors = ["Diem Association <opensource@diem.com>"]
55
description = "Move Ethereum ABI"
66
publish = false
7-
edition = "2018"
7+
edition = "2021"
88
license = "Apache-2.0"
99

1010
[dependencies]

language/evm/move-to-yul/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
authors = ["Diem Association <opensource@diem.com>"]
55
description = "Move Solidity Generator"
66
publish = false
7-
edition = "2018"
7+
edition = "2021"
88
license = "Apache-2.0"
99

1010
[dependencies]

language/evm/move-to-yul/src/abi_move_metadata.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ pub(crate) fn generate_abi_move_metadata(ctx: &Context, receive: bool, fallback:
2525
let st_env = ctx.env.get_struct(key.to_qualified_id());
2626
event_map.insert(
2727
st_env.get_identifier().unwrap().to_string(),
28-
from_event_sig(ctx.event_signature_map.borrow().get(&key).unwrap()),
28+
from_event_sig(ctx.event_signature_map.borrow().get(key).unwrap()),
2929
);
3030
}
3131

3232
// Callable functions
3333
let mut func_map = BTreeMap::new();
3434
for (key, (solidity_sig, attr)) in ctx.callable_function_map.borrow().iter() {
3535
let fun = ctx.env.get_function(key.to_qualified_id());
36-
let abi_sig = from_solidity_sig(&solidity_sig, Some(*attr), "function");
36+
let abi_sig = from_solidity_sig(solidity_sig, Some(*attr), "function");
3737
func_map.insert(fun.get_identifier().to_string(), abi_sig);
3838
}
3939

language/evm/move-to-yul/src/context.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,7 @@ impl<'a> Context<'a> {
353353
fn get_target_structs(&self, p: impl Fn(&StructEnv) -> bool) -> Vec<StructEnv<'a>> {
354354
self.env
355355
.get_modules()
356-
.map(|m| m.into_structs().filter(|f| p(f)))
357-
.flatten()
356+
.flat_map(|m| m.into_structs().filter(|f| p(f)))
358357
.collect()
359358
}
360359

@@ -607,7 +606,7 @@ impl<'a> Context<'a> {
607606
.get_local_name(idx)
608607
.display(target.symbol_pool())
609608
.to_string()
610-
.replace("#", "_")
609+
.replace('#', "_")
611610
}
612611

613612
/// Make name for a result.

language/evm/move-to-yul/src/dispatcher_generator.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ impl Generator {
260260
/// Generate optional receive function.
261261
fn optional_receive(&mut self, ctx: &Context, receive: &Option<FunctionEnv<'_>>) -> bool {
262262
if let Some(receive) = receive {
263-
ctx.check_no_generics(&receive);
264-
if !attributes::is_payable_fun(&receive) {
263+
ctx.check_no_generics(receive);
264+
if !attributes::is_payable_fun(receive) {
265265
ctx.env
266266
.error(&receive.get_loc(), "receive function must be payable")
267267
}
@@ -308,8 +308,8 @@ impl Generator {
308308
fallback: &Option<FunctionEnv<'_>>,
309309
) {
310310
if let Some(fallback) = fallback {
311-
ctx.check_no_generics(&fallback);
312-
if !attributes::is_payable_fun(&fallback) {
311+
ctx.check_no_generics(fallback);
312+
if !attributes::is_payable_fun(fallback) {
313313
self.generate_call_value_check(ctx, REVERT_ERR_NON_PAYABLE_FUN);
314314
}
315315
let fun_id = &fallback
@@ -559,7 +559,7 @@ impl Generator {
559559
);
560560
});
561561
head_pos += ty_size;
562-
let memory_func = ctx.memory_store_builtin_fun(&move_ty);
562+
let memory_func = ctx.memory_store_builtin_fun(move_ty);
563563
if local_typ_var.len() == 1 {
564564
gen.call_builtin(
565565
ctx,
@@ -1453,7 +1453,7 @@ impl Generator {
14531453
{
14541454
let is_static = ty.is_static();
14551455
let local_typ_var = vec![ret_var[stack_pos].clone()];
1456-
let memory_func = ctx.memory_load_builtin_fun(&move_ty);
1456+
let memory_func = ctx.memory_load_builtin_fun(move_ty);
14571457
if local_typ_var.len() == 1 {
14581458
emitln!(
14591459
ctx.writer,
@@ -1473,7 +1473,7 @@ impl Generator {
14731473
ctx,
14741474
&ty.clone(),
14751475
&SignatureDataLocation::Memory,
1476-
&move_ty,
1476+
move_ty,
14771477
sub_option.clone()
14781478
),
14791479
local_typ_var[0].clone()
@@ -1487,7 +1487,7 @@ impl Generator {
14871487
ctx,
14881488
&ty.clone(),
14891489
&SignatureDataLocation::Memory,
1490-
&move_ty,
1490+
move_ty,
14911491
sub_option.clone()
14921492
),
14931493
local_typ_var[0].clone(),
@@ -1506,7 +1506,7 @@ impl Generator {
15061506
ctx,
15071507
&ty.clone(),
15081508
&SignatureDataLocation::Memory,
1509-
&move_ty,
1509+
move_ty,
15101510
sub_option.clone()
15111511
),
15121512
local_typ_var[0].clone()

language/evm/move-to-yul/src/solidity_ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ impl SolidityType {
397397
let error_msg = "illegal type name";
398398
return Err(anyhow!(error_msg));
399399
}
400-
ctx.check_or_create_struct_abi(&trimmed_ty_str)
400+
ctx.check_or_create_struct_abi(trimmed_ty_str)
401401
}
402402
}
403403

language/evm/move-to-yul/src/vectors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ fn define_destroy_empty_fun(
10501050

10511051
/// Generate equality method for the vector type.
10521052
pub(crate) fn equality_fun(gen: &mut Generator, ctx: &Context, ty: &Type) {
1053-
let elem_type = get_elem_type(&ty).unwrap();
1053+
let elem_type = get_elem_type(ty).unwrap();
10541054
if ctx.type_allocates_memory(&elem_type) {
10551055
emitln!(
10561056
ctx.writer,

language/evm/move-to-yul/tests/testsuite.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use move_to_yul::{generator::Generator, options::Options};
1818
use primitive_types::{H160, U256};
1919
use std::{
2020
collections::BTreeMap,
21+
fmt::Write,
2122
path::{Path, PathBuf},
2223
};
2324

@@ -115,16 +116,19 @@ fn run_tests(
115116
let mut res = String::new();
116117
res.push_str("!! Unit tests\n\n");
117118
for (fun, source) in test_cases {
118-
res.push_str(&format!(
119-
"// test of {}\n",
119+
writeln!(
120+
&mut res,
121+
"// test of {}",
120122
env.get_function(*fun).get_full_name_str()
121-
));
123+
)
124+
.unwrap();
122125
res.push_str(source);
123-
res.push_str(&format!(
124-
"===> Test result of {}: {}\n\n",
126+
writeln!(
127+
&mut res,
128+
"===> Test result of {}: {}\n",
125129
env.get_function(*fun).get_full_name_str(),
126130
execute_test(env, source)?
127-
));
131+
)?;
128132
}
129133
Ok(res)
130134
}

language/move-analyzer/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem"
77
homepage = "https://diem.com"
88
license = "Apache-2.0"
99
publish = false
10-
edition = "2018"
10+
edition = "2021"
1111

1212
[dependencies]
1313
anyhow = "1.0.52"

language/move-binary-format/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem"
77
homepage = "https://diem.com"
88
license = "Apache-2.0"
99
publish = ["crates-io"]
10-
edition = "2018"
10+
edition = "2021"
1111

1212
[dependencies]
1313
anyhow = "1.0.52"

language/move-binary-format/serializer-tests/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem"
77
homepage = "https://diem.com"
88
license = "Apache-2.0"
99
publish = false
10-
edition = "2018"
10+
edition = "2021"
1111

1212
[dev-dependencies]
1313
proptest = "1.0.0"

language/move-borrow-graph/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ name = "move-borrow-graph"
33
version = "0.0.1"
44
authors = ["Diem Association <opensource@diem.com>"]
55
publish = false
6-
edition = "2018"
6+
edition = "2021"
77
license = "Apache-2.0"

language/move-borrow-graph/src/references.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl<Loc: Copy, Lbl: Clone + Ord + Debug> Debug for BorrowEdge<Loc, Lbl> {
228228
// Iteration
229229
//**********************************************************************************************
230230

231-
impl<'a, Loc: Copy, Lbl: Clone + Ord> IntoIterator for BorrowEdgeSet<Loc, Lbl> {
231+
impl<Loc: Copy, Lbl: Clone + Ord> IntoIterator for BorrowEdgeSet<Loc, Lbl> {
232232
type Item = BorrowEdge<Loc, Lbl>;
233233
type IntoIter = std::collections::btree_set::IntoIter<BorrowEdge<Loc, Lbl>>;
234234

language/move-bytecode-verifier/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem"
77
homepage = "https://diem.com"
88
license = "Apache-2.0"
99
publish = false
10-
edition = "2018"
10+
edition = "2021"
1111

1212
[dependencies]
1313
anyhow = "1.0.52"

language/move-bytecode-verifier/bytecode-verifier-tests/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem"
77
homepage = "https://diem.com"
88
license = "Apache-2.0"
99
publish = false
10-
edition = "2018"
10+
edition = "2021"
1111

1212
[dev-dependencies]
1313
petgraph = "0.5.1"

language/move-bytecode-verifier/invalid-mutations/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "invalid-mutations"
33
version = "0.1.0"
4-
edition = "2018"
4+
edition = "2021"
55
authors = ["Diem Association <opensource@diem.com>"]
66
description = "Diem invalid mutations"
77
repository = "https://github.com/diem/diem"

language/move-bytecode-verifier/transactional-tests/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "bytecode-verifier-transactional-tests"
33
version = "0.1.0"
44
authors = ["Diem Association <opensource@diem.com>"]
55
publish = false
6-
edition = "2018"
6+
edition = "2021"
77
license = "Apache-2.0"
88

99
[dev-dependencies]

language/move-command-line-common/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ repository = "https://github.com/diem/diem"
77
homepage = "https://diem.com"
88
license = "Apache-2.0"
99
publish = false
10-
edition = "2018"
10+
edition = "2021"
1111

1212
[dependencies]
1313
anyhow = "1.0.52"

language/move-compiler/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.0.1"
44
authors = ["Diem Association <opensource@diem.com>"]
55
description = "The definition of the Move source language, and its compiler"
66
publish = false
7-
edition = "2018"
7+
edition = "2021"
88
license = "Apache-2.0"
99

1010
[dependencies]

0 commit comments

Comments
 (0)