From 4115d07484dba51054aa9775238572d7fa40cfcf Mon Sep 17 00:00:00 2001 From: f01dab1e Date: Thu, 5 Oct 2023 09:26:47 +0000 Subject: [PATCH] `Unordered` -> `SortedModule` --- .../src/hir/def_collector/dc_crate.rs | 4 +-- .../src/hir/def_collector/dc_mod.rs | 8 +++--- .../noirc_frontend/src/hir/def_map/mod.rs | 2 +- .../src/hir/resolution/resolver.rs | 4 +-- .../noirc_frontend/src/hir/type_check/mod.rs | 2 +- compiler/noirc_frontend/src/parser/mod.rs | 26 +++++++++---------- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs b/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs index 4444ab3f35c..ea8ada25cab 100644 --- a/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs +++ b/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs @@ -17,7 +17,7 @@ use crate::node_interner::{ FuncId, NodeInterner, StmtId, StructId, TraitId, TraitImplKey, TypeAliasId, }; -use crate::parser::{ParserError, UnorderParsedModule}; +use crate::parser::{ParserError, SortedModule}; use crate::{ ExpressionKind, Generics, Ident, LetStatement, Literal, NoirFunction, NoirStruct, NoirTrait, NoirTypeAlias, Path, Shared, StructType, TraitItem, Type, TypeBinding, TypeVariableKind, @@ -193,7 +193,7 @@ impl DefCollector { pub fn collect( mut def_map: CrateDefMap, context: &mut Context, - ast: UnorderParsedModule, + ast: SortedModule, root_file_id: FileId, ) -> Vec<(CompilationError, FileId)> { let mut errors: Vec<(CompilationError, FileId)> = vec![]; diff --git a/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs b/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs index 98b7d690b0a..b093a01a342 100644 --- a/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs +++ b/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs @@ -7,7 +7,7 @@ use crate::{ graph::CrateId, hir::def_collector::dc_crate::{UnresolvedStruct, UnresolvedTrait}, node_interner::TraitId, - parser::{SubModule, UnorderParsedModule}, + parser::{SubModule, SortedModule}, FunctionDefinition, Ident, LetStatement, NoirFunction, NoirStruct, NoirTrait, NoirTraitImpl, NoirTypeAlias, TraitImplItem, TraitItem, TypeImpl, }; @@ -35,7 +35,7 @@ struct ModCollector<'a> { /// This performs the entirety of the definition collection phase of the name resolution pass. pub fn collect_defs( def_collector: &mut DefCollector, - ast: UnorderParsedModule, + ast: SortedModule, file_id: FileId, module_id: LocalModuleId, crate_id: CrateId, @@ -404,7 +404,7 @@ impl<'a> ModCollector<'a> { Ok(child) => { errors.extend(collect_defs( self.def_collector, - submodule.contents.into_unorder(), + submodule.contents.into_sorted(), file_id, child, crate_id, @@ -462,7 +462,7 @@ impl<'a> ModCollector<'a> { // Parse the AST for the module we just found and then recursively look for it's defs let (ast, parsing_errors) = parse_file(&context.file_manager, child_file_id); - let ast = ast.into_unorder(); + let ast = ast.into_sorted(); errors.extend( parsing_errors.iter().map(|e| (e.clone().into(), child_file_id)).collect::>(), diff --git a/compiler/noirc_frontend/src/hir/def_map/mod.rs b/compiler/noirc_frontend/src/hir/def_map/mod.rs index 322fc6db1c5..dd98dfb4335 100644 --- a/compiler/noirc_frontend/src/hir/def_map/mod.rs +++ b/compiler/noirc_frontend/src/hir/def_map/mod.rs @@ -86,7 +86,7 @@ impl CrateDefMap { // First parse the root file. let root_file_id = context.crate_graph[crate_id].root_file_id; let (ast, parsing_errors) = parse_file(&context.file_manager, root_file_id); - let ast = ast.into_unorder(); + let ast = ast.into_sorted(); #[cfg(feature = "aztec")] let ast = match aztec_library::transform(ast, &crate_id, context) { diff --git a/compiler/noirc_frontend/src/hir/resolution/resolver.rs b/compiler/noirc_frontend/src/hir/resolution/resolver.rs index 56269f398b0..3af3ddd2363 100644 --- a/compiler/noirc_frontend/src/hir/resolution/resolver.rs +++ b/compiler/noirc_frontend/src/hir/resolution/resolver.rs @@ -1642,7 +1642,7 @@ mod test { } let mut errors = Vec::new(); - for func in program.into_unorder().functions { + for func in program.into_sorted().functions { let id = interner.push_test_function_definition(func.name().to_string()); let resolver = Resolver::new(&mut interner, &path_resolver, &def_maps, file); @@ -1658,7 +1658,7 @@ mod test { init_src_code_resolution(src); let mut all_captures: Vec> = Vec::new(); - for func in program.into_unorder().functions { + for func in program.into_sorted().functions { let name = func.name().to_string(); let id = interner.push_test_function_definition(name); path_resolver.insert_func(func.name().to_owned(), id); diff --git a/compiler/noirc_frontend/src/hir/type_check/mod.rs b/compiler/noirc_frontend/src/hir/type_check/mod.rs index 7a3e7972e06..0e288804f3f 100644 --- a/compiler/noirc_frontend/src/hir/type_check/mod.rs +++ b/compiler/noirc_frontend/src/hir/type_check/mod.rs @@ -446,7 +446,7 @@ mod test { }, ); - let func_meta = vecmap(program.into_unorder().functions, |nf| { + let func_meta = vecmap(program.into_sorted().functions, |nf| { let resolver = Resolver::new(&mut interner, &path_resolver, &def_maps, file); let (hir_func, func_meta, resolver_errors) = resolver.resolve_function(nf, main_id); assert_eq!(resolver_errors, vec![]); diff --git a/compiler/noirc_frontend/src/parser/mod.rs b/compiler/noirc_frontend/src/parser/mod.rs index 2b9b7eefb84..43bcace33d4 100644 --- a/compiler/noirc_frontend/src/parser/mod.rs +++ b/compiler/noirc_frontend/src/parser/mod.rs @@ -218,7 +218,7 @@ fn force<'a, T: 'a>(parser: impl NoirParser + 'a) -> impl NoirParser, pub functions: Vec, pub types: Vec, @@ -242,8 +242,8 @@ pub struct ParsedModule { } impl ParsedModule { - pub fn into_unorder(self) -> UnorderParsedModule { - let mut module = UnorderParsedModule::default(); + pub fn into_sorted(self) -> SortedModule { + let mut module = SortedModule::default(); for item in self.items { match item.kind { @@ -293,7 +293,7 @@ pub struct SubModule { pub is_contract: bool, } -impl UnorderParsedModule { +impl SortedModule { fn push_function(&mut self, func: NoirFunction) { self.functions.push(func); } @@ -539,37 +539,37 @@ impl std::fmt::Display for TopLevelStatement { impl std::fmt::Display for ParsedModule { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let legacy = self.clone().into_unorder(); + let module = self.clone().into_sorted(); - for decl in &legacy.module_decls { + for decl in &module.module_decls { writeln!(f, "mod {decl};")?; } - for import in &legacy.imports { + for import in &module.imports { write!(f, "{import}")?; } - for global_const in &legacy.globals { + for global_const in &module.globals { write!(f, "{global_const}")?; } - for type_ in &legacy.types { + for type_ in &module.types { write!(f, "{type_}")?; } - for function in &legacy.functions { + for function in &module.functions { write!(f, "{function}")?; } - for impl_ in &legacy.impls { + for impl_ in &module.impls { write!(f, "{impl_}")?; } - for type_alias in &legacy.type_aliases { + for type_alias in &module.type_aliases { write!(f, "{type_alias}")?; } - for submodule in &legacy.submodules { + for submodule in &module.submodules { write!(f, "{submodule}")?; }