From fbaa63443989f566b8b3b56a1c925e50fe456ecc Mon Sep 17 00:00:00 2001 From: Aztec Bot <49558828+AztecBot@users.noreply.github.com> Date: Thu, 6 Mar 2025 20:10:27 -0500 Subject: [PATCH] feat: Sync from noir (#12556) Automated pull of development from the [noir](https://github.com/noir-lang/noir) programming language, a dependency of Aztec. BEGIN_COMMIT_OVERRIDE chore!: convert `TraitMethodNotInScope` to error (https://github.com/noir-lang/noir/pull/7427) chore: bump ring to address advisory (https://github.com/noir-lang/noir/pull/7619) chore: bump external pinned commits (https://github.com/noir-lang/noir/pull/7618) feat: relate errors to macro built-ins errors (https://github.com/noir-lang/noir/pull/7609) END_COMMIT_OVERRIDE --------- Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com> --- .noir-sync-commit | 2 +- noir/noir-repo/.github/benchmark_projects.yml | 2 +- noir/noir-repo/Cargo.lock | 8 +-- noir/noir-repo/EXTERNAL_NOIR_LIBRARIES.yml | 2 +- .../noirc_frontend/src/elaborator/comptime.rs | 67 ++++++++++--------- .../noirc_frontend/src/elaborator/mod.rs | 19 +++--- .../noirc_frontend/src/hir/comptime/errors.rs | 17 +++-- .../src/hir/comptime/interpreter.rs | 17 +++-- .../src/hir/comptime/interpreter/builtin.rs | 42 ++++++++---- .../src/hir/resolution/import.rs | 2 +- noir/noir-repo/deny.toml | 11 --- .../execution_success/derive/src/main.nr | 2 +- .../embedded_curve_ops/src/main.nr | 2 + .../src/main.nr | 5 +- .../traits_in_crates_1/crate1/src/lib.nr | 2 +- .../traits_in_crates_1/crate2/src/lib.nr | 4 +- .../traits_in_crates_1/src/main.nr | 2 + .../traits_in_crates_2/crate1/src/lib.nr | 2 +- .../traits_in_crates_2/crate2/src/lib.nr | 4 +- .../traits_in_crates_2/src/main.nr | 2 + .../tooling/nargo_cli/tests/stdlib-props.rs | 5 +- 21 files changed, 123 insertions(+), 96 deletions(-) diff --git a/.noir-sync-commit b/.noir-sync-commit index 2b7ca3cb79d..3f2fa4ddee6 100644 --- a/.noir-sync-commit +++ b/.noir-sync-commit @@ -1 +1 @@ -b3443c124b19a909bf9cb370b4e0ebc151bb6aa3 \ No newline at end of file +37be49fd081f33dc7256d23cee8ccc0719c50a82 \ No newline at end of file diff --git a/noir/noir-repo/.github/benchmark_projects.yml b/noir/noir-repo/.github/benchmark_projects.yml index 5d9266a2d1a..3e63a12ec02 100644 --- a/noir/noir-repo/.github/benchmark_projects.yml +++ b/noir/noir-repo/.github/benchmark_projects.yml @@ -1,4 +1,4 @@ -define: &AZ_COMMIT 3b981f9217f9b859bdfbcdba2f5c080392c98da6 +define: &AZ_COMMIT fd9f1458557f2d67bcf2d58ba4194e000f58600c projects: private-kernel-inner: repo: AztecProtocol/aztec-packages diff --git a/noir/noir-repo/Cargo.lock b/noir/noir-repo/Cargo.lock index ca3fe90ee5d..7a64f0ec49e 100644 --- a/noir/noir-repo/Cargo.lock +++ b/noir/noir-repo/Cargo.lock @@ -652,9 +652,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64ct" -version = "1.7.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c103cbbedac994e292597ab79342dbd5b306a362045095db54917d92a9fdfd92" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "binary-merge" @@ -4355,9 +4355,9 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.11" +version = "0.17.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da5349ae27d3887ca812fb375b45a4fbb36d8d12d2df394968cd86e35683fe73" +checksum = "ed9b823fa29b721a59671b41d6b06e66b29e0628e207e8b1c3ceeda701ec928d" dependencies = [ "cc", "cfg-if", diff --git a/noir/noir-repo/EXTERNAL_NOIR_LIBRARIES.yml b/noir/noir-repo/EXTERNAL_NOIR_LIBRARIES.yml index 1d86c3e5d5b..b4eece545a4 100644 --- a/noir/noir-repo/EXTERNAL_NOIR_LIBRARIES.yml +++ b/noir/noir-repo/EXTERNAL_NOIR_LIBRARIES.yml @@ -1,4 +1,4 @@ -define: &AZ_COMMIT 3b981f9217f9b859bdfbcdba2f5c080392c98da6 +define: &AZ_COMMIT fd9f1458557f2d67bcf2d58ba4194e000f58600c libraries: noir_check_shuffle: repo: noir-lang/noir_check_shuffle diff --git a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/comptime.rs b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/comptime.rs index 7091f7b261c..6c556d6781f 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/comptime.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/comptime.rs @@ -49,9 +49,10 @@ impl<'context> Elaborator<'context> { pub fn elaborate_item_from_comptime_in_function<'a, T>( &'a mut self, current_function: Option, + reason: Option, f: impl FnOnce(&mut Elaborator<'a>) -> T, ) -> T { - self.elaborate_item_from_comptime(f, |elaborator| { + self.elaborate_item_from_comptime(reason, f, |elaborator| { if let Some(function) = current_function { let meta = elaborator.interner.function_meta(&function); elaborator.current_item = Some(DependencyId::Function(function)); @@ -65,9 +66,10 @@ impl<'context> Elaborator<'context> { pub fn elaborate_item_from_comptime_in_module<'a, T>( &'a mut self, module: ModuleId, + reason: Option, f: impl FnOnce(&mut Elaborator<'a>) -> T, ) -> T { - self.elaborate_item_from_comptime(f, |elaborator| { + self.elaborate_item_from_comptime(reason, f, |elaborator| { elaborator.current_item = None; elaborator.crate_id = module.krate; elaborator.local_module = module.local_id; @@ -76,6 +78,7 @@ impl<'context> Elaborator<'context> { fn elaborate_item_from_comptime<'a, T>( &'a mut self, + reason: Option, f: impl FnOnce(&mut Elaborator<'a>) -> T, setup: impl FnOnce(&mut Elaborator<'a>), ) -> T { @@ -104,7 +107,14 @@ impl<'context> Elaborator<'context> { let result = f(&mut elaborator); elaborator.check_and_pop_function_context(); - self.errors.append(&mut elaborator.errors); + let mut errors = std::mem::take(&mut elaborator.errors); + if let Some(reason) = reason { + errors = vecmap(errors, |error| { + CompilationError::ComptimeError(reason.to_macro_error(error)) + }); + }; + + self.errors.extend(errors); result } @@ -342,14 +352,11 @@ impl<'context> Elaborator<'context> { generated_items: &mut CollectedItems, location: Location, ) { - let previous_errors = - self.push_elaborate_reason_and_take_errors(ElaborateReason::RunningAttribute, location); - - for item in items { - self.add_item(item, generated_items, location); - } - - self.pop_elaborate_reason(previous_errors); + self.with_elaborate_reason(ElaborateReason::RunningAttribute(location), |elaborator| { + for item in items { + elaborator.add_item(item, generated_items, location); + } + }); } pub(crate) fn add_item( @@ -558,14 +565,10 @@ impl<'context> Elaborator<'context> { }); if !generated_items.is_empty() { - let previous_errors = self.push_elaborate_reason_and_take_errors( - ElaborateReason::RunningAttribute, - location, - ); - - self.elaborate_items(generated_items); - - self.pop_elaborate_reason(previous_errors); + let reason = ElaborateReason::RunningAttribute(location); + self.with_elaborate_reason(reason, |elaborator| { + elaborator.elaborate_items(generated_items); + }); } } } @@ -652,24 +655,22 @@ impl<'context> Elaborator<'context> { } } - /// Pushes an ElaborateReason but also `std::mem::take`s the current errors and returns them. - pub(crate) fn push_elaborate_reason_and_take_errors( - &mut self, - reason: ElaborateReason, - location: Location, - ) -> Vec { - self.elaborate_reasons.push_back((reason, location)); - std::mem::take(&mut self.errors) - } + pub(crate) fn with_elaborate_reason(&mut self, reason: ElaborateReason, f: F) -> T + where + F: FnOnce(&mut Elaborator) -> T, + { + self.elaborate_reasons.push_back(reason); + let previous_errors = std::mem::take(&mut self.errors); + + let value = f(self); - /// Pops en ElaborateREason. Receives the errors that were returned by `push_elaborate_reason` - /// so they are restored, while also wrapping errors in the current Elaborator in a ComptimeError. - pub(crate) fn pop_elaborate_reason(&mut self, previous_errors: Vec) { let new_errors = std::mem::take(&mut self.errors); let new_errors = self.wrap_errors_in_macro_error(new_errors); self.errors = previous_errors; self.push_errors(new_errors); self.elaborate_reasons.pop_back(); + + value } fn wrap_errors_in_macro_error(&self, errors: Vec) -> Vec { @@ -677,8 +678,8 @@ impl<'context> Elaborator<'context> { } fn wrap_error_in_macro_error(&self, mut error: CompilationError) -> CompilationError { - for (reason, location) in self.elaborate_reasons.iter().rev() { - error = CompilationError::ComptimeError(reason.to_macro_error(error, *location)); + for reason in self.elaborate_reasons.iter().rev() { + error = CompilationError::ComptimeError(reason.to_macro_error(error)); } error } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/mod.rs b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/mod.rs index fccf99cc7ca..9600fc509cb 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/mod.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/mod.rs @@ -199,25 +199,26 @@ pub struct Elaborator<'context> { /// Sometimes items are elaborated because a function attribute ran and generated items. /// The Elaborator keeps track of these reasons so that when an error is produced it will /// be wrapped in another error that will include this reason. - pub(crate) elaborate_reasons: im::Vector<(ElaborateReason, Location)>, + pub(crate) elaborate_reasons: im::Vector, } #[derive(Copy, Clone)] pub enum ElaborateReason { /// A function attribute generated an item that's being elaborated. - RunningAttribute, - /// Evaluating `Module::add_item` - AddingItemToModule, + RunningAttribute(Location), + /// Evaluating a comptime call like `Module::add_item` + EvaluatingComptimeCall(&'static str, Location), } impl ElaborateReason { - fn to_macro_error(self, error: CompilationError, location: Location) -> ComptimeError { + fn to_macro_error(self, error: CompilationError) -> ComptimeError { match self { - ElaborateReason::RunningAttribute => { + ElaborateReason::RunningAttribute(location) => { ComptimeError::ErrorRunningAttribute { error: Box::new(error), location } } - ElaborateReason::AddingItemToModule => { - ComptimeError::ErrorAddingItemToModule { error: Box::new(error), location } + ElaborateReason::EvaluatingComptimeCall(method_name, location) => { + let error = Box::new(error); + ComptimeError::ErrorEvaluatingComptimeCall { method_name, error, location } } } } @@ -251,7 +252,7 @@ impl<'context> Elaborator<'context> { crate_id: CrateId, interpreter_call_stack: im::Vector, options: ElaboratorOptions<'context>, - elaborate_reasons: im::Vector<(ElaborateReason, Location)>, + elaborate_reasons: im::Vector, ) -> Self { Self { scopes: ScopeForest::default(), diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/errors.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/errors.rs index 27440069c02..52b50d54566 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/errors.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/errors.rs @@ -703,15 +703,22 @@ impl<'a> From<&'a InterpreterError> for CustomDiagnostic { /// comptime call or macro "something" that eventually led to that error. #[derive(Debug, Clone, PartialEq, Eq)] pub enum ComptimeError { - ErrorRunningAttribute { error: Box, location: Location }, - ErrorAddingItemToModule { error: Box, location: Location }, + ErrorRunningAttribute { + error: Box, + location: Location, + }, + ErrorEvaluatingComptimeCall { + method_name: &'static str, + error: Box, + location: Location, + }, } impl ComptimeError { pub fn location(&self) -> Location { match self { ComptimeError::ErrorRunningAttribute { location, .. } - | ComptimeError::ErrorAddingItemToModule { location, .. } => *location, + | ComptimeError::ErrorEvaluatingComptimeCall { location, .. } => *location, } } } @@ -724,9 +731,9 @@ impl<'a> From<&'a ComptimeError> for CustomDiagnostic { diagnostic.add_secondary("While running this function attribute".into(), *location); diagnostic } - ComptimeError::ErrorAddingItemToModule { error, location } => { + ComptimeError::ErrorEvaluatingComptimeCall { method_name, error, location } => { let mut diagnostic = CustomDiagnostic::from(&**error); - diagnostic.add_secondary("While interpreting `Module::add_item`".into(), *location); + diagnostic.add_secondary(format!("While evaluating `{method_name}`"), *location); diagnostic } } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter.rs index d5b830d257c..3e83c5f3fb9 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter.rs @@ -10,7 +10,7 @@ use rustc_hash::FxHashMap as HashMap; use crate::TypeVariable; use crate::ast::{BinaryOpKind, FunctionKind, IntegerBitSize, Signedness, UnaryOp}; -use crate::elaborator::Elaborator; +use crate::elaborator::{ElaborateReason, Elaborator}; use crate::graph::CrateId; use crate::hir::def_map::ModuleId; use crate::hir::type_check::TypeCheckError; @@ -191,7 +191,7 @@ impl<'local, 'interner> Interpreter<'local, 'interner> { Some(body) => Ok(body), None => { if matches!(&meta.function_body, FunctionBody::Unresolved(..)) { - self.elaborate_in_function(None, |elaborator| { + self.elaborate_in_function(None, None, |elaborator| { elaborator.elaborate_function(function); }); @@ -207,10 +207,11 @@ impl<'local, 'interner> Interpreter<'local, 'interner> { fn elaborate_in_function( &mut self, function: Option, + reason: Option, f: impl FnOnce(&mut Elaborator) -> T, ) -> T { self.unbind_generics_from_previous_function(); - let result = self.elaborator.elaborate_item_from_comptime_in_function(function, f); + let result = self.elaborator.elaborate_item_from_comptime_in_function(function, reason, f); self.rebind_generics_from_previous_function(); result } @@ -218,10 +219,11 @@ impl<'local, 'interner> Interpreter<'local, 'interner> { fn elaborate_in_module( &mut self, module: ModuleId, + reason: Option, f: impl FnOnce(&mut Elaborator) -> T, ) -> T { self.unbind_generics_from_previous_function(); - let result = self.elaborator.elaborate_item_from_comptime_in_module(module, f); + let result = self.elaborator.elaborate_item_from_comptime_in_module(module, reason, f); self.rebind_generics_from_previous_function(); result } @@ -1325,9 +1327,10 @@ impl<'local, 'interner> Interpreter<'local, 'interner> { let mut result = self.call_function(function_id, arguments, bindings, location)?; if call.is_macro_call { let expr = result.into_expression(self.elaborator, location)?; - let expr = self.elaborate_in_function(self.current_function, |elaborator| { - elaborator.elaborate_expression(expr).0 - }); + let expr = + self.elaborate_in_function(self.current_function, None, |elaborator| { + elaborator.elaborate_expression(expr).0 + }); result = self.evaluate(expr)?; // Macro calls are typed as type variables during type checking. diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs index 77ee9183ead..44b3265df31 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs @@ -836,8 +836,9 @@ fn quoted_as_module( parse(interpreter.elaborator, argument, Parser::parse_path_no_turbofish_or_error, "a path") .ok(); let option_value = path.and_then(|path| { - let module = interpreter - .elaborate_in_function(interpreter.current_function, |elaborator| { + let reason = Some(ElaborateReason::EvaluatingComptimeCall("Quoted::as_module", location)); + let module = + interpreter.elaborate_in_function(interpreter.current_function, reason, |elaborator| { elaborator.resolve_module_by_path(path) }); module.map(Value::ModuleDefinition) @@ -859,8 +860,10 @@ fn quoted_as_trait_constraint( Parser::parse_trait_bound_or_error, "a trait constraint", )?; + let reason = + Some(ElaborateReason::EvaluatingComptimeCall("Quoted::as_trait_constraint", location)); let bound = interpreter - .elaborate_in_function(interpreter.current_function, |elaborator| { + .elaborate_in_function(interpreter.current_function, reason, |elaborator| { elaborator.resolve_trait_bound(&trait_bound) }) .ok_or(InterpreterError::FailedToResolveTraitBound { trait_bound, location })?; @@ -876,8 +879,11 @@ fn quoted_as_type( ) -> IResult { let argument = check_one_argument(arguments, location)?; let typ = parse(interpreter.elaborator, argument, Parser::parse_type_or_error, "a type")?; - let typ = interpreter - .elaborate_in_function(interpreter.current_function, |elab| elab.resolve_type(typ)); + let reason = Some(ElaborateReason::EvaluatingComptimeCall("Quoted::as_type", location)); + let typ = + interpreter.elaborate_in_function(interpreter.current_function, reason, |elaborator| { + elaborator.resolve_type(typ) + }); Ok(Value::Type(typ)) } @@ -2299,7 +2305,9 @@ fn expr_resolve( interpreter.current_function }; - interpreter.elaborate_in_function(function_to_resolve_in, |elaborator| match expr_value { + let reason = Some(ElaborateReason::EvaluatingComptimeCall("Expr::resolve", location)); + interpreter.elaborate_in_function(function_to_resolve_in, reason, |elaborator| match expr_value + { ExprValue::Expression(expression_kind) => { let expr = Expression { kind: expression_kind, location: self_argument_location }; let (expr_id, _) = elaborator.elaborate_expression(expr); @@ -2452,7 +2460,14 @@ fn function_def_as_typed_expr( let hir_expr = HirExpression::Ident(hir_ident.clone(), generics.clone()); let expr_id = interpreter.elaborator.interner.push_expr(hir_expr); interpreter.elaborator.interner.push_expr_location(expr_id, location); - let typ = interpreter.elaborator.type_check_variable(hir_ident, expr_id, generics); + let reason = Some(ElaborateReason::EvaluatingComptimeCall( + "FunctionDefinition::as_typed_expr", + location, + )); + let typ = + interpreter.elaborate_in_function(interpreter.current_function, reason, |elaborator| { + elaborator.type_check_variable(hir_ident, expr_id, generics) + }); interpreter.elaborator.interner.push_expr_type(expr_id, typ); Ok(Value::TypedExpr(TypedExpr::ExprId(expr_id))) } @@ -2658,7 +2673,10 @@ fn function_def_set_parameters( "a pattern", )?; - let hir_pattern = interpreter.elaborate_in_function(Some(func_id), |elaborator| { + let reason = + ElaborateReason::EvaluatingComptimeCall("FunctionDefinition::set_parameters", location); + let reason = Some(reason); + let hir_pattern = interpreter.elaborate_in_function(Some(func_id), reason, |elaborator| { elaborator.elaborate_pattern_and_store_ids( parameter_pattern, parameter_type.clone(), @@ -2773,10 +2791,8 @@ fn module_add_item( let parser = Parser::parse_top_level_items; let top_level_statements = parse(interpreter.elaborator, item, parser, "a top-level item")?; - interpreter.elaborate_in_module(module_id, |elaborator| { - let previous_errors = elaborator - .push_elaborate_reason_and_take_errors(ElaborateReason::AddingItemToModule, location); - + let reason = Some(ElaborateReason::EvaluatingComptimeCall("Module::add_item", location)); + interpreter.elaborate_in_module(module_id, reason, |elaborator| { let mut generated_items = CollectedItems::default(); for top_level_statement in top_level_statements { @@ -2786,8 +2802,6 @@ fn module_add_item( if !generated_items.is_empty() { elaborator.elaborate_items(generated_items); } - - elaborator.pop_elaborate_reason(previous_errors); }); Ok(Value::Unit) diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/import.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/import.rs index 16e25b80465..14e0e5e5386 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/import.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/import.rs @@ -112,7 +112,7 @@ impl<'a> From<&'a PathResolutionError> for CustomDiagnostic { CustomDiagnostic::simple_error(error.to_string(), String::new(), ident.location()) } PathResolutionError::TraitMethodNotInScope { ident, .. } => { - CustomDiagnostic::simple_warning(error.to_string(), String::new(), ident.location()) + CustomDiagnostic::simple_error(error.to_string(), String::new(), ident.location()) } PathResolutionError::UnresolvedWithPossibleTraitsToImport { ident, traits } => { let mut traits = vecmap(traits, |trait_name| format!("`{}`", trait_name)); diff --git a/noir/noir-repo/deny.toml b/noir/noir-repo/deny.toml index 48628fb0045..c2ff9aee70e 100644 --- a/noir/noir-repo/deny.toml +++ b/noir/noir-repo/deny.toml @@ -7,8 +7,6 @@ yanked = "warn" ignore = [ "RUSTSEC-2024-0388", # derivative unmaintained - "RUSTSEC-2024-0384", # instant unmaintained - "RUSTSEC-2020-0016", # net2 unmaintained ] # This section is considered when running `cargo deny check bans`. @@ -49,7 +47,6 @@ allow = [ "BSD-3-Clause", "ISC", "0BSD", - "Unicode-DFS-2016", "Unicode-3.0", "Unlicense", "Zlib", @@ -65,20 +62,12 @@ exceptions = [ # CC0 is a permissive license but somewhat unclear status for source code # so we prefer to not have dependencies using it # https://tldrlegal.com/license/creative-commons-cc0-1.0-universal - { allow = ["CC0-1.0"], name = "more-asserts" }, { allow = ["CC0-1.0"], name = "notify" }, - { allow = ["CC0-1.0"], name = "tiny-keccak" }, { allow = ["MPL-2.0"], name = "sized-chunks" }, { allow = ["MPL-2.0"], name = "webpki-roots" }, { allow = ["CDDL-1.0"], name = "inferno" }, - { allow = ["OpenSSL"], name = "ring" }, ] -[[licenses.clarify]] -crate = "ring" -expression = "ISC" -license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }] - # This section is considered when running `cargo deny check sources`. # More documentation about the 'sources' section can be found here: # https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html diff --git a/noir/noir-repo/test_programs/execution_success/derive/src/main.nr b/noir/noir-repo/test_programs/execution_success/derive/src/main.nr index f7d4f6b607a..724c185737b 100644 --- a/noir/noir-repo/test_programs/execution_success/derive/src/main.nr +++ b/noir/noir-repo/test_programs/execution_success/derive/src/main.nr @@ -1,4 +1,4 @@ -use std::hash::Hash; +use std::hash::{Hash, Hasher}; #[derive_via(derive_do_nothing)] trait DoNothing { diff --git a/noir/noir-repo/test_programs/execution_success/embedded_curve_ops/src/main.nr b/noir/noir-repo/test_programs/execution_success/embedded_curve_ops/src/main.nr index 85cf60dc796..dcccdfd16fb 100644 --- a/noir/noir-repo/test_programs/execution_success/embedded_curve_ops/src/main.nr +++ b/noir/noir-repo/test_programs/execution_success/embedded_curve_ops/src/main.nr @@ -1,3 +1,5 @@ +use std::ops::Add; + fn main(priv_key: Field, pub_x: pub Field, pub_y: pub Field) { let g1_y = 17631683881184975370165255887551781615748388533673675138860; let g1 = std::embedded_curve_ops::EmbeddedCurvePoint { x: 1, y: g1_y, is_infinite: false }; diff --git a/noir/noir-repo/test_programs/execution_success/inline_decompose_hint_brillig_call/src/main.nr b/noir/noir-repo/test_programs/execution_success/inline_decompose_hint_brillig_call/src/main.nr index e500f0f976d..a5d57d0596d 100644 --- a/noir/noir-repo/test_programs/execution_success/inline_decompose_hint_brillig_call/src/main.nr +++ b/noir/noir-repo/test_programs/execution_success/inline_decompose_hint_brillig_call/src/main.nr @@ -1,4 +1,7 @@ -use std::embedded_curve_ops::{EmbeddedCurvePoint, EmbeddedCurveScalar, fixed_base_scalar_mul}; +use std::{ + embedded_curve_ops::{EmbeddedCurvePoint, EmbeddedCurveScalar, fixed_base_scalar_mul}, + ops::Add, +}; fn main() -> pub Field { let pre_address = 0x23d95e303879a5d0bbef78ecbc335e559da37431f6dcd11da54ed375c2846813; diff --git a/noir/noir-repo/test_programs/execution_success/traits_in_crates_1/crate1/src/lib.nr b/noir/noir-repo/test_programs/execution_success/traits_in_crates_1/crate1/src/lib.nr index e36a263093a..d472755e1fd 100644 --- a/noir/noir-repo/test_programs/execution_success/traits_in_crates_1/crate1/src/lib.nr +++ b/noir/noir-repo/test_programs/execution_success/traits_in_crates_1/crate1/src/lib.nr @@ -1,4 +1,4 @@ -trait MyTrait { +pub trait MyTrait { fn Add10(&mut self); } diff --git a/noir/noir-repo/test_programs/execution_success/traits_in_crates_1/crate2/src/lib.nr b/noir/noir-repo/test_programs/execution_success/traits_in_crates_1/crate2/src/lib.nr index c59bf0387c1..8f8df053f80 100644 --- a/noir/noir-repo/test_programs/execution_success/traits_in_crates_1/crate2/src/lib.nr +++ b/noir/noir-repo/test_programs/execution_success/traits_in_crates_1/crate2/src/lib.nr @@ -1,3 +1,3 @@ -struct MyStruct { - Q: Field, +pub struct MyStruct { + pub Q: Field, } diff --git a/noir/noir-repo/test_programs/execution_success/traits_in_crates_1/src/main.nr b/noir/noir-repo/test_programs/execution_success/traits_in_crates_1/src/main.nr index 2afec29ee1f..9f2768fc9bf 100644 --- a/noir/noir-repo/test_programs/execution_success/traits_in_crates_1/src/main.nr +++ b/noir/noir-repo/test_programs/execution_success/traits_in_crates_1/src/main.nr @@ -1,3 +1,5 @@ +use crate1::MyTrait; + fn main(x: Field, y: pub Field) { let mut V = crate2::MyStruct { Q: x }; V.Add10(); diff --git a/noir/noir-repo/test_programs/execution_success/traits_in_crates_2/crate1/src/lib.nr b/noir/noir-repo/test_programs/execution_success/traits_in_crates_2/crate1/src/lib.nr index 59a28a50c79..72cac406138 100644 --- a/noir/noir-repo/test_programs/execution_success/traits_in_crates_2/crate1/src/lib.nr +++ b/noir/noir-repo/test_programs/execution_success/traits_in_crates_2/crate1/src/lib.nr @@ -1,3 +1,3 @@ -trait MyTrait { +pub trait MyTrait { fn Add10(&mut self); } diff --git a/noir/noir-repo/test_programs/execution_success/traits_in_crates_2/crate2/src/lib.nr b/noir/noir-repo/test_programs/execution_success/traits_in_crates_2/crate2/src/lib.nr index fe6a94a4a95..e80ff59474f 100644 --- a/noir/noir-repo/test_programs/execution_success/traits_in_crates_2/crate2/src/lib.nr +++ b/noir/noir-repo/test_programs/execution_success/traits_in_crates_2/crate2/src/lib.nr @@ -1,5 +1,5 @@ -struct MyStruct { - Q: Field, +pub struct MyStruct { + pub Q: Field, } impl crate1::MyTrait for MyStruct { diff --git a/noir/noir-repo/test_programs/execution_success/traits_in_crates_2/src/main.nr b/noir/noir-repo/test_programs/execution_success/traits_in_crates_2/src/main.nr index 2afec29ee1f..9f2768fc9bf 100644 --- a/noir/noir-repo/test_programs/execution_success/traits_in_crates_2/src/main.nr +++ b/noir/noir-repo/test_programs/execution_success/traits_in_crates_2/src/main.nr @@ -1,3 +1,5 @@ +use crate1::MyTrait; + fn main(x: Field, y: pub Field) { let mut V = crate2::MyStruct { Q: x }; V.Add10(); diff --git a/noir/noir-repo/tooling/nargo_cli/tests/stdlib-props.rs b/noir/noir-repo/tooling/nargo_cli/tests/stdlib-props.rs index 7c3794d03ab..b00d50c8348 100644 --- a/noir/noir-repo/tooling/nargo_cli/tests/stdlib-props.rs +++ b/noir/noir-repo/tooling/nargo_cli/tests/stdlib-props.rs @@ -177,7 +177,10 @@ fn fuzz_poseidon_equivalence() { // Noir has hashes up to length 16, but the reference library won't work with more than 12. for len in 1..light_poseidon::MAX_X5_LEN { let source = format!( - "fn main(input: [Field; {len}]) -> pub Field {{ + " + use std::hash::{{Hash, Hasher}}; + + fn main(input: [Field; {len}]) -> pub Field {{ let h1 = std::hash::poseidon::bn254::hash_{len}(input); let h2 = {{ let mut hasher = std::hash::poseidon::PoseidonHasher::default();