Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove dependency on generational-arena #4207

Merged
merged 29 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f27b439
wip: remove dependency on generational-arena, add minimal vec-based a…
michaeljklein Jan 30, 2024
7f95c26
cargo fmt
michaeljklein Jan 30, 2024
648c00c
Merge branch 'master' into michaeljklein/vec-arena
michaeljklein Jan 30, 2024
f761a97
Merge branch 'master' into michaeljklein/vec-arena
michaeljklein Jan 30, 2024
da7e219
cargo clippy
michaeljklein Jan 30, 2024
f836981
revert warnings for unused crates
michaeljklein Jan 30, 2024
257ca9d
Merge branch 'master' into michaeljklein/vec-arena
michaeljklein Jan 30, 2024
10f161a
Merge branch 'master' into michaeljklein/vec-arena
michaeljklein Jan 30, 2024
9203fe5
rename ix -> index
michaeljklein Jan 30, 2024
ad7958e
Merge branch 'master' into michaeljklein/vec-arena
michaeljklein Jan 31, 2024
00531d2
make Index a tuple struct
michaeljklein Jan 31, 2024
b8098c8
Update compiler/noirc_frontend/src/hir/type_check/mod.rs
kevaundray Feb 1, 2024
d8581f4
Merge branch 'master' into michaeljklein/vec-arena
michaeljklein Feb 5, 2024
151a23c
added back generational_arena, added copy of generational_arena::{Are…
michaeljklein Feb 5, 2024
86d120e
wip debugging failing test
michaeljklein Feb 6, 2024
5d0a77b
Merge remote-tracking branch 'origin/master' into michaeljklein/vec-a…
kevaundray Feb 12, 2024
cd279cd
Fix compile errors from aztec_macros
jfecher Feb 12, 2024
ed62fd7
Fmt
jfecher Feb 12, 2024
e1aa513
Merge branch 'master' into michaeljklein/vec-arena
jfecher Feb 12, 2024
0f4f32d
Fix frontend test
jfecher Feb 12, 2024
ec1c5c4
Merge branch 'master' into michaeljklein/vec-arena
kevaundray Feb 13, 2024
948447c
Merge branch 'master' into michaeljklein/vec-arena
michaeljklein Feb 13, 2024
aa35b34
remove generational arena test stubs, indices, etc
michaeljklein Feb 13, 2024
9dbb84c
Merge branch 'master' into michaeljklein/vec-arena
michaeljklein Feb 13, 2024
68d7cb6
cargo fmt
michaeljklein Feb 13, 2024
b8d5b2e
Merge branch 'master' into michaeljklein/vec-arena
kevaundray Feb 15, 2024
e49fde4
fix: DefinitionIds should not be stored in id_to_type (#4397)
jfecher Feb 16, 2024
7885574
cleanup debugging, remove generational arena note from deny.toml
michaeljklein Feb 16, 2024
881373d
Merge branch 'master' into michaeljklein/vec-arena
michaeljklein Feb 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,10 @@ noirc_errors = { path = "compiler/noirc_errors" }
noirc_evaluator = { path = "compiler/noirc_evaluator" }
noirc_frontend = { path = "compiler/noirc_frontend" }
noirc_printable_type = { path = "compiler/noirc_printable_type" }
noir_wasm = { path = "compiler/wasm" }

# Noir tooling workspace dependencies
nargo = { path = "tooling/nargo" }
nargo_fmt = { path = "tooling/nargo_fmt" }
nargo_cli = { path = "tooling/nargo_cli" }
nargo_toml = { path = "tooling/nargo_toml" }
noir_lsp = { path = "tooling/lsp" }
noir_debugger = { path = "tooling/debugger" }
Expand All @@ -97,8 +95,6 @@ getrandom = "0.2"

# Debugger
dap = "0.4.1-alpha1"

cfg-if = "1.0.0"
clap = { version = "4.3.19", features = ["derive", "env"] }
codespan = { version = "0.11.1", features = ["serialization"] }
codespan-lsp = "0.11.1"
Expand Down
2 changes: 1 addition & 1 deletion aztec_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ fn collect_traits(context: &HirContext) -> Vec<TraitId> {
crates
.flat_map(|crate_id| context.def_map(&crate_id).map(|def_map| def_map.modules()))
.flatten()
.flat_map(|(_, module)| {
.flat_map(|module| {
module.type_definitions().filter_map(|typ| {
if let ModuleDefId::TraitId(struct_id) = typ {
Some(struct_id)
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/hir/def_map/item_scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub enum Visibility {
Public,
}

#[derive(Default, Debug, PartialEq, Eq)]
#[derive(Clone, Default, Debug, PartialEq, Eq)]
michaeljklein marked this conversation as resolved.
Show resolved Hide resolved
pub struct ItemScope {
types: HashMap<Ident, Scope>,
values: HashMap<Ident, Scope>,
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/hir/def_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct LocalModuleId(pub Index);

impl LocalModuleId {
pub fn dummy_id() -> LocalModuleId {
LocalModuleId(Index::from_raw_parts(std::usize::MAX, std::u64::MAX))
LocalModuleId(Index(std::usize::MAX))
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/hir/def_map/module_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use super::{ItemScope, LocalModuleId, ModuleDefId, ModuleId, PerNs};

/// Contains the actual contents of a module: its parent (if one exists),
/// children, and scope with all definitions defined within the scope.
#[derive(Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
michaeljklein marked this conversation as resolved.
Show resolved Hide resolved
pub struct ModuleData {
pub parent: Option<LocalModuleId>,
pub children: HashMap<Ident, LocalModuleId>,
Expand Down
4 changes: 2 additions & 2 deletions compiler/noirc_frontend/src/hir/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ mod test {
}

fn local_module_id(&self) -> LocalModuleId {
LocalModuleId(arena::Index::from_raw_parts(0, 0))
LocalModuleId(arena::Index(0, generational_arena::Index::from_raw_parts(0, 0)))
jfecher marked this conversation as resolved.
Show resolved Hide resolved
}

fn module_id(&self) -> ModuleId {
Expand Down Expand Up @@ -509,7 +509,7 @@ mod test {
let mut def_maps = BTreeMap::new();
let file = FileId::default();

let mut modules = arena::Arena::new();
let mut modules = arena::Arena::default();
let location = Location::new(Default::default(), file);
modules.insert(ModuleData::new(None, location, false));

Expand Down
30 changes: 15 additions & 15 deletions compiler/noirc_frontend/src/hir_def/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use super::types::{StructType, Type};
/// references other HIR nodes indirectly via IDs rather than directly via
/// boxing. Variables in HirExpressions are tagged with their DefinitionId
/// from the definition that refers to them so there is no ambiguity with names.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub enum HirExpression {
Ident(HirIdent),
Literal(HirLiteral),
Expand Down Expand Up @@ -109,7 +109,7 @@ impl HirBinaryOp {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub enum HirLiteral {
Array(HirArrayLiteral),
Bool(bool),
Expand All @@ -119,19 +119,19 @@ pub enum HirLiteral {
Unit,
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub enum HirArrayLiteral {
Standard(Vec<ExprId>),
Repeated { repeated_element: ExprId, length: Type },
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct HirPrefixExpression {
pub operator: UnaryOp,
pub rhs: ExprId,
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct HirInfixExpression {
pub lhs: ExprId,
pub operator: HirBinaryOp,
Expand All @@ -146,7 +146,7 @@ pub struct HirInfixExpression {

/// This is always a struct field access `my_struct.field`
/// and never a method call. The later is represented by HirMethodCallExpression.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct HirMemberAccess {
pub lhs: ExprId,
// This field is not an IdentId since the rhs of a field
Expand All @@ -160,21 +160,21 @@ pub struct HirMemberAccess {
pub is_offset: bool,
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct HirIfExpression {
pub condition: ExprId,
pub consequence: ExprId,
pub alternative: Option<ExprId>,
}

// `lhs as type` in the source code
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct HirCastExpression {
pub lhs: ExprId,
pub r#type: Type,
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct HirCallExpression {
pub func: ExprId,
pub arguments: Vec<ExprId>,
Expand All @@ -185,7 +185,7 @@ pub struct HirCallExpression {
/// lowered into HirCallExpression nodes
/// after type checking resolves the object
/// type and the method it calls.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct HirMethodCallExpression {
pub method: Ident,
pub object: ExprId,
Expand Down Expand Up @@ -239,7 +239,7 @@ impl HirMethodCallExpression {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct HirConstructorExpression {
pub r#type: Shared<StructType>,
pub struct_generics: Vec<Type>,
Expand All @@ -253,13 +253,13 @@ pub struct HirConstructorExpression {
}

/// Indexing, as in `array[index]`
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct HirIndexExpression {
pub collection: ExprId,
pub index: ExprId,
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct HirBlockExpression(pub Vec<StmtId>);

impl HirBlockExpression {
Expand All @@ -269,7 +269,7 @@ impl HirBlockExpression {
}

/// A variable captured inside a closure
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct HirCapturedVar {
pub ident: HirIdent,

Expand All @@ -283,7 +283,7 @@ pub struct HirCapturedVar {
pub transitive_capture_index: Option<usize>,
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct HirLambda {
pub parameters: Vec<(HirPattern, Type)>,
pub return_type: Type,
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/hir_def/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{Distinctness, FunctionReturnType, Type, Visibility};

/// A Hir function is a block expression
/// with a list of statements
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct HirFunction(ExprId);

impl HirFunction {
Expand Down
12 changes: 6 additions & 6 deletions compiler/noirc_frontend/src/hir_def/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use noirc_errors::{Location, Span};
/// the Statement AST node. Unlike the AST node, any nested nodes
/// are referred to indirectly via ExprId or StmtId, which can be
/// used to retrieve the relevant node via the NodeInterner.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub enum HirStatement {
Let(HirLetStatement),
Constrain(HirConstrainStatement),
Expand All @@ -19,7 +19,7 @@ pub enum HirStatement {
Error,
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
michaeljklein marked this conversation as resolved.
Show resolved Hide resolved
pub struct HirLetStatement {
pub pattern: HirPattern,
pub r#type: Type,
Expand All @@ -35,7 +35,7 @@ impl HirLetStatement {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct HirForStatement {
pub identifier: HirIdent,
pub start_range: ExprId,
Expand All @@ -44,7 +44,7 @@ pub struct HirForStatement {
}

/// Corresponds to `lvalue = expression;` in the source code
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct HirAssignStatement {
pub lvalue: HirLValue,
pub expression: ExprId,
Expand All @@ -54,10 +54,10 @@ pub struct HirAssignStatement {
/// This node also contains the FileId of the file the constrain
/// originates from. This is used later in the SSA pass to issue
/// an error if a constrain is found to be always false.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct HirConstrainStatement(pub ExprId, pub FileId, pub Option<ExprId>);

#[derive(Debug, Clone, Hash)]
#[derive(Debug, Clone, Hash, PartialEq)]
pub enum HirPattern {
Identifier(HirIdent),
Mutable(Box<HirPattern>, Location),
Expand Down
12 changes: 6 additions & 6 deletions compiler/noirc_frontend/src/node_interner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ impl DefinitionId {

impl From<DefinitionId> for Index {
fn from(id: DefinitionId) -> Self {
Index::from_raw_parts(id.0, u64::MAX)
jfecher marked this conversation as resolved.
Show resolved Hide resolved
Index(id.0)
}
}

Expand All @@ -302,7 +302,7 @@ impl StmtId {
// This can be anything, as the program will ultimately fail
// after resolution
pub fn dummy_id() -> StmtId {
StmtId(Index::from_raw_parts(std::usize::MAX, 0))
StmtId(Index(std::usize::MAX))
}
}

Expand All @@ -311,7 +311,7 @@ pub struct ExprId(Index);

impl ExprId {
pub fn empty_block_id() -> ExprId {
ExprId(Index::from_raw_parts(0, 0))
ExprId(Index(0))
}
}
#[derive(Debug, Eq, PartialEq, Hash, Copy, Clone)]
Expand All @@ -322,7 +322,7 @@ impl FuncId {
// This can be anything, as the program will ultimately fail
// after resolution
pub fn dummy_id() -> FuncId {
FuncId(Index::from_raw_parts(std::usize::MAX, 0))
FuncId(Index(std::usize::MAX))
}
}

Expand Down Expand Up @@ -400,7 +400,7 @@ macro_rules! partialeq {
($id_type:ty) => {
impl PartialEq<usize> for &$id_type {
fn eq(&self, other: &usize) -> bool {
let (index, _) = self.0.into_raw_parts();
let index = self.0 .0;
index == *other
}
}
Expand All @@ -417,7 +417,7 @@ partialeq!(StmtId);
/// We use one Arena for all types that can be interned as that has better cache locality
/// This data structure is never accessed directly, so API wise there is no difference between using
/// Multiple arenas and a single Arena
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub(crate) enum Node {
Function(HirFunction),
Statement(HirStatement),
Expand Down
5 changes: 0 additions & 5 deletions compiler/utils/arena/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,3 @@ version.workspace = true
authors.workspace = true
edition.workspace = true
license.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
generational-arena = "0.2.8"
Loading
Loading