Skip to content

Commit

Permalink
Remove optional GlobalId, use DefinitionKind, they should be the same
Browse files Browse the repository at this point in the history
  • Loading branch information
aakoshh committed Oct 11, 2024
1 parent 1d2bd36 commit 901c64a
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 15 deletions.
1 change: 0 additions & 1 deletion compiler/noirc_frontend/src/elaborator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,6 @@ impl<'context> Elaborator<'context> {
DefinitionKind::Local(None),
&mut parameter_idents,
true, // warn_if_unused
None,
);

parameters.push((pattern, typ.clone(), visibility));
Expand Down
14 changes: 2 additions & 12 deletions compiler/noirc_frontend/src/elaborator/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{
expr::{HirExpression, HirIdent, HirMethodReference, ImplKind, TraitMethod},
stmt::HirPattern,
},
node_interner::{DefinitionId, DefinitionKind, ExprId, FuncId, GlobalId, TraitImplKind},
node_interner::{DefinitionId, DefinitionKind, ExprId, FuncId, TraitImplKind},
Kind, ResolvedGeneric, Shared, StructType, Type, TypeBindings,
};

Expand All @@ -37,7 +37,6 @@ impl<'context> Elaborator<'context> {
None,
&mut Vec::new(),
warn_if_unused,
None,
)
}

Expand All @@ -50,7 +49,6 @@ impl<'context> Elaborator<'context> {
definition_kind: DefinitionKind,
created_ids: &mut Vec<HirIdent>,
warn_if_unused: bool,
global_id: Option<GlobalId>,
) -> HirPattern {
self.elaborate_pattern_mut(
pattern,
Expand All @@ -59,7 +57,6 @@ impl<'context> Elaborator<'context> {
None,
created_ids,
warn_if_unused,
global_id,
)
}

Expand All @@ -72,7 +69,6 @@ impl<'context> Elaborator<'context> {
mutable: Option<Span>,
new_definitions: &mut Vec<HirIdent>,
warn_if_unused: bool,
global_id: Option<GlobalId>,
) -> HirPattern {
match pattern {
Pattern::Identifier(name) => {
Expand All @@ -82,9 +78,7 @@ impl<'context> Elaborator<'context> {
(Some(_), DefinitionKind::Local(_)) => DefinitionKind::Local(None),
(_, other) => other,
};
let ident = if let Some(global_id) = global_id {
// Sanity check that we don't have conflicting globals.
assert_eq!(definition, DefinitionKind::Global(global_id));
let ident = if let DefinitionKind::Global(global_id) = definition {
// Globals don't need to be added to scope, they're already in the def_maps
let id = self.interner.get_global(global_id).definition_id;
let location = Location::new(name.span(), self.file);
Expand Down Expand Up @@ -114,7 +108,6 @@ impl<'context> Elaborator<'context> {
Some(span),
new_definitions,
warn_if_unused,
global_id,
);
let location = Location::new(span, self.file);
HirPattern::Mutable(Box::new(pattern), location)
Expand Down Expand Up @@ -146,7 +139,6 @@ impl<'context> Elaborator<'context> {
mutable,
new_definitions,
warn_if_unused,
global_id,
)
});
let location = Location::new(span, self.file);
Expand All @@ -170,7 +162,6 @@ impl<'context> Elaborator<'context> {
mutable,
new_definitions,
warn_if_unused,
global_id,
)
}
}
Expand Down Expand Up @@ -285,7 +276,6 @@ impl<'context> Elaborator<'context> {
mutable,
new_definitions,
true, // warn_if_unused
None,
);

if unseen_fields.contains(&field) {
Expand Down
1 change: 0 additions & 1 deletion compiler/noirc_frontend/src/elaborator/statements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ impl<'context> Elaborator<'context> {
definition,
&mut Vec::new(),
warn_if_unused,
global_id,
);

let attributes = let_stmt.attributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2462,7 +2462,6 @@ fn function_def_set_parameters(
DefinitionKind::Local(None),
&mut parameter_idents,
true, // warn_if_unused
None,
)
});

Expand Down

0 comments on commit 901c64a

Please sign in to comment.