Skip to content

Commit

Permalink
chore: reexport CrateName through nargo (#6177)
Browse files Browse the repository at this point in the history
# Description

## Problem\*

Resolves <!-- Link to GitHub Issue -->

## Summary\*

Ideally `nargo_cli` would not need to directly hook into
`noirc_frontend` but a number of imports it needs are not reexported by
the packages which are supposed to be the entrypoints to the noir
compiler (`noirc_driver` and `nargo`). This PR tackles a couple of cases
of these issues.

## Additional Context



## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
TomAFrench authored Sep 30, 2024
1 parent a195442 commit 1ac980b
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 30 deletions.
2 changes: 1 addition & 1 deletion compiler/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use noirc_evaluator::create_program;
use noirc_evaluator::errors::RuntimeError;
use noirc_evaluator::ssa::SsaProgramArtifact;
use noirc_frontend::debug::build_debug_crate_file;
use noirc_frontend::graph::{CrateId, CrateName};
use noirc_frontend::hir::def_map::{Contract, CrateDefMap};
use noirc_frontend::hir::Context;
use noirc_frontend::monomorphization::{
Expand All @@ -35,6 +34,7 @@ use debug::filter_relevant_files;

pub use contract::{CompiledContract, CompiledContractOutputs, ContractFunction};
pub use debug::DebugFile;
pub use noirc_frontend::graph::{CrateId, CrateName};
pub use program::CompiledProgram;

const STD_CRATE_NAME: &str = "std";
Expand Down
2 changes: 1 addition & 1 deletion tooling/nargo/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use noirc_errors::{

pub use noirc_errors::Location;

use noirc_frontend::graph::CrateName;
use noirc_driver::CrateName;
use noirc_printable_type::ForeignCallError;
use thiserror::Error;

Expand Down
2 changes: 1 addition & 1 deletion tooling/nargo/src/package.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{collections::BTreeMap, fmt::Display, path::PathBuf};

use acvm::acir::circuit::ExpressionWidth;
use noirc_frontend::graph::CrateName;
pub use noirc_driver::CrateName;

use crate::constants::PROVER_INPUT_FILE;

Expand Down
14 changes: 7 additions & 7 deletions tooling/nargo_cli/src/cli/check_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ use clap::Args;
use fm::FileManager;
use iter_extended::btree_map;
use nargo::{
errors::CompileError, insert_all_files_for_workspace_into_file_manager, ops::report_errors,
package::Package, parse_all, prepare_package,
errors::CompileError,
insert_all_files_for_workspace_into_file_manager,
ops::report_errors,
package::{CrateName, Package},
parse_all, prepare_package,
};
use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection};
use noirc_abi::{AbiParameter, AbiType, MAIN_RETURN_NAME};
use noirc_driver::{
check_crate, compute_function_abi, CompileOptions, NOIR_ARTIFACT_VERSION_STRING,
};
use noirc_frontend::{
graph::{CrateId, CrateName},
hir::{Context, ParsedFiles},
check_crate, compute_function_abi, CompileOptions, CrateId, NOIR_ARTIFACT_VERSION_STRING,
};
use noirc_frontend::hir::{Context, ParsedFiles};

use super::fs::write_to_file;
use super::NargoConfig;
Expand Down
4 changes: 1 addition & 3 deletions tooling/nargo_cli/src/cli/compile_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ use std::time::Duration;
use acvm::acir::circuit::ExpressionWidth;
use fm::FileManager;
use nargo::ops::{collect_errors, compile_contract, compile_program, report_errors};
use nargo::package::Package;
use nargo::package::{CrateName, Package};
use nargo::workspace::Workspace;
use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all};
use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection};
use noirc_driver::DEFAULT_EXPRESSION_WIDTH;
use noirc_driver::NOIR_ARTIFACT_VERSION_STRING;
use noirc_driver::{CompilationResult, CompileOptions, CompiledContract};

use noirc_frontend::graph::CrateName;

use clap::Args;
use noirc_frontend::hir::ParsedFiles;
use notify::{EventKind, RecursiveMode, Watcher};
Expand Down
3 changes: 1 addition & 2 deletions tooling/nargo_cli/src/cli/debug_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use fm::FileManager;
use nargo::constants::PROVER_INPUT_FILE;
use nargo::errors::CompileError;
use nargo::ops::{compile_program, compile_program_with_debug_instrumenter, report_errors};
use nargo::package::Package;
use nargo::package::{CrateName, Package};
use nargo::workspace::Workspace;
use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all};
use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection};
Expand All @@ -19,7 +19,6 @@ use noirc_driver::{
file_manager_with_stdlib, CompileOptions, CompiledProgram, NOIR_ARTIFACT_VERSION_STRING,
};
use noirc_frontend::debug::DebugInstrumenter;
use noirc_frontend::graph::CrateName;
use noirc_frontend::hir::ParsedFiles;

use super::compile_cmd::get_target_width;
Expand Down
3 changes: 1 addition & 2 deletions tooling/nargo_cli/src/cli/execute_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ use clap::Args;
use nargo::constants::PROVER_INPUT_FILE;
use nargo::errors::try_to_diagnose_runtime_error;
use nargo::ops::DefaultForeignCallExecutor;
use nargo::package::Package;
use nargo::package::{CrateName, Package};
use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection};
use noirc_abi::input_parser::{Format, InputValue};
use noirc_abi::InputMap;
use noirc_artifacts::debug::DebugArtifact;
use noirc_driver::{CompileOptions, CompiledProgram, NOIR_ARTIFACT_VERSION_STRING};
use noirc_frontend::graph::CrateName;

use super::compile_cmd::compile_workspace_full;
use super::fs::{inputs::read_inputs_from_file, witness::save_witness_to_dir};
Expand Down
2 changes: 1 addition & 1 deletion tooling/nargo_cli/src/cli/fs/program.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::path::{Path, PathBuf};

use nargo::package::CrateName;
use noirc_artifacts::{contract::ContractArtifact, program::ProgramArtifact};
use noirc_frontend::graph::CrateName;

use crate::errors::FilesystemError;

Expand Down
3 changes: 1 addition & 2 deletions tooling/nargo_cli/src/cli/info_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ use std::collections::HashMap;
use acvm::acir::circuit::ExpressionWidth;
use clap::Args;
use iter_extended::vecmap;
use nargo::package::Package;
use nargo::package::{CrateName, Package};
use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection};
use noirc_artifacts::{debug::DebugArtifact, program::ProgramArtifact};
use noirc_driver::{CompileOptions, NOIR_ARTIFACT_VERSION_STRING};
use noirc_errors::{debug_info::OpCodesCount, Location};
use noirc_frontend::graph::CrateName;
use prettytable::{row, table, Row};
use rayon::prelude::*;
use serde::Serialize;
Expand Down
3 changes: 1 addition & 2 deletions tooling/nargo_cli/src/cli/init_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ use super::fs::{create_named_dir, write_to_file};
use super::NargoConfig;
use clap::Args;
use nargo::constants::{PKG_FILE, SRC_DIR};
use nargo::package::PackageType;
use nargo::package::{CrateName, PackageType};
use noirc_driver::NOIRC_VERSION;
use noirc_frontend::graph::CrateName;
use std::path::PathBuf;

/// Create a Noir project in the current directory.
Expand Down
3 changes: 1 addition & 2 deletions tooling/nargo_cli/src/cli/new_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use crate::errors::CliError;

use super::{init_cmd::initialize_project, NargoConfig};
use clap::Args;
use nargo::package::PackageType;
use noirc_frontend::graph::CrateName;
use nargo::package::{CrateName, PackageType};
use std::path::PathBuf;

/// Create a Noir project in a new directory.
Expand Down
11 changes: 5 additions & 6 deletions tooling/nargo_cli/src/cli/test_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ use bn254_blackbox_solver::Bn254BlackBoxSolver;
use clap::Args;
use fm::FileManager;
use nargo::{
insert_all_files_for_workspace_into_file_manager, ops::TestStatus, package::Package, parse_all,
prepare_package,
insert_all_files_for_workspace_into_file_manager,
ops::TestStatus,
package::{CrateName, Package},
parse_all, prepare_package,
};
use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection};
use noirc_driver::{check_crate, CompileOptions, NOIR_ARTIFACT_VERSION_STRING};
use noirc_frontend::{
graph::CrateName,
hir::{FunctionNameMatch, ParsedFiles},
};
use noirc_frontend::hir::{FunctionNameMatch, ParsedFiles};
use rayon::prelude::{IntoParallelIterator, ParallelBridge, ParallelIterator};
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};

Expand Down

0 comments on commit 1ac980b

Please sign in to comment.