From d75e031083dfb22b505fde463545ffe79ad817f1 Mon Sep 17 00:00:00 2001 From: George Mitenkov Date: Tue, 22 Oct 2024 16:27:59 -0700 Subject: [PATCH] [fix] Format --- Cargo.lock | 1 - .../move/evm/move-to-yul/tests/testsuite.rs | 3 +- third_party/move/move-compiler/Cargo.toml | 1 - .../move-compiler/src/attr_derivation/mod.rs | 118 +----------------- .../move/tools/move-cli/src/base/build.rs | 2 +- 5 files changed, 6 insertions(+), 119 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eb74e7f49d7834..f53d2c2f19b214 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11045,7 +11045,6 @@ dependencies = [ "pathdiff", "petgraph 0.6.5", "regex", - "sha3 0.9.1", "tempfile", ] diff --git a/third_party/move/evm/move-to-yul/tests/testsuite.rs b/third_party/move/evm/move-to-yul/tests/testsuite.rs index c31bcfbbc20187..2d968e33b2ff4b 100644 --- a/third_party/move/evm/move-to-yul/tests/testsuite.rs +++ b/third_party/move/evm/move-to-yul/tests/testsuite.rs @@ -44,8 +44,7 @@ fn test_runner(path: &Path) -> datatest_stable::Result<()> { "Evm".to_string(), NumericalAddress::parse_str("0x2").unwrap(), ); - let flags = move_compiler::Flags::empty() - .set_sources_shadow_deps(true); + let flags = move_compiler::Flags::empty().set_sources_shadow_deps(true); let known_attributes = attr_derivation::get_known_attributes_for_flavor(&flags); let env = run_model_builder_with_options_and_compilation_flags( vec![PackagePaths { diff --git a/third_party/move/move-compiler/Cargo.toml b/third_party/move/move-compiler/Cargo.toml index 140592051b2c7a..038362bf81b09d 100644 --- a/third_party/move/move-compiler/Cargo.toml +++ b/third_party/move/move-compiler/Cargo.toml @@ -15,7 +15,6 @@ hex = { workspace = true } once_cell = { workspace = true } petgraph = { workspace = true } regex = { workspace = true } -sha3 = { workspace = true } tempfile = { workspace = true } bcs = { workspace = true } diff --git a/third_party/move/move-compiler/src/attr_derivation/mod.rs b/third_party/move/move-compiler/src/attr_derivation/mod.rs index 6693a888970f25..3895710c5f0a80 100644 --- a/third_party/move/move-compiler/src/attr_derivation/mod.rs +++ b/third_party/move/move-compiler/src/attr_derivation/mod.rs @@ -3,14 +3,11 @@ // SPDX-License-Identifier: Apache-2.0 use crate::{ - attr_derivation::{ - evm_deriver::{add_attributes_for_evm, derive_for_evm}, - }, + attr_derivation::evm_deriver::{add_attributes_for_evm, derive_for_evm}, parser::ast::{ - Attribute, AttributeValue, Attribute_, Attributes, CallKind, Definition, Exp, Exp_, - Function, FunctionBody_, FunctionName, FunctionSignature, LeadingNameAccess_, - NameAccessChain, NameAccessChain_, StructDefinition, StructLayout, StructName, Type, Type_, - Value_, Var, Visibility, + Attribute, AttributeValue, Attribute_, Attributes, Definition, Function, FunctionBody_, + FunctionName, FunctionSignature, NameAccessChain, NameAccessChain_, Type, Type_, Var, + Visibility, }, shared::{ known_attributes::{AttributeKind, KnownAttribute}, @@ -24,7 +21,6 @@ use std::collections::BTreeSet; mod evm_deriver; const EVM_FLAVOR: &str = "evm"; -const EVENT_ATTR: &str = "event"; /// Entry point for deriving definitions from attributes for the given module. Depending on the /// flavor specified via the flags, this is dispatching to the according attribute processor. @@ -124,48 +120,6 @@ pub(crate) fn new_native_fun( } } -/// Helper to create a new function declaration. -pub(crate) fn new_fun( - loc: Loc, - name: FunctionName, - attributes: Attributes, - visibility: Visibility, - entry: Option, - signature: FunctionSignature, - def: Exp, -) -> Function { - Function { - attributes: vec![attributes], - loc, - visibility, - entry, - signature, - access_specifiers: None, - name, - inline: false, - body: sp( - loc, - FunctionBody_::Defined((vec![], vec![], None, Box::new(Some(def)))), - ), - } -} - -/// Helper to create a new struct declaration. -pub(crate) fn new_struct(loc: Loc, name: StructName, layout: StructLayout) -> StructDefinition { - StructDefinition { - attributes: vec![sp( - // #[event] - loc, - vec![new_attr(loc, EVENT_ATTR, vec![])], - )], - loc, - abilities: vec![], - name, - type_parameters: vec![], - layout, - } -} - /// Helper to create a new named variable. pub(crate) fn new_var(loc: Loc, name: &str) -> Var { Var(sp(loc, Symbol::from(name))) @@ -183,67 +137,3 @@ pub(crate) fn new_simple_type(loc: Loc, ty_str: &str, ty_args: Vec) -> Typ pub(crate) fn new_simple_name(loc: Loc, name: &str) -> NameAccessChain { sp(loc, NameAccessChain_::One(sp(loc, Symbol::from(name)))) } - -/// Helper to create a full name. -pub(crate) fn new_full_name( - loc: Loc, - addr_alias: &str, - module: &str, - name: &str, -) -> NameAccessChain { - let leading = sp( - loc, - LeadingNameAccess_::Name(sp(loc, Symbol::from(addr_alias))), - ); - sp( - loc, - NameAccessChain_::Three( - sp(loc, (leading, sp(loc, Symbol::from(module)))), - sp(loc, Symbol::from(name)), - ), - ) -} - -/// Helper to create a call exp. -pub(crate) fn new_call_exp(loc: Loc, fun: NameAccessChain, args: Vec) -> Exp { - sp(loc, Exp_::Call(fun, CallKind::Regular, None, sp(loc, args))) -} - -pub(crate) fn new_borrow_exp(loc: Loc, arg: Exp) -> Exp { - sp(loc, Exp_::Borrow(false, Box::new(arg))) -} - -/// Helper to create a name exp. -pub(crate) fn new_simple_name_exp(loc: Loc, name: Name) -> Exp { - sp(loc, Exp_::Name(sp(loc, NameAccessChain_::One(name)), None)) -} - -/// Helper to create an expression for denoting a vector value. -#[allow(unused)] -pub(crate) fn new_vec_u8(loc: Loc, vec: &[u8]) -> Exp { - let values = vec - .iter() - .map(|x| { - sp( - loc, - Exp_::Value(sp(loc, Value_::Num(Symbol::from(x.to_string())))), - ) - }) - .collect(); - sp( - loc, - Exp_::Vector( - loc, - Some(vec![new_simple_type(loc, "u8", vec![])]), - sp(loc, values), - ), - ) -} - -/// Helper to create new u64. -pub(crate) fn new_u64(loc: Loc, val: u64) -> Exp { - sp( - loc, - Exp_::Value(sp(loc, Value_::Num(Symbol::from(val.to_string())))), - ) -} diff --git a/third_party/move/tools/move-cli/src/base/build.rs b/third_party/move/tools/move-cli/src/base/build.rs index 6f305e2fd1c055..74f33acaa38d29 100644 --- a/third_party/move/tools/move-cli/src/base/build.rs +++ b/third_party/move/tools/move-cli/src/base/build.rs @@ -25,7 +25,7 @@ impl Build { let architecture = config.architecture.unwrap_or(Architecture::Move); match architecture { - Architecture::Move | Architecture::AsyncMove => { + Architecture::Move => { config.compile_package(&rerooted_path, &mut std::io::stdout())?; },