diff --git a/crates/noirc_frontend/src/hir/def_map/mod.rs b/crates/noirc_frontend/src/hir/def_map/mod.rs index 25e0488a7b6..fdaf2dd3acc 100644 --- a/crates/noirc_frontend/src/hir/def_map/mod.rs +++ b/crates/noirc_frontend/src/hir/def_map/mod.rs @@ -18,6 +18,9 @@ pub use module_data::*; mod namespace; pub use namespace::*; +/// The name that is used for a non-contract program's entry-point function. +pub const MAIN_FUNCTION: &str = "main"; + // XXX: Ultimately, we want to constrain an index to be of a certain type just like in RA /// Lets first check if this is offered by any external crate /// XXX: RA has made this a crate on crates.io @@ -104,8 +107,6 @@ impl CrateDefMap { /// Find the main function for this crate pub fn main_function(&self) -> Option { - const MAIN_FUNCTION: &str = "main"; - let root_module = &self.modules()[self.root.0]; // This function accepts an Ident, so we attach a dummy span to diff --git a/crates/noirc_frontend/src/hir/resolution/resolver.rs b/crates/noirc_frontend/src/hir/resolution/resolver.rs index ebc67b6181a..daee5ee426f 100644 --- a/crates/noirc_frontend/src/hir/resolution/resolver.rs +++ b/crates/noirc_frontend/src/hir/resolution/resolver.rs @@ -22,7 +22,7 @@ use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use std::rc::Rc; use crate::graph::CrateId; -use crate::hir::def_map::{ModuleDefId, TryFromModuleDefId}; +use crate::hir::def_map::{ModuleDefId, TryFromModuleDefId, MAIN_FUNCTION}; use crate::hir_def::stmt::{HirAssignStatement, HirLValue, HirPattern}; use crate::node_interner::{ DefinitionId, DefinitionKind, ExprId, FuncId, NodeInterner, StmtId, StructId, @@ -677,7 +677,7 @@ impl<'a> Resolver<'a> { if self.in_contract() { !func.def.is_unconstrained && !func.def.is_open } else { - func.name() == "main" + func.name() == MAIN_FUNCTION } } @@ -688,7 +688,7 @@ impl<'a> Resolver<'a> { // witness indices in their abis is not a concern. !func.def.is_unconstrained && !func.def.is_open } else { - func.name() == "main" + func.name() == MAIN_FUNCTION } }