From 5a1625e4863907a0f723560675c034699b78bef5 Mon Sep 17 00:00:00 2001 From: Ana Perez Ghiglia Date: Mon, 29 Jul 2024 18:49:46 -0300 Subject: [PATCH] Remove unused imports --- tooling/nargo_cli/src/cli/dap_cmd.rs | 20 +++++++++---------- tooling/nargo_cli/src/cli/debug_cmd.rs | 9 ++++----- .../nargo_cli/src/cli/execution_helpers.rs | 10 ++++++---- tooling/nargo_cli/src/cli/test_cmd.rs | 18 ++++++++--------- 4 files changed, 28 insertions(+), 29 deletions(-) diff --git a/tooling/nargo_cli/src/cli/dap_cmd.rs b/tooling/nargo_cli/src/cli/dap_cmd.rs index 9aa17dc9051..26e3abf2065 100644 --- a/tooling/nargo_cli/src/cli/dap_cmd.rs +++ b/tooling/nargo_cli/src/cli/dap_cmd.rs @@ -4,14 +4,11 @@ use acvm::FieldElement; use bn254_blackbox_solver::Bn254BlackBoxSolver; use clap::Args; use nargo::constants::PROVER_INPUT_FILE; +use nargo::package::Package; use nargo::workspace::Workspace; -use nargo::{insert_all_files_for_workspace_into_file_manager, package::Package, parse_all}; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_abi::input_parser::Format; -use noirc_driver::{ - check_crate, file_manager_with_stdlib, CompileOptions, CompiledProgram, - NOIR_ARTIFACT_VERSION_STRING, -}; +use noirc_driver::{check_crate, CompileOptions, CompiledProgram, NOIR_ARTIFACT_VERSION_STRING}; use noirc_frontend::{graph::CrateName, hir::FunctionNameMatch}; use std::io::{BufReader, BufWriter, Read, Write}; @@ -125,11 +122,11 @@ fn load_and_compile_project( compile_options_for_debugging(acir_mode, skip_instrumentation, CompileOptions::default()); let compiled_program = match test_name { - Some(test_name) => load_and_compile_test_function(test_name, workspace, &package, &compile_options)?, - None => { - compile_bin_package_for_debugging(&workspace, &package, &compile_options) - .map_err(|_| LoadError::Generic("Failed to compile project".into()))? - }, + Some(test_name) => { + load_and_compile_test_function(test_name, workspace, &package, &compile_options)? + } + None => compile_bin_package_for_debugging(&workspace, &package, &compile_options) + .map_err(|_| LoadError::Generic("Failed to compile project".into()))?, }; let compiled_program = nargo::ops::transform_program(compiled_program, expression_width); @@ -152,7 +149,8 @@ fn load_and_compile_test_function( package: &Package, compile_options: &CompileOptions, ) -> Result { - let (workspace_file_manager, mut parsed_files) = file_manager_and_files_from(&workspace.root_dir, &workspace); + let (workspace_file_manager, mut parsed_files) = + file_manager_and_files_from(&workspace.root_dir, &workspace); let test_functions = get_tests_in_package( &workspace_file_manager, diff --git a/tooling/nargo_cli/src/cli/debug_cmd.rs b/tooling/nargo_cli/src/cli/debug_cmd.rs index 33880e37e8b..854e76cd9d1 100644 --- a/tooling/nargo_cli/src/cli/debug_cmd.rs +++ b/tooling/nargo_cli/src/cli/debug_cmd.rs @@ -10,14 +10,12 @@ use nargo::errors::CompileError; use nargo::ops::{compile_program, compile_program_with_debug_instrumenter, report_errors}; use nargo::package::Package; use nargo::workspace::Workspace; -use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all, NargoError}; +use nargo::NargoError; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_abi::input_parser::{Format, InputValue}; use noirc_abi::Abi; -use noirc_driver::{ - file_manager_with_stdlib, CompileOptions, CompiledProgram, NOIR_ARTIFACT_VERSION_STRING, -}; +use noirc_driver::{CompileOptions, CompiledProgram, NOIR_ARTIFACT_VERSION_STRING}; use noirc_frontend::graph::CrateName; use super::compile_cmd::get_target_width; @@ -101,7 +99,8 @@ pub(crate) fn compile_bin_package_for_debugging( package: &Package, compile_options: &CompileOptions, ) -> Result { - let (workspace_file_manager, mut parsed_files) = file_manager_and_files_from(std::path::Path::new(""), workspace); + let (workspace_file_manager, mut parsed_files) = + file_manager_and_files_from(std::path::Path::new(""), workspace); let compilation_result = if compile_options.instrument_debug { let debug_state = diff --git a/tooling/nargo_cli/src/cli/execution_helpers.rs b/tooling/nargo_cli/src/cli/execution_helpers.rs index 3fb84d14b4e..e125ac8bd84 100644 --- a/tooling/nargo_cli/src/cli/execution_helpers.rs +++ b/tooling/nargo_cli/src/cli/execution_helpers.rs @@ -1,6 +1,6 @@ -use fm::{FileId, FileManager}; -use nargo::{package::Package, workspace::Workspace}; +use fm::FileManager; use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all, prepare_package}; +use nargo::{package::Package, workspace::Workspace}; use noirc_driver::{file_manager_with_stdlib, link_to_debug_crate}; use noirc_frontend::{ debug::DebugInstrumenter, @@ -8,7 +8,6 @@ use noirc_frontend::{ hir::{Context, ParsedFiles}, }; -use std::collections::HashMap; use std::path::Path; pub(crate) fn prepare_package_for_debug<'a>( @@ -57,7 +56,10 @@ pub(crate) fn instrument_package_files( // TODO: should we create a type that englobe fileManager + parsed_files? // all functions that need file_manager needs parsed_files as well -pub(crate) fn file_manager_and_files_from(root: &Path, workspace: &Workspace) -> (FileManager, ParsedFiles) { +pub(crate) fn file_manager_and_files_from( + root: &Path, + workspace: &Workspace, +) -> (FileManager, ParsedFiles) { let mut workspace_file_manager = file_manager_with_stdlib(root); insert_all_files_for_workspace_into_file_manager(workspace, &mut workspace_file_manager); let parsed_files = parse_all(&workspace_file_manager); diff --git a/tooling/nargo_cli/src/cli/test_cmd.rs b/tooling/nargo_cli/src/cli/test_cmd.rs index 620d3a5a7c7..d677da2b637 100644 --- a/tooling/nargo_cli/src/cli/test_cmd.rs +++ b/tooling/nargo_cli/src/cli/test_cmd.rs @@ -5,15 +5,11 @@ use bn254_blackbox_solver::Bn254BlackBoxSolver; use clap::Args; use fm::FileManager; use nargo::{ - insert_all_files_for_workspace_into_file_manager, ops::test_status_program_compile_fail, - ops::test_status_program_compile_pass, ops::TestStatus, package::Package, parse_all, - prepare_package, + ops::test_status_program_compile_fail, ops::test_status_program_compile_pass, ops::TestStatus, + package::Package, prepare_package, }; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; -use noirc_driver::{ - check_crate, compile_no_check, file_manager_with_stdlib, CompileOptions, - NOIR_ARTIFACT_VERSION_STRING, -}; +use noirc_driver::{check_crate, compile_no_check, CompileOptions, NOIR_ARTIFACT_VERSION_STRING}; use noirc_frontend::{ graph::CrateName, hir::{def_map::TestFunction, Context, FunctionNameMatch, ParsedFiles}, @@ -23,7 +19,10 @@ use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; use crate::{cli::check_cmd::check_crate_and_report_errors, errors::CliError}; -use super::{execution_helpers::{file_manager_and_files_from, prepare_package_for_debug}, NargoConfig}; +use super::{ + execution_helpers::{file_manager_and_files_from, prepare_package_for_debug}, + NargoConfig, +}; /// Run the tests for this program #[derive(Debug, Clone, Args)] @@ -72,7 +71,8 @@ pub(crate) fn run(args: TestCommand, config: NargoConfig) -> Result<(), CliError )?; let debug_mode = args.debug; - let (workspace_file_manager, parsed_files) = file_manager_and_files_from(&workspace.root_dir, &workspace); + let (workspace_file_manager, parsed_files) = + file_manager_and_files_from(&workspace.root_dir, &workspace); let pattern = match &args.test_name { Some(name) => {