diff --git a/crates/nargo/src/cli/compile_cmd.rs b/crates/nargo/src/cli/compile_cmd.rs index e4f318e33eb..941f0251166 100644 --- a/crates/nargo/src/cli/compile_cmd.rs +++ b/crates/nargo/src/cli/compile_cmd.rs @@ -62,9 +62,7 @@ pub fn compile_circuit>( let mut driver = Resolver::resolve_root_config(program_dir.as_ref(), backend.np_language())?; add_std_lib(&mut driver); - driver - .into_compiled_program(backend.np_language(), show_ssa, allow_warnings) - .map_err(|_| std::process::exit(1)) + driver.into_compiled_program(show_ssa, allow_warnings).map_err(|_| std::process::exit(1)) } fn preprocess_with_path>( diff --git a/crates/nargo/src/cli/test_cmd.rs b/crates/nargo/src/cli/test_cmd.rs index e4073132c49..3d0aa719691 100644 --- a/crates/nargo/src/cli/test_cmd.rs +++ b/crates/nargo/src/cli/test_cmd.rs @@ -91,10 +91,9 @@ fn run_test( show_output: bool, ) -> Result<(), CliError> { let backend = crate::backends::ConcreteBackend; - let language = backend.np_language(); let program = driver - .compile_no_check(language, false, allow_warnings, Some(main), show_output) + .compile_no_check(false, allow_warnings, Some(main), show_output) .map_err(|_| CliError::Generic(format!("Test '{test_name}' failed to compile")))?; let mut solved_witness = BTreeMap::new(); diff --git a/crates/noirc_driver/src/lib.rs b/crates/noirc_driver/src/lib.rs index a7e393705c9..2ba135abfab 100644 --- a/crates/noirc_driver/src/lib.rs +++ b/crates/noirc_driver/src/lib.rs @@ -16,6 +16,7 @@ use std::path::{Path, PathBuf}; pub struct Driver { context: Context, + language: Language, } #[derive(Debug, Serialize, Deserialize, Clone)] @@ -25,8 +26,8 @@ pub struct CompiledProgram { } impl Driver { - pub fn new(np_language: &acvm::Language) -> Self { - let mut driver = Driver { context: Context::default() }; + pub fn new(np_language: &Language) -> Self { + let mut driver = Driver { context: Context::default(), language: np_language.clone() }; driver.context.def_interner.set_language(np_language); driver } @@ -37,9 +38,7 @@ impl Driver { let mut driver = Driver::new(&np_language); driver.create_local_crate(root_file, CrateType::Binary); - driver - .into_compiled_program(np_language, false, false) - .unwrap_or_else(|_| std::process::exit(1)) + driver.into_compiled_program(false, false).unwrap_or_else(|_| std::process::exit(1)) } /// Compiles a file and returns true if compilation was successful @@ -146,19 +145,17 @@ impl Driver { pub fn into_compiled_program( mut self, - np_language: acvm::Language, show_ssa: bool, allow_warnings: bool, ) -> Result { self.check_crate(allow_warnings)?; - self.compile_no_check(np_language, show_ssa, allow_warnings, None, true) + self.compile_no_check(show_ssa, allow_warnings, None, true) } /// Compile the current crate. Assumes self.check_crate is called beforehand! #[allow(deprecated)] pub fn compile_no_check( &self, - np_language: acvm::Language, show_ssa: bool, allow_warnings: bool, // Optional override to provide a different `main` function to start execution @@ -183,6 +180,7 @@ impl Driver { let program = monomorphize(main_function, &self.context.def_interner); + let np_language = self.language.clone(); let blackbox_supported = acvm::default_is_black_box_supported(np_language.clone()); match create_circuit(program, np_language, blackbox_supported, show_ssa, show_output) { diff --git a/crates/noirc_driver/src/main.rs b/crates/noirc_driver/src/main.rs index 1ae9afe497a..e7f99ced95f 100644 --- a/crates/noirc_driver/src/main.rs +++ b/crates/noirc_driver/src/main.rs @@ -18,5 +18,5 @@ fn main() { driver.add_dep(LOCAL_CRATE, crate_id1, "coo4"); driver.add_dep(LOCAL_CRATE, crate_id2, "coo3"); - driver.into_compiled_program(acvm::Language::R1CS, false, false).ok(); + driver.into_compiled_program(false, false).ok(); }