Skip to content

Commit

Permalink
Use has_export()
Browse files Browse the repository at this point in the history
  • Loading branch information
aakoshh committed Nov 26, 2024
1 parent fc7a1dd commit b1041a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
6 changes: 1 addition & 5 deletions compiler/noirc_frontend/src/hir/def_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,7 @@ impl CrateDefMap {
module.value_definitions().filter_map(|id| {
if let Some(func_id) = id.as_function() {
let attributes = interner.function_attributes(&func_id);
if attributes.secondary.contains(&SecondaryAttribute::Export) {
Some(func_id)
} else {
None
}
attributes.has_export().then_some(func_id)
} else {
None
}
Expand Down
12 changes: 6 additions & 6 deletions compiler/noirc_frontend/src/lexer/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ impl Attributes {
/// This is useful for finding out if we should compile a contract method
/// as an entry point or not.
pub fn has_contract_library_method(&self) -> bool {
self.has_secondary_attr(SecondaryAttribute::ContractLibraryMethod)
self.has_secondary_attr(&SecondaryAttribute::ContractLibraryMethod)
}

pub fn is_test_function(&self) -> bool {
Expand Down Expand Up @@ -716,21 +716,21 @@ impl Attributes {
}

pub fn has_varargs(&self) -> bool {
self.has_secondary_attr(SecondaryAttribute::Varargs)
self.has_secondary_attr(&SecondaryAttribute::Varargs)
}

pub fn has_use_callers_scope(&self) -> bool {
self.has_secondary_attr(SecondaryAttribute::UseCallersScope)
self.has_secondary_attr(&SecondaryAttribute::UseCallersScope)
}

/// True if the function is marked with an `#[export]` attribute.
pub fn has_export(&self) -> bool {
self.has_secondary_attr(SecondaryAttribute::Export)
self.has_secondary_attr(&SecondaryAttribute::Export)
}

/// Check if secondary attributes contain a specific instance.
fn has_secondary_attr(&self, attr: SecondaryAttribute) -> bool {
self.secondary.iter().any(|a| *a == attr)
pub fn has_secondary_attr(&self, attr: &SecondaryAttribute) -> bool {
self.secondary.contains(attr)
}
}

Expand Down

0 comments on commit b1041a1

Please sign in to comment.