diff --git a/aptos-move/framework/src/extended_checks.rs b/aptos-move/framework/src/extended_checks.rs index a9f80d3afd4689..651d4ab464fba0 100644 --- a/aptos-move/framework/src/extended_checks.rs +++ b/aptos-move/framework/src/extended_checks.rs @@ -45,17 +45,18 @@ pub fn get_all_attribute_names() -> &'static BTreeSet { VIEW_FUN_ATTRIBUTE, ]; - fn add_attribute_names(table: &mut BTreeSet) { - for str in ALL_ATTRIBUTE_NAMES { - table.insert(str.to_string()); - } + fn extended_attribute_names() -> BTreeSet { + ALL_ATTRIBUTE_NAMES + .into_iter() + .map(|s| s.to_string()) + .collect::>() } + static KNOWN_ATTRIBUTES_SET: Lazy> = Lazy::new(|| { use known_attributes::AttributeKind; - let mut known_attributes = BTreeSet::new(); - known_attributes::KnownAttribute::add_attribute_names(&mut known_attributes); - add_attribute_names(&mut known_attributes); - known_attributes + let mut attributes = extended_attribute_names(); + known_attributes::KnownAttribute::add_attribute_names(&mut attributes); + attributes }); &KNOWN_ATTRIBUTES_SET } diff --git a/third_party/move/move-compiler/src/attr_derivation/async_deriver.rs b/third_party/move/move-compiler/src/attr_derivation/async_deriver.rs index 465fe717562a3d..c565d56e3d90e2 100644 --- a/third_party/move/move-compiler/src/attr_derivation/async_deriver.rs +++ b/third_party/move/move-compiler/src/attr_derivation/async_deriver.rs @@ -35,17 +35,22 @@ const GENERATED_SEND_ATTR: &str = "_generated_send"; const MAX_SEND_PARAM_COUNT: usize = 8; -pub(crate) fn add_attributes_for_async(known_attributes: &mut BTreeSet) { - known_attributes.insert(ACTOR_ATTR.to_string()); - known_attributes.insert(CONT_ATTR.to_string()); - known_attributes.insert(EVENT_ATTR.to_string()); - known_attributes.insert(INIT_ATTR.to_string()); - known_attributes.insert(MESSAGE_ATTR.to_string()); - known_attributes.insert(RPC_ATTR.to_string()); - known_attributes.insert(STATE_ATTR.to_string()); - known_attributes.insert(GENERATED_CONT_ATTR.to_string()); - known_attributes.insert(GENERATED_RPC_ATTR.to_string()); - known_attributes.insert(GENERATED_SEND_ATTR.to_string()); +pub(crate) fn add_attributes_for_async(attributes: &mut BTreeSet) { + const ALL_ATTRIBUTE_NAMES: [&str; 10] = [ + ACTOR_ATTR, + CONT_ATTR, + EVENT_ATTR, + INIT_ATTR, + MESSAGE_ATTR, + RPC_ATTR, + STATE_ATTR, + GENERATED_CONT_ATTR, + GENERATED_RPC_ATTR, + GENERATED_SEND_ATTR, + ]; + ALL_ATTRIBUTE_NAMES.into_iter().for_each(|elt| { + attributes.insert(elt.to_string()); + }); } pub(crate) fn derive_for_async( diff --git a/third_party/move/move-compiler/src/attr_derivation/evm_deriver.rs b/third_party/move/move-compiler/src/attr_derivation/evm_deriver.rs index ea890760a8e7e6..89fc637095f968 100644 --- a/third_party/move/move-compiler/src/attr_derivation/evm_deriver.rs +++ b/third_party/move/move-compiler/src/attr_derivation/evm_deriver.rs @@ -43,35 +43,38 @@ const RECEIVE_ATTR: &str = "receive"; const VIEW_ATTR: &str = "view"; const PURE_ATTR: &str = "pure"; -pub(crate) fn add_attributes_for_evm(known_attributes: &mut BTreeSet) { - known_attributes.insert(CALLABLE_ATTR.to_string()); - known_attributes.insert(CONTRACT_ATTR.to_string()); - known_attributes.insert(EXTERNAL_ATTR.to_string()); - - known_attributes.insert(ABI_STRUCT_ATTR.to_string()); - known_attributes.insert(ACTOR_ATTR.to_string()); - known_attributes.insert(CREATE_ATTR.to_string()); - known_attributes.insert(DECODE_ATTR.to_string()); - known_attributes.insert(DELETE_ATTR.to_string()); - known_attributes.insert(ENCODE_ATTR.to_string()); - known_attributes.insert(ENCODE_PACKED_ATTR.to_string()); - known_attributes.insert(EVENT_ATTR.to_string()); - known_attributes.insert(EVM_ARITH_ATTR.to_string()); - known_attributes.insert(EVM_TEST_ATTR.to_string()); - known_attributes.insert(FALLBACK_ATTR.to_string()); - known_attributes.insert(INIT_ATTR.to_string()); - known_attributes.insert(INTERFACE_ATTR.to_string()); - known_attributes.insert(INTERFACE_ID_ATTR.to_string()); - known_attributes.insert(MESSAGE_ATTR.to_string()); - known_attributes.insert(SELECTOR_ATTR.to_string()); - known_attributes.insert(STATE_ATTR.to_string()); - known_attributes.insert(STORAGE_ATTR.to_string()); - - known_attributes.insert(EVM_CONTRACT_ATTR.to_string()); - known_attributes.insert(PAYABLE_ATTR.to_string()); - known_attributes.insert(RECEIVE_ATTR.to_string()); - known_attributes.insert(VIEW_ATTR.to_string()); - known_attributes.insert(PURE_ATTR.to_string()); +pub(crate) fn add_attributes_for_evm(attributes: &mut BTreeSet) { + const ALL_ATTRIBUTE_NAMES: [&str; 26] = [ + CALLABLE_ATTR, + CONTRACT_ATTR, + EXTERNAL_ATTR, + ABI_STRUCT_ATTR, + ACTOR_ATTR, + CREATE_ATTR, + DECODE_ATTR, + DELETE_ATTR, + ENCODE_ATTR, + ENCODE_PACKED_ATTR, + EVENT_ATTR, + EVM_ARITH_ATTR, + EVM_TEST_ATTR, + FALLBACK_ATTR, + INIT_ATTR, + INTERFACE_ATTR, + INTERFACE_ID_ATTR, + MESSAGE_ATTR, + SELECTOR_ATTR, + STATE_ATTR, + STORAGE_ATTR, + EVM_CONTRACT_ATTR, + PAYABLE_ATTR, + RECEIVE_ATTR, + VIEW_ATTR, + PURE_ATTR, + ]; + ALL_ATTRIBUTE_NAMES.into_iter().for_each(|elt| { + attributes.insert(elt.to_string()); + }); } pub(crate) fn derive_for_evm( diff --git a/third_party/move/move-compiler/tests/move_check/parser/aptos_stdlib_attributes.move b/third_party/move/move-compiler/tests/move_check/parser/aptos_stdlib_attributes.move index 8e4f4b67cb68f3..2180c108cb141b 100644 --- a/third_party/move/move-compiler/tests/move_check/parser/aptos_stdlib_attributes.move +++ b/third_party/move/move-compiler/tests/move_check/parser/aptos_stdlib_attributes.move @@ -1,4 +1,6 @@ -module aptos_std::M { +// Test that warnings about unknown "#[testonly]" attribute is +// suppressed in apts_std module. +module aptos_std::module_with_suppressed_warnings { #[a, a(x = 0)] fun foo() {} diff --git a/third_party/move/move-compiler/tests/move_check/skip_attribute_checks/aptos_stdlib_attributes.move b/third_party/move/move-compiler/tests/move_check/skip_attribute_checks/aptos_stdlib_attributes.move index 8e4f4b67cb68f3..2180c108cb141b 100644 --- a/third_party/move/move-compiler/tests/move_check/skip_attribute_checks/aptos_stdlib_attributes.move +++ b/third_party/move/move-compiler/tests/move_check/skip_attribute_checks/aptos_stdlib_attributes.move @@ -1,4 +1,6 @@ -module aptos_std::M { +// Test that warnings about unknown "#[testonly]" attribute is +// suppressed in apts_std module. +module aptos_std::module_with_suppressed_warnings { #[a, a(x = 0)] fun foo() {} diff --git a/third_party/move/move-prover/lab/src/benchmark.rs b/third_party/move/move-prover/lab/src/benchmark.rs index 2e34e1f04722e8..9060c5c4da3e74 100644 --- a/third_party/move/move-prover/lab/src/benchmark.rs +++ b/third_party/move/move-prover/lab/src/benchmark.rs @@ -14,7 +14,7 @@ use clap::{ use codespan_reporting::term::termcolor::{ColorChoice, StandardStream}; use itertools::Itertools; use log::LevelFilter; -use move_compiler::shared::PackagePaths; +use move_compiler::shared::{known_attributes::KnownAttribute, PackagePaths}; use move_model::{ model::{FunctionEnv, GlobalEnv, ModuleEnv, VerificationScope}, parse_addresses_from_options, run_model_builder_with_options, @@ -150,6 +150,8 @@ fn run_benchmark( }; let addrs = parse_addresses_from_options(options.move_named_address_values.clone())?; options.move_deps.append(&mut dep_dirs.to_vec()); + let skip_attribute_checks = true; + let known_attributes = KnownAttribute::get_all_attribute_names().clone(); let env = run_model_builder_with_options( vec![PackagePaths { name: None, @@ -162,6 +164,8 @@ fn run_benchmark( named_address_map: addrs, }], options.model_builder.clone(), + skip_attribute_checks, + &known_attributes, )?; let mut error_writer = StandardStream::stderr(ColorChoice::Auto);