Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade rust toolchain 1.62.1 && edition 2021 && cargo clippy --fix #275_169 #476

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion devtools/x-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "x-core"
version = "0.1.0"
authors = ["Diem Association <opensource@diem.com>"]
description = "Core data structures used by x"
edition = "2018"
edition = "2021"
publish = false
license = "Apache-2.0"

Expand Down
2 changes: 1 addition & 1 deletion devtools/x-lint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "x-lint"
version = "0.1.0"
authors = ["Diem Association <opensource@diem.com>"]
description = "Lint engine for x"
edition = "2018"
edition = "2021"
publish = false
license = "Apache-2.0"

Expand Down
2 changes: 1 addition & 1 deletion devtools/x/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "x"
version = "0.1.0"
authors = ["Diem Association <opensource@diem.com>"]
description = "Diem extended cargo tasks"
edition = "2018"
edition = "2021"
publish = false
license = "Apache-2.0"

Expand Down
13 changes: 7 additions & 6 deletions devtools/x/src/lint/guppy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use guppy::{
};
use std::{
collections::{BTreeMap, HashMap},
fmt::Write as FmtWrite,
iter,
};
use x_core::{WorkspaceStatus, XCoreContext};
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion language/benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "CLI frontend for the Move compiler and VM (with Diem Framework)"
authors = ["Diem Association <opensource@diem.com>"]
license = "Apache-2.0"
publish = false
edition = "2018"
edition = "2021"

[dependencies]
anyhow = "1.0.52"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "diem-crypto-derive"
version = "0.0.3"
authors = ["Diem Association <opensource@diem.com>"]
publish = false
edition = "2018"
edition = "2021"
license = "Apache-2.0"

[lib]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "diem-crypto"
version = "0.0.3"
authors = ["Diem Association <opensource@diem.com>"]
publish = false
edition = "2018"
edition = "2021"
license = "Apache-2.0"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "diem-framework-natives"
version = "0.0.0"
authors = ["Diem Association <opensource@diem.com>"]
publish = false
edition = "2018"
edition = "2021"
license = "Apache-2.0"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion language/evm/extract-ethereum-abi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Diem Association <opensource@diem.com>"]
description = "Extract Etherem ABI"
publish = false
edition = "2018"
edition = "2021"
license = "Apache-2.0"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion language/evm/move-ethereum-abi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Diem Association <opensource@diem.com>"]
description = "Move Ethereum ABI"
publish = false
edition = "2018"
edition = "2021"
license = "Apache-2.0"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion language/evm/move-to-yul/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Diem Association <opensource@diem.com>"]
description = "Move Solidity Generator"
publish = false
edition = "2018"
edition = "2021"
license = "Apache-2.0"

[dependencies]
Expand Down
4 changes: 2 additions & 2 deletions language/evm/move-to-yul/src/abi_move_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ 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()),
);
}

// Callable functions
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);
}

Expand Down
5 changes: 2 additions & 3 deletions language/evm/move-to-yul/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,7 @@ impl<'a> Context<'a> {
fn get_target_structs(&self, p: impl Fn(&StructEnv) -> bool) -> Vec<StructEnv<'a>> {
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()
}

Expand Down Expand Up @@ -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.
Expand Down
18 changes: 9 additions & 9 deletions language/evm/move-to-yul/src/dispatcher_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ impl Generator {
/// Generate optional receive function.
fn optional_receive(&mut self, ctx: &Context, receive: &Option<FunctionEnv<'_>>) -> 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")
}
Expand Down Expand Up @@ -308,8 +308,8 @@ impl Generator {
fallback: &Option<FunctionEnv<'_>>,
) {
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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -1473,7 +1473,7 @@ impl Generator {
ctx,
&ty.clone(),
&SignatureDataLocation::Memory,
&move_ty,
move_ty,
sub_option.clone()
),
local_typ_var[0].clone()
Expand All @@ -1487,7 +1487,7 @@ impl Generator {
ctx,
&ty.clone(),
&SignatureDataLocation::Memory,
&move_ty,
move_ty,
sub_option.clone()
),
local_typ_var[0].clone(),
Expand All @@ -1506,7 +1506,7 @@ impl Generator {
ctx,
&ty.clone(),
&SignatureDataLocation::Memory,
&move_ty,
move_ty,
sub_option.clone()
),
local_typ_var[0].clone()
Expand Down
2 changes: 1 addition & 1 deletion language/evm/move-to-yul/src/solidity_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion language/evm/move-to-yul/src/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 10 additions & 6 deletions language/evm/move-to-yul/tests/testsuite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};

Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion language/move-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion language/move-binary-format/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion language/move-binary-format/serializer-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion language/move-borrow-graph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ name = "move-borrow-graph"
version = "0.0.1"
authors = ["Diem Association <opensource@diem.com>"]
publish = false
edition = "2018"
edition = "2021"
license = "Apache-2.0"
2 changes: 1 addition & 1 deletion language/move-borrow-graph/src/references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl<Loc: Copy, Lbl: Clone + Ord + Debug> Debug for BorrowEdge<Loc, Lbl> {
// Iteration
//**********************************************************************************************

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

Expand Down
2 changes: 1 addition & 1 deletion language/move-bytecode-verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "invalid-mutations"
version = "0.1.0"
edition = "2018"
edition = "2021"
authors = ["Diem Association <opensource@diem.com>"]
description = "Diem invalid mutations"
repository = "https://github.com/diem/diem"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "bytecode-verifier-transactional-tests"
version = "0.1.0"
authors = ["Diem Association <opensource@diem.com>"]
publish = false
edition = "2018"
edition = "2021"
license = "Apache-2.0"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion language/move-command-line-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion language/move-compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.0.1"
authors = ["Diem Association <opensource@diem.com>"]
description = "The definition of the Move source language, and its compiler"
publish = false
edition = "2018"
edition = "2021"
license = "Apache-2.0"

[dependencies]
Expand Down
Loading