From 7ea0e914625789e65b0d5908f7f0b76a9fd32652 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Thu, 25 Apr 2024 14:41:47 +0100 Subject: [PATCH] chore: rework workspace structure for utils crates (#4886) # Description ## Problem\* Resolves ## Summary\* This PR flattens a layer of nesting from our crate structure. I've renamed `arena` to `noirc_arena` so we can publish to crates.io in the future. ## 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. --- Cargo.lock | 10 +++++----- Cargo.toml | 14 ++++++++------ compiler/{utils/arena => noirc_arena}/Cargo.toml | 2 +- compiler/{utils/arena => noirc_arena}/src/lib.rs | 0 compiler/noirc_frontend/Cargo.toml | 2 +- compiler/noirc_frontend/src/hir/def_map/mod.rs | 2 +- compiler/noirc_frontend/src/hir/type_check/mod.rs | 4 ++-- compiler/noirc_frontend/src/node_interner.rs | 2 +- compiler/noirc_frontend/src/resolve_locations.rs | 2 +- compiler/noirc_frontend/src/tests.rs | 2 +- {compiler/utils => utils}/iter-extended/Cargo.toml | 0 {compiler/utils => utils}/iter-extended/src/lib.rs | 0 12 files changed, 21 insertions(+), 19 deletions(-) rename compiler/{utils/arena => noirc_arena}/Cargo.toml (86%) rename compiler/{utils/arena => noirc_arena}/src/lib.rs (100%) rename {compiler/utils => utils}/iter-extended/Cargo.toml (100%) rename {compiler/utils => utils}/iter-extended/src/lib.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 8a8ccfdbf8a..eaed1c08bec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -233,10 +233,6 @@ version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" -[[package]] -name = "arena" -version = "0.28.0" - [[package]] name = "ark-bls12-381" version = "0.4.0" @@ -3099,6 +3095,10 @@ dependencies = [ "wasm-bindgen-test", ] +[[package]] +name = "noirc_arena" +version = "0.28.0" + [[package]] name = "noirc_driver" version = "0.28.0" @@ -3160,7 +3160,6 @@ name = "noirc_frontend" version = "0.28.0" dependencies = [ "acvm", - "arena", "base64 0.21.2", "chumsky", "fm", @@ -3168,6 +3167,7 @@ dependencies = [ "iter-extended", "lalrpop", "lalrpop-util", + "noirc_arena", "noirc_errors", "noirc_printable_type", "petgraph", diff --git a/Cargo.toml b/Cargo.toml index 108d179b9ca..ed0aef0d35b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ members = [ # Aztec Macro crate for metaprogramming "aztec_macros", # Compiler crates + "compiler/noirc_arena", "compiler/noirc_evaluator", "compiler/noirc_frontend", "compiler/noirc_errors", @@ -11,10 +12,7 @@ members = [ "compiler/noirc_printable_type", "compiler/fm", "compiler/wasm", - # Utility crates used by the Noir compiler - "compiler/utils/arena", - "compiler/utils/iter-extended", - # Crates related to tooling built ontop of the Noir compiler + # Crates related to tooling built on top of the Noir compiler "tooling/backend_interface", "tooling/bb_abstraction_leaks", "tooling/lsp", @@ -35,6 +33,8 @@ members = [ "acvm-repo/brillig_vm", "acvm-repo/blackbox_solver", "acvm-repo/bn254_blackbox_solver", + # Utility crates + "utils/iter-extended", ] default-members = ["tooling/nargo_cli", "tooling/acvm_cli"] resolver = "2" @@ -61,9 +61,8 @@ acvm_blackbox_solver = { version = "0.44.0", path = "acvm-repo/blackbox_solver", bn254_blackbox_solver = { version = "0.44.0", path = "acvm-repo/bn254_blackbox_solver", default-features = false } # Noir compiler workspace dependencies -arena = { path = "compiler/utils/arena" } fm = { path = "compiler/fm" } -iter-extended = { path = "compiler/utils/iter-extended" } +noirc_arena = { path = "compiler/noirc_arena" } noirc_driver = { path = "compiler/noirc_driver" } noirc_errors = { path = "compiler/noirc_errors" } noirc_evaluator = { path = "compiler/noirc_evaluator" } @@ -80,6 +79,9 @@ noirc_abi = { path = "tooling/noirc_abi" } bb_abstraction_leaks = { path = "tooling/bb_abstraction_leaks" } acvm_cli = { path = "tooling/acvm_cli" } +# Misc utils crates +iter-extended = { path = "utils/iter-extended" } + # LSP async-lsp = { version = "0.1.0", default-features = false } lsp-types = "0.94.1" diff --git a/compiler/utils/arena/Cargo.toml b/compiler/noirc_arena/Cargo.toml similarity index 86% rename from compiler/utils/arena/Cargo.toml rename to compiler/noirc_arena/Cargo.toml index f6bd764ee62..b94f997b7b9 100644 --- a/compiler/utils/arena/Cargo.toml +++ b/compiler/noirc_arena/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "arena" +name = "noirc_arena" version.workspace = true authors.workspace = true edition.workspace = true diff --git a/compiler/utils/arena/src/lib.rs b/compiler/noirc_arena/src/lib.rs similarity index 100% rename from compiler/utils/arena/src/lib.rs rename to compiler/noirc_arena/src/lib.rs diff --git a/compiler/noirc_frontend/Cargo.toml b/compiler/noirc_frontend/Cargo.toml index 84c9393fa37..0430d214d53 100644 --- a/compiler/noirc_frontend/Cargo.toml +++ b/compiler/noirc_frontend/Cargo.toml @@ -10,10 +10,10 @@ license.workspace = true [dependencies] acvm.workspace = true +noirc_arena.workspace = true noirc_errors.workspace = true noirc_printable_type.workspace = true fm.workspace = true -arena.workspace = true iter-extended.workspace = true chumsky.workspace = true thiserror.workspace = true diff --git a/compiler/noirc_frontend/src/hir/def_map/mod.rs b/compiler/noirc_frontend/src/hir/def_map/mod.rs index 7c0090ff95b..590c2e3d6b6 100644 --- a/compiler/noirc_frontend/src/hir/def_map/mod.rs +++ b/compiler/noirc_frontend/src/hir/def_map/mod.rs @@ -5,8 +5,8 @@ use crate::macros_api::MacroProcessor; use crate::node_interner::{FuncId, GlobalId, NodeInterner, StructId}; use crate::parser::{parse_program, ParsedModule, ParserError}; use crate::token::{FunctionAttribute, SecondaryAttribute, TestScope}; -use arena::{Arena, Index}; use fm::{FileId, FileManager}; +use noirc_arena::{Arena, Index}; use noirc_errors::Location; use std::collections::{BTreeMap, HashMap}; mod module_def; diff --git a/compiler/noirc_frontend/src/hir/type_check/mod.rs b/compiler/noirc_frontend/src/hir/type_check/mod.rs index 44dab6dee3d..2a1ff1dd42c 100644 --- a/compiler/noirc_frontend/src/hir/type_check/mod.rs +++ b/compiler/noirc_frontend/src/hir/type_check/mod.rs @@ -672,7 +672,7 @@ pub mod test { } fn local_module_id(&self) -> LocalModuleId { - LocalModuleId(arena::Index::unsafe_zeroed()) + LocalModuleId(noirc_arena::Index::unsafe_zeroed()) } fn module_id(&self) -> ModuleId { @@ -724,7 +724,7 @@ pub mod test { let mut def_maps = BTreeMap::new(); let file = FileId::default(); - let mut modules = arena::Arena::default(); + let mut modules = noirc_arena::Arena::default(); let location = Location::new(Default::default(), file); modules.insert(ModuleData::new(None, location, false)); diff --git a/compiler/noirc_frontend/src/node_interner.rs b/compiler/noirc_frontend/src/node_interner.rs index 9d3a79820dc..5e4fa3df6c5 100644 --- a/compiler/noirc_frontend/src/node_interner.rs +++ b/compiler/noirc_frontend/src/node_interner.rs @@ -2,9 +2,9 @@ use std::borrow::Cow; use std::collections::HashMap; use std::ops::Deref; -use arena::{Arena, Index}; use fm::FileId; use iter_extended::vecmap; +use noirc_arena::{Arena, Index}; use noirc_errors::{Location, Span, Spanned}; use petgraph::algo::tarjan_scc; use petgraph::prelude::DiGraph; diff --git a/compiler/noirc_frontend/src/resolve_locations.rs b/compiler/noirc_frontend/src/resolve_locations.rs index b5f1b1d0c64..ac8c96a092e 100644 --- a/compiler/noirc_frontend/src/resolve_locations.rs +++ b/compiler/noirc_frontend/src/resolve_locations.rs @@ -1,4 +1,4 @@ -use arena::Index; +use noirc_arena::Index; use noirc_errors::Location; use crate::hir_def::expr::HirExpression; diff --git a/compiler/noirc_frontend/src/tests.rs b/compiler/noirc_frontend/src/tests.rs index 31bf2245b1f..c6cef568ed8 100644 --- a/compiler/noirc_frontend/src/tests.rs +++ b/compiler/noirc_frontend/src/tests.rs @@ -31,8 +31,8 @@ mod test { hir::def_map::{CrateDefMap, LocalModuleId}, parse_program, }; - use arena::Arena; use fm::FileManager; + use noirc_arena::Arena; pub(crate) fn has_parser_error(errors: &[(CompilationError, FileId)]) -> bool { errors.iter().any(|(e, _f)| matches!(e, CompilationError::ParseError(_))) diff --git a/compiler/utils/iter-extended/Cargo.toml b/utils/iter-extended/Cargo.toml similarity index 100% rename from compiler/utils/iter-extended/Cargo.toml rename to utils/iter-extended/Cargo.toml diff --git a/compiler/utils/iter-extended/src/lib.rs b/utils/iter-extended/src/lib.rs similarity index 100% rename from compiler/utils/iter-extended/src/lib.rs rename to utils/iter-extended/src/lib.rs