diff --git a/Cargo.lock b/Cargo.lock index 13351b6f33c4eb..d72fd19c532ded 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6767,7 +6767,6 @@ dependencies = [ "move-coverage", "move-disassembler", "move-docgen", - "move-errmapgen", "move-ir-types", "move-package", "move-prover", @@ -6912,17 +6911,6 @@ dependencies = [ "serde", ] -[[package]] -name = "move-errmapgen" -version = "0.1.0" -dependencies = [ - "anyhow", - "move-command-line-common", - "move-core-types", - "move-model", - "serde", -] - [[package]] name = "move-ir-compiler" version = "0.1.0" @@ -7057,7 +7045,6 @@ dependencies = [ "move-command-line-common", "move-compiler", "move-docgen", - "move-errmapgen", "move-model", "move-stackless-bytecode", "once_cell", @@ -7097,7 +7084,6 @@ dependencies = [ "move-command-line-common", "move-core-types", "move-docgen", - "move-errmapgen", "move-prover", "move-stdlib-natives", "move-vm-runtime", diff --git a/external-crates/move/Cargo.lock b/external-crates/move/Cargo.lock index 0140cce6fa5cb0..dd1b5c2c109bc5 100644 --- a/external-crates/move/Cargo.lock +++ b/external-crates/move/Cargo.lock @@ -1692,7 +1692,6 @@ dependencies = [ "move-coverage", "move-disassembler", "move-docgen", - "move-errmapgen", "move-ir-types", "move-package", "move-prover", @@ -1854,30 +1853,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "move-errmapgen" -version = "0.1.0" -dependencies = [ - "anyhow", - "codespan-reporting", - "datatest-stable", - "move-command-line-common", - "move-core-types", - "move-model", - "move-prover", - "serde", -] - -[[package]] -name = "move-explain" -version = "0.1.0" -dependencies = [ - "bcs", - "clap 4.5.4", - "move-command-line-common", - "move-core-types", -] - [[package]] name = "move-ir-compiler" version = "0.1.0" @@ -2025,7 +2000,6 @@ dependencies = [ "move-command-line-common", "move-compiler", "move-docgen", - "move-errmapgen", "move-model", "move-prover-test-utils", "move-stackless-bytecode", @@ -2086,7 +2060,6 @@ dependencies = [ "move-command-line-common", "move-core-types", "move-docgen", - "move-errmapgen", "move-package", "move-prover", "move-stdlib-natives", diff --git a/external-crates/move/crates/move-cli/Cargo.toml b/external-crates/move/crates/move-cli/Cargo.toml index 57b80e0e7402fc..d718f3727217e9 100644 --- a/external-crates/move/crates/move-cli/Cargo.toml +++ b/external-crates/move/crates/move-cli/Cargo.toml @@ -41,7 +41,6 @@ move-binary-format.workspace = true move-package.workspace = true move-prover.workspace = true move-unit-test.workspace = true -move-errmapgen.workspace = true move-bytecode-viewer.workspace = true [dev-dependencies] diff --git a/external-crates/move/crates/move-cli/src/base/errmap.rs b/external-crates/move/crates/move-cli/src/base/errmap.rs deleted file mode 100644 index 130ea42db815ef..00000000000000 --- a/external-crates/move/crates/move-cli/src/base/errmap.rs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) The Move Contributors -// SPDX-License-Identifier: Apache-2.0 - -use super::reroot_path; -use clap::*; -use move_package::{BuildConfig, ModelConfig}; -use std::path::{Path, PathBuf}; - -/// Generate error map for the package and its dependencies at `path` for use by the Move -/// explanation tool. -#[derive(Parser)] -#[clap(name = "errmap")] -pub struct Errmap { - /// The prefix that all error reasons within modules will be prefixed with, e.g., "E" if - /// all error reasons are "E_CANNOT_PERFORM_OPERATION", "E_CANNOT_ACCESS", etc. - #[clap(long)] - pub error_prefix: Option, - /// The file to serialize the generated error map to. - #[clap(long, default_value = "error_map")] - pub output_file: PathBuf, -} - -impl Errmap { - pub fn execute(self, path: Option<&Path>, config: BuildConfig) -> anyhow::Result<()> { - let rerooted_path = reroot_path(path)?; - let Self { - error_prefix, - output_file, - } = self; - let mut errmap_options = move_errmapgen::ErrmapOptions::default(); - if let Some(err_prefix) = error_prefix { - errmap_options.error_prefix = err_prefix; - } - errmap_options.output_file = output_file - .with_extension(move_command_line_common::files::MOVE_ERROR_DESC_EXTENSION) - .to_string_lossy() - .to_string(); - let model = config.move_model_for_package( - &rerooted_path, - ModelConfig { - all_files_as_targets: true, - target_filter: None, - }, - )?; - let mut errmap_gen = move_errmapgen::ErrmapGen::new(&model, &errmap_options); - errmap_gen.gen(); - errmap_gen.save_result(); - Ok(()) - } -} diff --git a/external-crates/move/crates/move-cli/src/base/mod.rs b/external-crates/move/crates/move-cli/src/base/mod.rs index 17ecabafeeb8ec..c8101360b0eb21 100644 --- a/external-crates/move/crates/move-cli/src/base/mod.rs +++ b/external-crates/move/crates/move-cli/src/base/mod.rs @@ -5,7 +5,6 @@ pub mod build; pub mod coverage; pub mod disassemble; pub mod docgen; -pub mod errmap; pub mod info; pub mod migrate; pub mod new; diff --git a/external-crates/move/crates/move-cli/src/lib.rs b/external-crates/move/crates/move-cli/src/lib.rs index e5f70c5ba3629d..c20715bf3ddb26 100644 --- a/external-crates/move/crates/move-cli/src/lib.rs +++ b/external-crates/move/crates/move-cli/src/lib.rs @@ -3,8 +3,8 @@ // SPDX-License-Identifier: Apache-2.0 use base::{ - build::Build, coverage::Coverage, disassemble::Disassemble, docgen::Docgen, errmap::Errmap, - info::Info, migrate::Migrate, new::New, test::Test, + build::Build, coverage::Coverage, disassemble::Disassemble, docgen::Docgen, info::Info, + migrate::Migrate, new::New, test::Test, }; use move_package::BuildConfig; @@ -19,9 +19,7 @@ pub const DEFAULT_BUILD_DIR: &str = "."; use anyhow::Result; use clap::Parser; -use move_core_types::{ - account_address::AccountAddress, errmap::ErrorMapping, identifier::Identifier, -}; +use move_core_types::{account_address::AccountAddress, identifier::Identifier}; use move_vm_runtime::native_functions::NativeFunction; use move_vm_test_utils::gas_schedule::CostTable; use std::path::PathBuf; @@ -62,7 +60,6 @@ pub enum Command { Coverage(Coverage), Disassemble(Disassemble), Docgen(Docgen), - Errmap(Errmap), Info(Info), Migrate(Migrate), New(New), @@ -82,7 +79,6 @@ pub enum Command { pub fn run_cli( natives: Vec, cost_table: &CostTable, - error_descriptions: &ErrorMapping, move_args: Move, cmd: Command, ) -> Result<()> { @@ -98,7 +94,6 @@ pub fn run_cli( c.execute(move_args.package_path.as_deref(), move_args.build_config) } Command::Docgen(c) => c.execute(move_args.package_path.as_deref(), move_args.build_config), - Command::Errmap(c) => c.execute(move_args.package_path.as_deref(), move_args.build_config), Command::Info(c) => c.execute(move_args.package_path.as_deref(), move_args.build_config), Command::Migrate(c) => c.execute(move_args.package_path.as_deref(), move_args.build_config), Command::New(c) => c.execute_with_defaults(move_args.package_path.as_deref()), @@ -108,27 +103,13 @@ pub fn run_cli( natives, Some(cost_table.clone()), ), - Command::Sandbox { storage_dir, cmd } => cmd.handle_command( - natives, - cost_table, - error_descriptions, - &move_args, - &storage_dir, - ), + Command::Sandbox { storage_dir, cmd } => { + cmd.handle_command(natives, cost_table, &move_args, &storage_dir) + } } } -pub fn move_cli( - natives: Vec, - cost_table: &CostTable, - error_descriptions: &ErrorMapping, -) -> Result<()> { +pub fn move_cli(natives: Vec, cost_table: &CostTable) -> Result<()> { let args = MoveCLI::parse(); - run_cli( - natives, - cost_table, - error_descriptions, - args.move_args, - args.cmd, - ) + run_cli(natives, cost_table, args.move_args, args.cmd) } diff --git a/external-crates/move/crates/move-cli/src/main.rs b/external-crates/move/crates/move-cli/src/main.rs index 289dc6207a54ab..acbbbe6d23a8d3 100644 --- a/external-crates/move/crates/move-cli/src/main.rs +++ b/external-crates/move/crates/move-cli/src/main.rs @@ -3,11 +3,10 @@ // SPDX-License-Identifier: Apache-2.0 use anyhow::Result; -use move_core_types::{account_address::AccountAddress, errmap::ErrorMapping}; +use move_core_types::account_address::AccountAddress; use move_stdlib_natives::{all_natives, nursery_natives, GasParameters, NurseryGasParameters}; fn main() -> Result<()> { - let error_descriptions: ErrorMapping = bcs::from_bytes(move_stdlib::error_descriptions())?; let cost_table = &move_vm_test_utils::gas_schedule::INITIAL_COST_SCHEDULE; let addr = AccountAddress::from_hex_literal("0x1").unwrap(); let natives = all_natives(addr, GasParameters::zeros()) @@ -19,5 +18,5 @@ fn main() -> Result<()> { )) .collect(); - move_cli::move_cli(natives, cost_table, &error_descriptions) + move_cli::move_cli(natives, cost_table) } diff --git a/external-crates/move/crates/move-cli/src/sandbox/cli.rs b/external-crates/move/crates/move-cli/src/sandbox/cli.rs index 39f3bed91b7d5b..30a4053bfdfb0e 100644 --- a/external-crates/move/crates/move-cli/src/sandbox/cli.rs +++ b/external-crates/move/crates/move-cli/src/sandbox/cli.rs @@ -12,8 +12,7 @@ use crate::{ use anyhow::Result; use clap::Parser; use move_core_types::{ - errmap::ErrorMapping, language_storage::TypeTag, parser, - transaction_argument::TransactionArgument, + language_storage::TypeTag, parser, transaction_argument::TransactionArgument, }; use move_package::compilation::package_layout::CompiledPackageLayout; use move_vm_test_utils::gas_schedule::CostTable; @@ -188,7 +187,6 @@ impl SandboxCommand { &self, natives: Vec, cost_table: &CostTable, - error_descriptions: &ErrorMapping, move_args: &Move, storage_dir: &Path, ) -> Result<()> { @@ -229,7 +227,6 @@ impl SandboxCommand { sandbox::commands::run( natives, cost_table, - error_descriptions, &state, context.package(), module_file, diff --git a/external-crates/move/crates/move-cli/src/sandbox/commands/run.rs b/external-crates/move/crates/move-cli/src/sandbox/commands/run.rs index d530c664b3ee5e..2a710ae83b97b5 100644 --- a/external-crates/move/crates/move-cli/src/sandbox/commands/run.rs +++ b/external-crates/move/crates/move-cli/src/sandbox/commands/run.rs @@ -14,7 +14,6 @@ use move_binary_format::file_format::CompiledModule; use move_command_line_common::files::try_exists; use move_core_types::{ account_address::AccountAddress, - errmap::ErrorMapping, identifier::IdentStr, language_storage::TypeTag, runtime_value::MoveValue, @@ -28,7 +27,6 @@ use std::{fs, path::Path}; pub fn run( natives: impl IntoIterator, cost_table: &CostTable, - error_descriptions: &ErrorMapping, state: &OnDiskStateView, _package: &CompiledPackage, module_file: &Path, @@ -108,7 +106,6 @@ pub fn run( if let Err(err) = res { explain_execution_error( - error_descriptions, err, state, &script_type_parameters, diff --git a/external-crates/move/crates/move-cli/src/sandbox/utils/mod.rs b/external-crates/move/crates/move-cli/src/sandbox/utils/mod.rs index 16524d8a17fbaa..58a597f9117857 100644 --- a/external-crates/move/crates/move-cli/src/sandbox/utils/mod.rs +++ b/external-crates/move/crates/move-cli/src/sandbox/utils/mod.rs @@ -17,7 +17,6 @@ use move_compiler::diagnostics::{self, report_diagnostics, Diagnostic, Diagnosti use move_core_types::{ account_address::AccountAddress, effects::{ChangeSet, Op}, - errmap::ErrorMapping, language_storage::{ModuleId, TypeTag}, transaction_argument::TransactionArgument, vm_status::{StatusCode, StatusType}, @@ -280,7 +279,6 @@ pub(crate) fn explain_publish_error( /// Explain an execution error pub(crate) fn explain_execution_error( - error_descriptions: &ErrorMapping, error: VMError, state: &OnDiskStateView, script_type_parameters: &[AbilitySet], @@ -292,21 +290,10 @@ pub(crate) fn explain_execution_error( use StatusCode::*; match (error.location(), error.major_status(), error.sub_status()) { (Location::Module(module_id), StatusCode::ABORTED, Some(abort_code)) => { - // try to use move-explain to explain the abort - - print!( + println!( "Execution aborted with code {} in module {}.", abort_code, module_id ); - - if let Some(error_desc) = error_descriptions.get_explanation(module_id, abort_code) { - println!( - " Abort code details:\nName: {}\nDescription:{}", - error_desc.code_name, error_desc.code_description, - ) - } else { - println!() - } } (location, status_code, _) if error.status_type() == StatusType::Execution => { let (function, code_offset) = error.offsets()[0]; diff --git a/external-crates/move/crates/move-cli/tests/build_tests/help/args.exp b/external-crates/move/crates/move-cli/tests/build_tests/help/args.exp index 3c95bffca36862..b9e005495b14c9 100644 --- a/external-crates/move/crates/move-cli/tests/build_tests/help/args.exp +++ b/external-crates/move/crates/move-cli/tests/build_tests/help/args.exp @@ -8,7 +8,6 @@ Commands: coverage Inspect test coverage for this package. A previous test run with the `--coverage` flag must have previously been run disassemble Disassemble the Move bytecode pointed to docgen Generate javadoc style documentation for Move packages - errmap Generate error map for the package and its dependencies at `path` for use by the Move explanation tool info Print address information migrate Migrate to Move 2024 for the package at `path`. If no path is provided defaults to current directory new Create a new Move package with name `name` at `path`. If `path` is not provided the package will be created in the directory `name` diff --git a/external-crates/move/crates/move-cli/tests/sandbox_tests/package_basics/args.exp b/external-crates/move/crates/move-cli/tests/sandbox_tests/package_basics/args.exp index 9286cc0412666a..623a5b33a28cc9 100644 --- a/external-crates/move/crates/move-cli/tests/sandbox_tests/package_basics/args.exp +++ b/external-crates/move/crates/move-cli/tests/sandbox_tests/package_basics/args.exp @@ -94,7 +94,6 @@ B0: } } -Command `errmap`: Command `info`: PackageBasics ├── std:0x1 diff --git a/external-crates/move/crates/move-cli/tests/sandbox_tests/package_basics/args.txt b/external-crates/move/crates/move-cli/tests/sandbox_tests/package_basics/args.txt index 64ea070e28d348..a80887c977c7f6 100644 --- a/external-crates/move/crates/move-cli/tests/sandbox_tests/package_basics/args.txt +++ b/external-crates/move/crates/move-cli/tests/sandbox_tests/package_basics/args.txt @@ -4,7 +4,6 @@ coverage summary --summarize-functions coverage source --module AModule coverage bytecode --module AModule disassemble --package MoveStdlib --name signer -errmap info test double_two test one_one diff --git a/external-crates/move/crates/move-cli/tools.md b/external-crates/move/crates/move-cli/tools.md index d2cbd9ec546c09..0dd3da7c662943 100644 --- a/external-crates/move/crates/move-cli/tools.md +++ b/external-crates/move/crates/move-cli/tools.md @@ -10,12 +10,11 @@ Move has a number of tools associated with it. This directory contains all, or almost all of them. The following crates in this directory are libraries that are used by the [`move-cli`](./move-cli) `package` subcommand: -* `move-bytecode-viewer` -* `move-disassembler` -* `move-explain` -* `move-unit-test` -* `move-package` -* `move-coverage` +- `move-bytecode-viewer` +- `move-disassembler` +- `move-unit-test` +- `move-package` +- `move-coverage` In this sense each of these crates defines the core logic for a specific package command, e.g., how to run and report unit tests, or collect and diff --git a/external-crates/move/crates/move-errmapgen/Cargo.toml b/external-crates/move/crates/move-errmapgen/Cargo.toml deleted file mode 100644 index d40ad6416c035c..00000000000000 --- a/external-crates/move/crates/move-errmapgen/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "move-errmapgen" -version = "0.1.0" -authors = ["Diem Association "] -publish = false -edition = "2021" -license = "Apache-2.0" - -[dependencies] -# Move dependencies -move-command-line-common.workspace = true -move-model.workspace = true -move-core-types.workspace = true - -# external dependencies -anyhow.workspace = true -serde.workspace = true - -[dev-dependencies] -codespan-reporting.workspace = true -move-prover.workspace = true -datatest-stable.workspace = true diff --git a/external-crates/move/crates/move-errmapgen/src/errmapgen.rs b/external-crates/move/crates/move-errmapgen/src/errmapgen.rs deleted file mode 100644 index 1a9aeb2b6d4835..00000000000000 --- a/external-crates/move/crates/move-errmapgen/src/errmapgen.rs +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) The Diem Core Contributors -// Copyright (c) The Move Contributors -// SPDX-License-Identifier: Apache-2.0 - -use anyhow::{bail, Result}; -use move_command_line_common::files::MOVE_ERROR_DESC_EXTENSION; -use move_core_types::{ - account_address::AccountAddress, - errmap::{ErrorDescription, ErrorMapping}, - identifier::Identifier, - language_storage::ModuleId, -}; -use move_model::{ - ast::Value, - model::{GlobalEnv, ModuleEnv, NamedConstantEnv}, - symbol::Symbol, -}; -use serde::{Deserialize, Serialize}; -use std::{convert::TryFrom, rc::Rc}; - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct ErrmapOptions { - /// The constant prefix that determines if a constant is an error or not - pub error_prefix: String, - /// The module ID of the error category module - pub error_category_module: ModuleId, - /// In which file to store the output - pub output_file: String, -} - -impl Default for ErrmapOptions { - fn default() -> Self { - Self { - error_prefix: "E".to_string(), - error_category_module: ModuleId::new( - AccountAddress::from_hex_literal("0x1").unwrap(), - Identifier::new("errors").unwrap(), - ), - output_file: MOVE_ERROR_DESC_EXTENSION.to_string(), - } - } -} - -pub struct ErrmapGen<'env> { - /// Options for error map generation - options: &'env ErrmapOptions, - /// Input definitions - env: &'env GlobalEnv, - /// Output error mapping - output: ErrorMapping, -} - -impl<'env> ErrmapGen<'env> { - pub fn new(env: &'env GlobalEnv, options: &'env ErrmapOptions) -> Self { - Self { - options, - env, - output: ErrorMapping::default(), - } - } - - pub fn save_result(&self) { - self.output.to_file(&self.options.output_file); - } - - pub fn gen(&mut self) { - for module in self.env.get_modules() { - if !module.is_script_module() { - self.build_error_map(&module).unwrap() - } - } - } - - fn build_error_map(&mut self, module: &ModuleEnv<'_>) -> Result<()> { - let module_id = self.get_module_id_for_name(module); - if module_id == self.options.error_category_module { - self.build_error_categories(module)? - } else { - self.build_error_map_for_module(&module_id, module)? - } - Ok(()) - } - - fn build_error_categories(&mut self, module: &ModuleEnv<'_>) -> Result<()> { - for named_constant in module.get_named_constants() { - let name = self.name_string(named_constant.get_name()); - let error_category = self.get_abort_code(&named_constant)?; - self.output.add_error_category( - error_category, - ErrorDescription { - code_name: name.to_string(), - code_description: named_constant.get_doc().to_string(), - }, - )? - } - Ok(()) - } - - fn build_error_map_for_module( - &mut self, - module_id: &ModuleId, - module: &ModuleEnv<'_>, - ) -> Result<()> { - for named_constant in module.get_named_constants() { - let name = self.name_string(named_constant.get_name()); - if name.starts_with(&self.options.error_prefix) { - let abort_code = self.get_abort_code(&named_constant)?; - self.output.add_module_error( - module_id.clone(), - abort_code, - ErrorDescription { - code_name: name.to_string(), - code_description: named_constant.get_doc().to_string(), - }, - )? - } - } - Ok(()) - } - - fn get_abort_code(&self, constant: &NamedConstantEnv<'_>) -> Result { - match constant.get_value() { - Value::Number(big_int) => u64::try_from(big_int).map_err(|err| err.into()), - x => bail!( - "Invalid abort code constant {} found for code {}", - x, - self.name_string(constant.get_name()) - ), - } - } - - fn get_module_id_for_name(&self, module: &ModuleEnv<'_>) -> ModuleId { - let name = module.get_name(); - let addr = AccountAddress::from_hex_literal(&format!("0x{:x}", name.addr())).unwrap(); - let name = Identifier::new(self.name_string(name.name()).to_string()).unwrap(); - ModuleId::new(addr, name) - } - - fn name_string(&self, symbol: Symbol) -> Rc { - self.env.symbol_pool().string(symbol) - } -} diff --git a/external-crates/move/crates/move-errmapgen/src/lib.rs b/external-crates/move/crates/move-errmapgen/src/lib.rs deleted file mode 100644 index 90cc7d01f354b2..00000000000000 --- a/external-crates/move/crates/move-errmapgen/src/lib.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) The Diem Core Contributors -// Copyright (c) The Move Contributors -// SPDX-License-Identifier: Apache-2.0 - -#![forbid(unsafe_code)] - -mod errmapgen; - -pub use crate::errmapgen::*; diff --git a/external-crates/move/crates/move-explain/Cargo.toml b/external-crates/move/crates/move-explain/Cargo.toml deleted file mode 100644 index 641cabf046f4a7..00000000000000 --- a/external-crates/move/crates/move-explain/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "move-explain" -version = "0.1.0" -authors = ["Diem Association "] -description = "Explain Move abort codes. Errors are defined as a global category + module-specific reason for the error" -repository = "https://github.com/diem/diem" -homepage = "https://diem.com" -license = "Apache-2.0" -publish = false -edition = "2021" - -[dependencies] -clap.workspace = true -move-command-line-common.workspace = true -move-core-types.workspace = true - -bcs.workspace = true - -[features] -default = [] diff --git a/external-crates/move/crates/move-explain/src/main.rs b/external-crates/move/crates/move-explain/src/main.rs deleted file mode 100644 index c8bf95a6470d4f..00000000000000 --- a/external-crates/move/crates/move-explain/src/main.rs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) The Diem Core Contributors -// Copyright (c) The Move Contributors -// SPDX-License-Identifier: Apache-2.0 - -use clap::Parser; -use move_command_line_common::files::MOVE_ERROR_DESC_EXTENSION; -use move_core_types::{ - account_address::AccountAddress, errmap::ErrorMapping, identifier::Identifier, - language_storage::ModuleId, -}; -#[derive(Debug, Parser)] -#[clap(author, version, about)] -struct Args { - /// The location (module id) returned with a `MoveAbort` error - #[clap(long = "location", short = 'l')] - location: String, - /// The abort code returned with a `MoveAbort` error - #[clap(long = "abort-code", short = 'a')] - abort_code: u64, - /// Path to the error code mapping file - #[clap(long = MOVE_ERROR_DESC_EXTENSION, short = 'e')] - errmap_path: String, -} - -fn main() { - let args = Args::parse(); - - let mut location = args.location.trim().split("::"); - let mut address_literal = location.next().expect("Could not find address").to_string(); - let module_name = location - .next() - .expect("Could not find module name") - .to_string(); - if !address_literal.starts_with("0x") { - address_literal = format!("0x{}", address_literal); - } - let module_id = ModuleId::new( - AccountAddress::from_hex_literal(&address_literal).expect("Unable to parse module address"), - Identifier::new(module_name).expect("Invalid module name encountered"), - ); - - let errmap_bytes = std::fs::read(&args.errmap_path).expect("Could not load errmap from file"); - let errmap: ErrorMapping = - bcs::from_bytes(&errmap_bytes).expect("Failed to deserialize errmap"); - - match errmap.get_explanation(&module_id, args.abort_code) { - None => println!( - "Unable to find a description for {}::{}", - args.location, args.abort_code - ), - Some(error_desc) => println!( - "Name: {}\nDescription: {}", - error_desc.code_name, error_desc.code_description, - ), - } -} diff --git a/external-crates/move/crates/move-prover/Cargo.toml b/external-crates/move/crates/move-prover/Cargo.toml index f57e20d5fb067d..c6830239b48d41 100644 --- a/external-crates/move/crates/move-prover/Cargo.toml +++ b/external-crates/move/crates/move-prover/Cargo.toml @@ -12,7 +12,6 @@ move-command-line-common.workspace = true move-compiler.workspace = true move-model.workspace = true move-docgen.workspace = true -move-errmapgen.workspace = true move-stackless-bytecode.workspace = true # external dependencies diff --git a/external-crates/move/crates/move-prover/src/cli.rs b/external-crates/move/crates/move-prover/src/cli.rs index bdb6807720d386..49fcbb99862197 100644 --- a/external-crates/move/crates/move-prover/src/cli.rs +++ b/external-crates/move/crates/move-prover/src/cli.rs @@ -24,7 +24,6 @@ use simplelog::{ use codespan_reporting::diagnostic::Severity; use move_docgen::DocgenOptions; -use move_errmapgen::ErrmapOptions; use move_model::options::ModelBuilderOptions; use move_stackless_bytecode::options::{AutoTraceLevel, ProverOptions}; @@ -49,8 +48,6 @@ pub struct Options { pub verbosity_level: LevelFilter, /// Whether to run the documentation generator instead of the prover. pub run_docgen: bool, - /// Whether to run the error map generator instead of the prover. - pub run_errmapgen: bool, /// Whether to run the internal reference escape analysis instead of the prover pub run_escape: bool, /// The paths to the Move sources. @@ -70,10 +67,6 @@ pub struct Options { pub docgen: DocgenOptions, /// Options for the prover. pub prover: ProverOptions, - /// Options for the error map generator. - /// TODO: this currently create errors during deserialization, so skip them for this. - #[serde(skip_serializing)] - pub errmapgen: ErrmapOptions, } impl Default for Options { @@ -81,7 +74,6 @@ impl Default for Options { Self { output_path: "output.bpl".to_string(), run_docgen: false, - run_errmapgen: false, run_escape: false, verbosity_level: LevelFilter::Info, move_sources: vec![], @@ -90,7 +82,6 @@ impl Default for Options { model_builder: ModelBuilderOptions::default(), prover: ProverOptions::default(), docgen: DocgenOptions::default(), - errmapgen: ErrmapOptions::default(), experimental_pipeline: false, } } @@ -293,13 +284,6 @@ impl Options { .help("runs the ABI generator instead of the prover. \ Generated ABIs will be written into the directory `./abi` unless configured otherwise via toml"), ) - .arg( - Arg::new("errmapgen") - .long("errmapgen") - .action(clap::ArgAction::SetTrue) - .help("runs the error map generator instead of the prover. \ - The generated error map will be written to `errmap` unless configured otherwise"), - ) .arg( Arg::new("packedtypesgen") .long("packedtypesgen") @@ -650,9 +634,6 @@ impl Options { .map(|s| s.to_string()) .unwrap()] } - if matches.get_flag("errmapgen") { - options.run_errmapgen = true; - } if matches.get_flag("escape") { options.run_escape = true; } diff --git a/external-crates/move/crates/move-prover/src/lib.rs b/external-crates/move/crates/move-prover/src/lib.rs index 990ddaeb575156..6224a22142aa46 100644 --- a/external-crates/move/crates/move-prover/src/lib.rs +++ b/external-crates/move/crates/move-prover/src/lib.rs @@ -14,7 +14,6 @@ use codespan_reporting::{ use log::{debug, info, warn}; use move_compiler::shared::PackagePaths; use move_docgen::Docgen; -use move_errmapgen::ErrmapGen; use move_model::{model::GlobalEnv, parse_addresses_from_options, run_model_builder_with_options}; use move_stackless_bytecode::{ escape_analysis::EscapeAnalysisProcessor, @@ -105,13 +104,6 @@ pub fn run_move_prover_with_model( if options.run_docgen { return run_docgen(env, &options, error_writer, now); } - // Same for the error map generator - if options.run_errmapgen { - return { - run_errmapgen(env, &options, now); - Ok(()) - }; - } // Same for escape analysis if options.run_escape { return { @@ -220,20 +212,6 @@ fn run_docgen( } } -fn run_errmapgen(env: &GlobalEnv, options: &Options, now: Instant) { - let mut generator = ErrmapGen::new(env, &options.errmapgen); - let checking_elapsed = now.elapsed(); - info!("generating error map"); - generator.gen(); - generator.save_result(); - let generating_elapsed = now.elapsed(); - info!( - "{:.3}s checking, {:.3}s generating", - checking_elapsed.as_secs_f64(), - (generating_elapsed - checking_elapsed).as_secs_f64() - ); -} - fn run_escape(env: &GlobalEnv, options: &Options, now: Instant) { let mut targets = FunctionTargetsHolder::default(); for module_env in env.get_modules() { diff --git a/external-crates/move/crates/move-prover/tools/check_pr.sh b/external-crates/move/crates/move-prover/tools/check_pr.sh index ec57f7370e6bde..45a05eafbfd607 100755 --- a/external-crates/move/crates/move-prover/tools/check_pr.sh +++ b/external-crates/move/crates/move-prover/tools/check_pr.sh @@ -88,7 +88,6 @@ if [ ! -z "$CHECKMORE" ]; then CRATES="$CRATES \ $BASE/language/move-prover/move-abigen\ $BASE/language/move-prover/move-docgen\ - $BASE/language/move-prover/errmapgen\ $BASE/language/move-prover/interpreter\ $BASE/language/move-prover/interpreter-testsuite\ $BASE/language/move-prover/lab\ diff --git a/external-crates/move/crates/move-stdlib/Cargo.toml b/external-crates/move/crates/move-stdlib/Cargo.toml index 19eba591e46207..d652de36b2dc86 100644 --- a/external-crates/move/crates/move-stdlib/Cargo.toml +++ b/external-crates/move/crates/move-stdlib/Cargo.toml @@ -11,7 +11,6 @@ publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -move-errmapgen.workspace = true move-docgen.workspace = true move-command-line-common.workspace = true move-prover.workspace = true diff --git a/external-crates/move/crates/move-stdlib/src/lib.rs b/external-crates/move/crates/move-stdlib/src/lib.rs index b300fa29181a7b..45c5c87b8b7d2e 100644 --- a/external-crates/move/crates/move-stdlib/src/lib.rs +++ b/external-crates/move/crates/move-stdlib/src/lib.rs @@ -17,7 +17,6 @@ const MODULES_DIR: &str = "sources"; const NURSERY_DIR: &str = "nursery"; const DOCS_DIR: &str = "docs"; const NURSERY_DOCS_DIR: &str = "nursery/docs"; -const ERRMAP_FILE: &str = "error_description.errmap"; const REFERENCES_TEMPLATE: &str = "doc_templates/references.md"; const OVERVIEW_TEMPLATE: &str = "doc_templates/overview.md"; @@ -50,10 +49,6 @@ pub fn move_nursery_docs_full_path() -> String { format!("{}/{}", env!("CARGO_MANIFEST_DIR"), NURSERY_DOCS_DIR) } -pub fn move_stdlib_errmap_full_path() -> String { - format!("{}/{}", env!("CARGO_MANIFEST_DIR"), ERRMAP_FILE) -} - pub fn move_stdlib_files() -> Vec { let path = path_in_crate(MODULES_DIR); find_filenames(&[path], |p| extension_equals(p, MOVE_EXTENSION)).unwrap() @@ -134,28 +129,3 @@ pub fn build_nursery_doc(output_path: &str) { move_stdlib_named_addresses(), ) } - -pub fn build_error_code_map(output_path: &str) { - let options = move_prover::cli::Options { - move_sources: crate::move_stdlib_files(), - move_deps: vec![], - verbosity_level: LevelFilter::Warn, - run_errmapgen: true, - move_named_address_values: move_prover::cli::named_addresses_for_options( - &move_stdlib_named_addresses(), - ), - errmapgen: move_errmapgen::ErrmapOptions { - output_file: output_path.to_string(), - ..Default::default() - }, - ..Default::default() - }; - options.setup_logging_for_test(); - move_prover::run_move_prover_errors_to_stderr(options).unwrap(); -} - -const ERROR_DESCRIPTIONS: &[u8] = include_bytes!("../error_description.errmap"); - -pub fn error_descriptions() -> &'static [u8] { - ERROR_DESCRIPTIONS -} diff --git a/external-crates/move/crates/move-stdlib/src/main.rs b/external-crates/move/crates/move-stdlib/src/main.rs index 050cd6afecaae3..03652b782db600 100644 --- a/external-crates/move/crates/move-stdlib/src/main.rs +++ b/external-crates/move/crates/move-stdlib/src/main.rs @@ -17,10 +17,5 @@ fn main() { std::fs::remove_dir_all(move_stdlib::move_nursery_docs_full_path()).unwrap_or(()); move_stdlib::build_nursery_doc(&move_stdlib::move_nursery_docs_full_path()); }); - - time_it("Generating error explanations", || { - std::fs::remove_file(move_stdlib::move_stdlib_errmap_full_path()).unwrap_or(()); - move_stdlib::build_error_code_map(&move_stdlib::move_stdlib_errmap_full_path()); - }); } } diff --git a/external-crates/move/crates/move-stdlib/src/tests.rs b/external-crates/move/crates/move-stdlib/src/tests.rs index c89e6392e6d7ef..cdb122311809e1 100644 --- a/external-crates/move/crates/move-stdlib/src/tests.rs +++ b/external-crates/move/crates/move-stdlib/src/tests.rs @@ -21,21 +21,6 @@ fn check_that_docs_are_updated() { ) } -#[test] -fn check_that_the_errmap_is_updated() { - let temp_file = tempfile::NamedTempFile::new().unwrap(); - - crate::build_error_code_map(&temp_file.path().to_string_lossy()); - - assert!( - file_diff::diff( - &temp_file.path().to_string_lossy(), - &crate::move_stdlib_errmap_full_path() - ), - "Generated errmap differ from the one checked in" - ); -} - fn check_dirs_not_diff, B: AsRef>( actual: A, expected: B,