From 2282f47e84654d3c3df174316681f7f027d7d836 Mon Sep 17 00:00:00 2001 From: Jake Fecher Date: Wed, 10 Jul 2024 12:41:45 -0500 Subject: [PATCH] Run macro processors in the elaborator --- .../src/hir/def_collector/dc_crate.rs | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 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 b474ccff0cc..0ad9ca0ec6e 100644 --- a/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs +++ b/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs @@ -412,17 +412,13 @@ impl DefCollector { } } - let handle_missing_file = |err| { - errors.push((CompilationError::DebugComptimeScopeNotFound(err), root_file_id)); - None - }; - let debug_comptime_in_file: Option = - debug_comptime_in_file.and_then(|debug_comptime_in_file| { - context - .file_manager - .find_by_path_suffix(debug_comptime_in_file) - .unwrap_or_else(handle_missing_file) - }); + let debug_comptime_in_file = debug_comptime_in_file.and_then(|debug_comptime_in_file| { + let file = context.file_manager.find_by_path_suffix(debug_comptime_in_file); + file.unwrap_or_else(|error| { + errors.push((CompilationError::DebugComptimeScopeNotFound(error), root_file_id)); + None + }) + }); if !use_legacy { let mut more_errors = Elaborator::elaborate( @@ -432,6 +428,14 @@ impl DefCollector { debug_comptime_in_file, ); errors.append(&mut more_errors); + + for macro_processor in macro_processors { + macro_processor.process_typed_ast(&crate_id, context).unwrap_or_else( + |(macro_err, file_id)| { + errors.push((macro_err.into(), file_id)); + }, + ); + } return errors; }