From 167e153fcda6c7cf61020ec50909e79a97c834a7 Mon Sep 17 00:00:00 2001 From: "Michael J. Klein" Date: Tue, 30 Apr 2024 12:12:10 -0400 Subject: [PATCH 01/26] use PathKind::Plain over Dep, remove PathKind::Dep, resolve both possibilities when PathKind::Plain encountered, add test to ensure case never encountered in nargo_fmt, update path parsers, update unit tests and test_programs, cargo fmt/clippy --- aztec_macros/src/utils/ast_utils.rs | 2 +- compiler/noirc_frontend/src/ast/statement.rs | 2 -- .../src/hir/def_collector/dc_crate.rs | 9 ++++-- .../src/hir/resolution/import.rs | 30 ++++++++++------- .../src/hir/resolution/resolver.rs | 2 +- compiler/noirc_frontend/src/lexer/token.rs | 3 -- .../noirc_frontend/src/noir_parser.lalrpop | 6 ++-- .../noirc_frontend/src/parser/parser/path.rs | 32 ++++++++----------- compiler/noirc_frontend/src/tests.rs | 1 + .../src/main.nr | 2 +- .../ec_baby_jubjub/src/main.nr | 16 +++++----- .../intrinsic_die/src/main.nr | 2 +- .../method_call_regression/src/main.nr | 2 +- .../reexports/src/main.nr | 2 +- .../regression_2099/src/main.nr | 16 +++++----- .../regression_3635/src/main.nr | 2 +- .../str_as_bytes/src/main.nr | 2 +- .../trait_default_implementation/src/main.nr | 2 +- .../trait_override_implementation/src/main.nr | 2 +- .../compile_success_empty/traits/src/main.nr | 2 +- .../compile_success_empty/vectors/src/main.nr | 2 +- .../workspace_reexport_bug/binary/src/main.nr | 2 +- .../workspace_reexport_bug/library/src/lib.nr | 2 +- .../execution_success/4_sub/src/main.nr | 2 +- .../execution_success/5_over/src/main.nr | 2 +- test_programs/execution_success/6/src/main.nr | 2 +- .../execution_success/6_array/src/main.nr | 2 +- test_programs/execution_success/7/src/main.nr | 2 +- .../array_dynamic_blackbox_input/src/main.nr | 2 +- .../src/main.nr | 2 +- .../execution_success/bigint/src/main.nr | 10 +++--- .../execution_success/blake3/src/main.nr | 2 +- .../brillig_blake2s/src/main.nr | 2 +- .../brillig_blake3/src/main.nr | 2 +- .../brillig_cow_regression/src/main.nr | 4 +-- .../brillig_ecdsa_secp256k1/src/main.nr | 2 +- .../brillig_ecdsa_secp256r1/src/main.nr | 2 +- .../brillig_fns_as_values/src/main.nr | 2 +- .../brillig_hash_to_field/src/main.nr | 2 +- .../brillig_keccak/src/main.nr | 2 +- .../brillig_oracle/src/main.nr | 4 +-- .../brillig_pedersen/src/main.nr | 2 +- .../brillig_scalar_mul/src/main.nr | 2 +- .../brillig_schnorr/src/main.nr | 2 +- .../brillig_sha256/src/main.nr | 2 +- .../brillig_slices/src/main.nr | 2 +- .../brillig_to_bits/src/main.nr | 2 +- .../brillig_to_bytes_integration/src/main.nr | 2 +- .../brillig_wrapping/src/main.nr | 2 +- .../conditional_1/src/main.nr | 2 +- .../conditional_2/src/main.nr | 2 +- .../src/main.nr | 2 +- .../execution_success/databus/src/main.nr | 2 +- .../diamond_deps_0/src/main.nr | 6 ++-- .../double_verify_nested_proof/src/main.nr | 2 +- .../double_verify_proof/src/main.nr | 2 +- .../double_verify_proof_recursive/src/main.nr | 2 +- .../ecdsa_secp256k1/src/main.nr | 2 +- .../ecdsa_secp256r1/src/main.nr | 2 +- .../execution_success/eddsa/src/main.nr | 12 +++---- .../fold_numeric_generic_poseidon/src/main.nr | 2 +- .../hash_to_field/src/main.nr | 2 +- .../execution_success/hashmap/src/main.nr | 8 ++--- .../execution_success/import/src/main.nr | 2 +- .../execution_success/keccak256/src/main.nr | 2 +- .../merkle_insert/src/main.nr | 4 +-- .../execution_success/modulus/src/main.nr | 2 +- .../operator_overloading/src/main.nr | 4 +-- .../pedersen_check/src/main.nr | 2 +- .../pedersen_commitment/src/main.nr | 2 +- .../pedersen_hash/src/main.nr | 2 +- .../poseidon_bn254_hash/src/main.nr | 4 +-- .../poseidonsponge_x5_254/src/main.nr | 2 +- .../execution_success/prelude/src/main.nr | 4 +-- .../regression_3051/src/main.nr | 4 +-- .../regression_3394/src/main.nr | 2 +- .../regression_4124/src/main.nr | 4 +-- .../regression_4449/src/main.nr | 2 +- .../src/main.nr | 2 +- .../execution_success/scalar_mul/src/main.nr | 2 +- .../execution_success/schnorr/src/main.nr | 2 +- .../execution_success/sha256/src/main.nr | 2 +- .../execution_success/sha2_byte/src/main.nr | 2 +- .../signed_comparison/src/main.nr | 2 +- .../signed_division/src/main.nr | 2 +- .../simple_print/src/main.nr | 2 +- .../simple_shield/src/main.nr | 2 +- .../execution_success/slices/src/main.nr | 4 +-- .../execution_success/strings/src/main.nr | 2 +- .../to_bytes_integration/src/main.nr | 2 +- .../traits_in_crates_1/crate1/src/lib.nr | 2 +- .../traits_in_crates_1/src/main.nr | 2 +- .../traits_in_crates_2/crate2/src/lib.nr | 2 +- .../traits_in_crates_2/src/main.nr | 2 +- .../execution_success/u128/src/main.nr | 2 +- .../execution_success/unit_value/src/main.nr | 2 +- .../brillig_overflow_checks/src/main.nr | 2 +- .../field_comparisons/src/main.nr | 2 +- .../noir_test_success/mock_oracle/src/main.nr | 2 +- .../should_fail_with_matches/src/main.nr | 4 +-- .../test_libraries/diamond_deps_1/src/lib.nr | 2 +- .../test_libraries/exporting_lib/src/lib.nr | 2 +- .../test_libraries/reexporting_lib/src/lib.nr | 4 +-- tooling/debugger/src/source_code_printer.rs | 4 +-- tooling/nargo_fmt/src/rewrite/imports.rs | 3 -- tooling/nargo_fmt/tests/expected/contract.nr | 6 ++-- .../nargo_fmt/tests/expected/import_braces.nr | 2 +- tooling/nargo_fmt/tests/expected/let.nr | 8 ++--- tooling/nargo_fmt/tests/expected/print.nr | 2 +- tooling/nargo_fmt/tests/expected/print2.nr | 2 +- .../tests/expected/singleton_import.nr | 2 ++ tooling/nargo_fmt/tests/input/contract.nr | 6 ++-- .../nargo_fmt/tests/input/import_braces.nr | 2 +- tooling/nargo_fmt/tests/input/let.nr | 8 ++--- tooling/nargo_fmt/tests/input/print.nr | 2 +- tooling/nargo_fmt/tests/input/print2.nr | 2 +- .../nargo_fmt/tests/input/singleton_import.nr | 2 ++ .../assert_lt/src/main.nr | 2 +- 118 files changed, 204 insertions(+), 202 deletions(-) create mode 100644 tooling/nargo_fmt/tests/expected/singleton_import.nr create mode 100644 tooling/nargo_fmt/tests/input/singleton_import.nr diff --git a/aztec_macros/src/utils/ast_utils.rs b/aztec_macros/src/utils/ast_utils.rs index ebb4854f86e..58f987a1ebf 100644 --- a/aztec_macros/src/utils/ast_utils.rs +++ b/aztec_macros/src/utils/ast_utils.rs @@ -148,7 +148,7 @@ macro_rules! chained_dep { ( $base:expr $(, $tail:expr)* ) => { { let mut base_path = ident_path($base); - base_path.kind = PathKind::Dep; + base_path.kind = PathKind::Plain; $( base_path.segments.push(ident($tail)); )* diff --git a/compiler/noirc_frontend/src/ast/statement.rs b/compiler/noirc_frontend/src/ast/statement.rs index 0da39edfd85..16ed56f1ce0 100644 --- a/compiler/noirc_frontend/src/ast/statement.rs +++ b/compiler/noirc_frontend/src/ast/statement.rs @@ -290,7 +290,6 @@ pub struct ImportStatement { #[derive(Debug, PartialEq, Eq, Copy, Clone, Hash)] pub enum PathKind { Crate, - Dep, Plain, } @@ -735,7 +734,6 @@ impl Display for PathKind { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { PathKind::Crate => write!(f, "crate"), - PathKind::Dep => write!(f, "dep"), PathKind::Plain => write!(f, "plain"), } } 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 2f6b101e62f..728fbe0cdc8 100644 --- a/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs +++ b/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs @@ -436,8 +436,11 @@ fn inject_prelude( .map(|segment| crate::ast::Ident::new(segment.into(), Span::default())) .collect(); - let path = - Path { segments: segments.clone(), kind: crate::ast::PathKind::Dep, span: Span::default() }; + let path = Path { + segments: segments.clone(), + kind: crate::ast::PathKind::Plain, + span: Span::default(), + }; if !crate_id.is_stdlib() { if let Ok(PathResolution { module_def_id, error }) = path_resolver::resolve_path( @@ -457,7 +460,7 @@ fn inject_prelude( 0, ImportDirective { module_id: crate_root, - path: Path { segments, kind: PathKind::Dep, span: Span::default() }, + path: Path { segments, kind: PathKind::Plain, span: Span::default() }, alias: None, is_prelude: true, }, diff --git a/compiler/noirc_frontend/src/hir/resolution/import.rs b/compiler/noirc_frontend/src/hir/resolution/import.rs index 8850331f683..83a452a5cad 100644 --- a/compiler/noirc_frontend/src/hir/resolution/import.rs +++ b/compiler/noirc_frontend/src/hir/resolution/import.rs @@ -149,24 +149,28 @@ fn resolve_path_to_ns( allow_contracts, ) } - crate::ast::PathKind::Dep => resolve_external_dep( - def_map, - import_directive, - def_maps, - allow_contracts, - importing_crate, - ), crate::ast::PathKind::Plain => { - // Plain paths are only used to import children modules. It's possible to allow import of external deps, but maybe this distinction is better? - // In Rust they can also point to external Dependencies, if no children can be found with the specified name - resolve_name_in_module( + let result = resolve_name_in_module( crate_id, importing_crate, import_path, import_directive.module_id, def_maps, allow_contracts, - ) + ); + + if result.is_ok() { + result + } else { + // TODO: combine error messages? + resolve_external_dep( + def_map, + import_directive, + def_maps, + allow_contracts, + importing_crate, + ) + } } } } @@ -293,7 +297,9 @@ fn resolve_external_dep( .ok_or_else(|| PathResolutionError::Unresolved(crate_name.to_owned()))?; // Create an import directive for the dependency crate - let path_without_crate_name = &path[1..]; // XXX: This will panic if the path is of the form `use dep::std` Ideal algorithm will not distinguish between crate and module + // XXX: This will panic if the path is of the form `use std`. Ideal algorithm will not distinguish between crate and module + // See `singleton_import.nr` test case for a check that such cases are handled elsewhere. + let path_without_crate_name = &path[1..]; let path = Path { segments: path_without_crate_name.to_vec(), diff --git a/compiler/noirc_frontend/src/hir/resolution/resolver.rs b/compiler/noirc_frontend/src/hir/resolution/resolver.rs index bef0ebdaacc..f47377d1d0c 100644 --- a/compiler/noirc_frontend/src/hir/resolution/resolver.rs +++ b/compiler/noirc_frontend/src/hir/resolution/resolver.rs @@ -1416,7 +1416,7 @@ impl<'a> Resolver<'a> { Ident::from("internal"), Ident::from("resolve_assert_message"), ], - kind: PathKind::Dep, + kind: PathKind::Plain, span, }) }; diff --git a/compiler/noirc_frontend/src/lexer/token.rs b/compiler/noirc_frontend/src/lexer/token.rs index 82e17ac3912..607094b4350 100644 --- a/compiler/noirc_frontend/src/lexer/token.rs +++ b/compiler/noirc_frontend/src/lexer/token.rs @@ -834,7 +834,6 @@ pub enum Keyword { Continue, Contract, Crate, - Dep, Distinct, Else, Field, @@ -879,7 +878,6 @@ impl fmt::Display for Keyword { Keyword::Continue => write!(f, "continue"), Keyword::Contract => write!(f, "contract"), Keyword::Crate => write!(f, "crate"), - Keyword::Dep => write!(f, "dep"), Keyword::Distinct => write!(f, "distinct"), Keyword::Else => write!(f, "else"), Keyword::Field => write!(f, "Field"), @@ -927,7 +925,6 @@ impl Keyword { "continue" => Keyword::Continue, "contract" => Keyword::Contract, "crate" => Keyword::Crate, - "dep" => Keyword::Dep, "distinct" => Keyword::Distinct, "else" => Keyword::Else, "Field" => Keyword::Field, diff --git a/compiler/noirc_frontend/src/noir_parser.lalrpop b/compiler/noirc_frontend/src/noir_parser.lalrpop index 9acb5ef8b58..a68046f44f4 100644 --- a/compiler/noirc_frontend/src/noir_parser.lalrpop +++ b/compiler/noirc_frontend/src/noir_parser.lalrpop @@ -66,7 +66,6 @@ extern { "continue" => BorrowedToken::Keyword(noir_token::Keyword::Continue), "contract" => BorrowedToken::Keyword(noir_token::Keyword::Contract), "crate" => BorrowedToken::Keyword(noir_token::Keyword::Crate), - "dep" => BorrowedToken::Keyword(noir_token::Keyword::Dep), "distinct" => BorrowedToken::Keyword(noir_token::Keyword::Distinct), "else" => BorrowedToken::Keyword(noir_token::Keyword::Else), "Field" => BorrowedToken::Keyword(noir_token::Keyword::Field), @@ -125,8 +124,9 @@ pub(crate) Path: Path = { Path { segments, kind, span } }, - "dep" "::" => { - let kind = PathKind::Dep; + // TODO: still needed with PathKind::Plain now that "dep::.." is gone? + => { + let kind = PathKind::Plain; let span = Span::from(lo as u32..hi as u32); Path { segments, kind, span } }, diff --git a/compiler/noirc_frontend/src/parser/parser/path.rs b/compiler/noirc_frontend/src/parser/parser/path.rs index 47bb11991fa..1ba4b49d183 100644 --- a/compiler/noirc_frontend/src/parser/parser/path.rs +++ b/compiler/noirc_frontend/src/parser/parser/path.rs @@ -8,24 +8,21 @@ use chumsky::prelude::*; use super::{ident, keyword}; pub(super) fn path() -> impl NoirParser { - let idents = || ident().separated_by(just(Token::DoubleColon)).at_least(1); let make_path = |kind| move |segments, span| Path { segments, kind, span }; - let prefix = |key| keyword(key).ignore_then(just(Token::DoubleColon)); - let path_kind = |key, kind| prefix(key).ignore_then(idents()).map_with_span(make_path(kind)); + let idents = || ident().separated_by(just(Token::DoubleColon)).at_least(1); + let crate_path = + || prefix(Keyword::Crate).ignore_then(idents()).map_with_span(make_path(PathKind::Crate)); - choice(( - path_kind(Keyword::Crate, PathKind::Crate), - path_kind(Keyword::Dep, PathKind::Dep), - idents().map_with_span(make_path(PathKind::Plain)), - )) + choice((crate_path(), idents().map_with_span(make_path(PathKind::Plain)))) } fn empty_path() -> impl NoirParser { - let make_path = |kind| move |_, span| Path { segments: Vec::new(), kind, span }; - let path_kind = |key, kind| keyword(key).map_with_span(make_path(kind)); - - choice((path_kind(Keyword::Crate, PathKind::Crate), path_kind(Keyword::Dep, PathKind::Dep))) + let make_path = |opt_crate: Option, span| { + let kind = if opt_crate.is_some() { PathKind::Crate } else { PathKind::Plain }; + Path { segments: Vec::new(), kind, span } + }; + keyword(Keyword::Crate).or_not().map_with_span(make_path) } pub(super) fn maybe_empty_path() -> impl NoirParser { @@ -43,7 +40,7 @@ mod test { ("std", vec!["std"]), ("std::hash", vec!["std", "hash"]), ("std::hash::collections", vec!["std", "hash", "collections"]), - ("dep::foo::bar", vec!["foo", "bar"]), + ("foo::bar", vec!["foo", "bar"]), ("crate::std::hash", vec!["std", "hash"]), ]; @@ -61,7 +58,9 @@ mod test { fn parse_path_kinds() { let cases = vec![ ("std", PathKind::Plain), - ("dep::hash::collections", PathKind::Dep), + ("hash::collections", PathKind::Plain), + ("dep", PathKind::Plain), + ("foo::dep", PathKind::Plain), ("crate::std::hash", PathKind::Crate), ]; @@ -70,9 +69,6 @@ mod test { assert_eq!(path.kind, expected_path_kind); } - parse_all_failing( - path(), - vec!["dep", "crate", "crate::std::crate", "foo::bar::crate", "foo::dep"], - ); + parse_all_failing(path(), vec!["crate", "crate::std::crate", "foo::bar::crate"]); } } diff --git a/compiler/noirc_frontend/src/tests.rs b/compiler/noirc_frontend/src/tests.rs index cf2d7dbe153..245f76b6546 100644 --- a/compiler/noirc_frontend/src/tests.rs +++ b/compiler/noirc_frontend/src/tests.rs @@ -1357,6 +1357,7 @@ fn lambda$f1(mut env$l1: (Field)) -> Field { assert_eq!(get_program_errors(src).len(), 1); } + #[test] fn deny_inline_attribute_on_unconstrained() { let src = r#" #[inline(never)] diff --git a/test_programs/compile_success_empty/conditional_regression_to_bits/src/main.nr b/test_programs/compile_success_empty/conditional_regression_to_bits/src/main.nr index 5446cfbb1e4..d8b1be8df7c 100644 --- a/test_programs/compile_success_empty/conditional_regression_to_bits/src/main.nr +++ b/test_programs/compile_success_empty/conditional_regression_to_bits/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main() { //Regression for to_le_bits() constant evaluation diff --git a/test_programs/compile_success_empty/ec_baby_jubjub/src/main.nr b/test_programs/compile_success_empty/ec_baby_jubjub/src/main.nr index becd3c8927a..fa6be84c26e 100644 --- a/test_programs/compile_success_empty/ec_baby_jubjub/src/main.nr +++ b/test_programs/compile_success_empty/ec_baby_jubjub/src/main.nr @@ -1,14 +1,14 @@ // Tests may be checked against https://github.com/cfrg/draft-irtf-cfrg-hash-to-curve/tree/main/poc -use dep::std::ec::tecurve::affine::Curve as AffineCurve; -use dep::std::ec::tecurve::affine::Point as Gaffine; -use dep::std::ec::tecurve::curvegroup::Curve; -use dep::std::ec::tecurve::curvegroup::Point as G; +use std::ec::tecurve::affine::Curve as AffineCurve; +use std::ec::tecurve::affine::Point as Gaffine; +use std::ec::tecurve::curvegroup::Curve; +use std::ec::tecurve::curvegroup::Point as G; -use dep::std::ec::swcurve::affine::Point as SWGaffine; -use dep::std::ec::swcurve::curvegroup::Point as SWG; +use std::ec::swcurve::affine::Point as SWGaffine; +use std::ec::swcurve::curvegroup::Point as SWG; -use dep::std::ec::montcurve::affine::Point as MGaffine; -use dep::std::ec::montcurve::curvegroup::Point as MG; +use std::ec::montcurve::affine::Point as MGaffine; +use std::ec::montcurve::curvegroup::Point as MG; fn main() { // This test only makes sense if Field is the right prime field. diff --git a/test_programs/compile_success_empty/intrinsic_die/src/main.nr b/test_programs/compile_success_empty/intrinsic_die/src/main.nr index 8cac707dfea..bd714082763 100644 --- a/test_programs/compile_success_empty/intrinsic_die/src/main.nr +++ b/test_programs/compile_success_empty/intrinsic_die/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; // This test checks that we perform dead-instruction-elimination on intrinsic functions. fn main(x: Field) { let hash = std::hash::pedersen_commitment([x]); diff --git a/test_programs/compile_success_empty/method_call_regression/src/main.nr b/test_programs/compile_success_empty/method_call_regression/src/main.nr index 8bb7ebcac45..e5ddfa6a934 100644 --- a/test_programs/compile_success_empty/method_call_regression/src/main.nr +++ b/test_programs/compile_success_empty/method_call_regression/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main() { // s: Struct diff --git a/test_programs/compile_success_empty/reexports/src/main.nr b/test_programs/compile_success_empty/reexports/src/main.nr index ed469ff77d0..0fd65a33564 100644 --- a/test_programs/compile_success_empty/reexports/src/main.nr +++ b/test_programs/compile_success_empty/reexports/src/main.nr @@ -1,4 +1,4 @@ -use dep::reexporting_lib::{FooStruct, MyStruct, lib}; +use reexporting_lib::{FooStruct, MyStruct, lib}; fn main() { let x: FooStruct = MyStruct { inner: 0 }; diff --git a/test_programs/compile_success_empty/regression_2099/src/main.nr b/test_programs/compile_success_empty/regression_2099/src/main.nr index f92373ce63a..660f72f56e5 100644 --- a/test_programs/compile_success_empty/regression_2099/src/main.nr +++ b/test_programs/compile_success_empty/regression_2099/src/main.nr @@ -1,13 +1,13 @@ -use dep::std::ec::tecurve::affine::Curve as AffineCurve; -use dep::std::ec::tecurve::affine::Point as Gaffine; -use dep::std::ec::tecurve::curvegroup::Curve; -use dep::std::ec::tecurve::curvegroup::Point as G; +use std::ec::tecurve::affine::Curve as AffineCurve; +use std::ec::tecurve::affine::Point as Gaffine; +use std::ec::tecurve::curvegroup::Curve; +use std::ec::tecurve::curvegroup::Point as G; -use dep::std::ec::swcurve::affine::Point as SWGaffine; -use dep::std::ec::swcurve::curvegroup::Point as SWG; +use std::ec::swcurve::affine::Point as SWGaffine; +use std::ec::swcurve::curvegroup::Point as SWG; -use dep::std::ec::montcurve::affine::Point as MGaffine; -use dep::std::ec::montcurve::curvegroup::Point as MG; +use std::ec::montcurve::affine::Point as MGaffine; +use std::ec::montcurve::curvegroup::Point as MG; fn main() { // Define Baby Jubjub (ERC-2494) parameters in affine representation diff --git a/test_programs/compile_success_empty/regression_3635/src/main.nr b/test_programs/compile_success_empty/regression_3635/src/main.nr index 97a04f9d93f..3aad972c102 100644 --- a/test_programs/compile_success_empty/regression_3635/src/main.nr +++ b/test_programs/compile_success_empty/regression_3635/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main() { let x: u8 = 0x61; diff --git a/test_programs/compile_success_empty/str_as_bytes/src/main.nr b/test_programs/compile_success_empty/str_as_bytes/src/main.nr index 6fdd926ce7f..d812f3156b6 100644 --- a/test_programs/compile_success_empty/str_as_bytes/src/main.nr +++ b/test_programs/compile_success_empty/str_as_bytes/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main() { let a = "hello"; let b = a.as_bytes(); diff --git a/test_programs/compile_success_empty/trait_default_implementation/src/main.nr b/test_programs/compile_success_empty/trait_default_implementation/src/main.nr index 2f5bff8c40c..56299187bf7 100644 --- a/test_programs/compile_success_empty/trait_default_implementation/src/main.nr +++ b/test_programs/compile_success_empty/trait_default_implementation/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; trait MyDefault { fn my_default(x: Field, y: Field) -> Self; diff --git a/test_programs/compile_success_empty/trait_override_implementation/src/main.nr b/test_programs/compile_success_empty/trait_override_implementation/src/main.nr index 85528291870..6c9bf55a560 100644 --- a/test_programs/compile_success_empty/trait_override_implementation/src/main.nr +++ b/test_programs/compile_success_empty/trait_override_implementation/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; trait MyDefault { fn my_default(x: Field, y: Field) -> Self; diff --git a/test_programs/compile_success_empty/traits/src/main.nr b/test_programs/compile_success_empty/traits/src/main.nr index ed804559fed..a69177b9cc7 100644 --- a/test_programs/compile_success_empty/traits/src/main.nr +++ b/test_programs/compile_success_empty/traits/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; trait MyDefault { fn my_default(x: Field, y: Field) -> Self; diff --git a/test_programs/compile_success_empty/vectors/src/main.nr b/test_programs/compile_success_empty/vectors/src/main.nr index d105ceed180..ac02a4691dd 100644 --- a/test_programs/compile_success_empty/vectors/src/main.nr +++ b/test_programs/compile_success_empty/vectors/src/main.nr @@ -1,4 +1,4 @@ -use dep::std::collections::vec::Vec; +use std::collections::vec::Vec; fn main(x: Field, y: pub Field) { let mut vector = Vec::new(); diff --git a/test_programs/compile_success_empty/workspace_reexport_bug/binary/src/main.nr b/test_programs/compile_success_empty/workspace_reexport_bug/binary/src/main.nr index ab0ae9a48b8..a4207794a8a 100644 --- a/test_programs/compile_success_empty/workspace_reexport_bug/binary/src/main.nr +++ b/test_programs/compile_success_empty/workspace_reexport_bug/binary/src/main.nr @@ -1,2 +1,2 @@ -use dep::library::ReExportMeFromAnotherLib; +use library::ReExportMeFromAnotherLib; fn main(_x: ReExportMeFromAnotherLib) {} diff --git a/test_programs/compile_success_empty/workspace_reexport_bug/library/src/lib.nr b/test_programs/compile_success_empty/workspace_reexport_bug/library/src/lib.nr index 8e84662ed03..e3a1539ea65 100644 --- a/test_programs/compile_success_empty/workspace_reexport_bug/library/src/lib.nr +++ b/test_programs/compile_success_empty/workspace_reexport_bug/library/src/lib.nr @@ -1,2 +1,2 @@ // Re-export -use dep::library2::ReExportMeFromAnotherLib; +use library2::ReExportMeFromAnotherLib; diff --git a/test_programs/execution_success/4_sub/src/main.nr b/test_programs/execution_success/4_sub/src/main.nr index 6aef8e7b208..64bb3f1c444 100644 --- a/test_programs/execution_success/4_sub/src/main.nr +++ b/test_programs/execution_success/4_sub/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; // Test unsafe integer subtraction with underflow: 12 - 2418266113 = 1876701195 modulo 2^32 fn main(mut x: u32, y: u32, z: u32) { x = std::wrapping_sub(x,y); diff --git a/test_programs/execution_success/5_over/src/main.nr b/test_programs/execution_success/5_over/src/main.nr index 313d580a8d1..a16488671d2 100644 --- a/test_programs/execution_success/5_over/src/main.nr +++ b/test_programs/execution_success/5_over/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; // Test unsafe integer arithmetic // Test odd bits integer fn main(mut x: u32, y: u32) { diff --git a/test_programs/execution_success/6/src/main.nr b/test_programs/execution_success/6/src/main.nr index 5ecb809e68b..c8e9268e20e 100644 --- a/test_programs/execution_success/6/src/main.nr +++ b/test_programs/execution_success/6/src/main.nr @@ -5,7 +5,7 @@ // If you do not cast, it will take all the bytes from the field element! // Mimc input is an array of field elements // The function is called mimc_bn254 to emphasize its parameters are chosen for bn254 curve, it should be used only with a proving system using the same curve (e.g Plonk from Aztec) -use dep::std; +use std; fn main(x: [u8; 5], result: pub [u8; 32]) { let mut digest = std::hash::sha256(x); diff --git a/test_programs/execution_success/6_array/src/main.nr b/test_programs/execution_success/6_array/src/main.nr index 6aa05f58b71..81c619305ff 100644 --- a/test_programs/execution_success/6_array/src/main.nr +++ b/test_programs/execution_success/6_array/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; //Basic tests for arrays fn main(x: [u32; 5], y: [u32; 5], mut z: u32, t: u32) { let mut c = 2301; diff --git a/test_programs/execution_success/7/src/main.nr b/test_programs/execution_success/7/src/main.nr index a6bba978644..a6aef65ef50 100644 --- a/test_programs/execution_success/7/src/main.nr +++ b/test_programs/execution_success/7/src/main.nr @@ -2,7 +2,7 @@ // // Pre-alpha dependencies must now be prefixed with the word "dep". // The line below indicates that we would like to pull in the standard library dependency. -use dep::std; +use std; fn main(x: [u8; 5], result: [u8; 32]) { let digest = std::hash::blake2s(x); diff --git a/test_programs/execution_success/array_dynamic_blackbox_input/src/main.nr b/test_programs/execution_success/array_dynamic_blackbox_input/src/main.nr index 4cbf1bd8e6d..260d609928b 100644 --- a/test_programs/execution_success/array_dynamic_blackbox_input/src/main.nr +++ b/test_programs/execution_success/array_dynamic_blackbox_input/src/main.nr @@ -18,7 +18,7 @@ fn compute_root(leaf: [u8; 32], path: [u8; 64], _index: u32, root: [u8; 32]) { hash_input[j + b] = path[offset + j]; } - current = dep::std::hash::sha256(hash_input); + current = std::hash::sha256(hash_input); index = index >> 1; } diff --git a/test_programs/execution_success/array_dynamic_nested_blackbox_input/src/main.nr b/test_programs/execution_success/array_dynamic_nested_blackbox_input/src/main.nr index 8faaf69dfc8..15a2747eaa9 100644 --- a/test_programs/execution_success/array_dynamic_nested_blackbox_input/src/main.nr +++ b/test_programs/execution_success/array_dynamic_nested_blackbox_input/src/main.nr @@ -15,6 +15,6 @@ fn main(mut x: [Foo; 3], y: pub Field, hash_result: pub [u8; 32]) { // Make sure that we are passing a dynamic array to the black box function call // by setting the array using a dynamic index here hash_input[y - 1] = 0; - let hash = dep::std::hash::sha256(hash_input); + let hash = std::hash::sha256(hash_input); assert_eq(hash, hash_result); } diff --git a/test_programs/execution_success/bigint/src/main.nr b/test_programs/execution_success/bigint/src/main.nr index c454c2b66cd..9385b39e847 100644 --- a/test_programs/execution_success/bigint/src/main.nr +++ b/test_programs/execution_success/bigint/src/main.nr @@ -1,5 +1,5 @@ -use dep::std::bigint; -use dep::std::{bigint::Secpk1Fq, println}; +use std::bigint; +use std::{bigint::Secpk1Fq, println}; fn main(mut x: [u8; 5], y: [u8; 5]) { let a = bigint::Secpk1Fq::from_le_bytes(&[x[0], x[1], x[2], x[3], x[4]]); @@ -10,8 +10,8 @@ fn main(mut x: [u8; 5], y: [u8; 5]) { a_be_bytes[31-i] = x[i]; b_be_bytes[31-i] = y[i]; } - let a_field = dep::std::field::bytes32_to_field(a_be_bytes); - let b_field = dep::std::field::bytes32_to_field(b_be_bytes); + let a_field = std::field::bytes32_to_field(a_be_bytes); + let b_field = std::field::bytes32_to_field(b_be_bytes); // Regression for issue #4682 let c = if x[0] != 0 { @@ -19,7 +19,7 @@ fn main(mut x: [u8; 5], y: [u8; 5]) { } else { test_unconstrained2(a, b) }; - assert(c.array[0] == dep::std::wrapping_mul(x[0], y[0])); + assert(c.array[0] == std::wrapping_mul(x[0], y[0])); let a_bytes = a.to_le_bytes(); let b_bytes = b.to_le_bytes(); diff --git a/test_programs/execution_success/blake3/src/main.nr b/test_programs/execution_success/blake3/src/main.nr index 3bfea6c5f95..861a54fcfee 100644 --- a/test_programs/execution_success/blake3/src/main.nr +++ b/test_programs/execution_success/blake3/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main(x: [u8; 5], result: [u8; 32]) { let digest = std::hash::blake3(x); diff --git a/test_programs/execution_success/brillig_blake2s/src/main.nr b/test_programs/execution_success/brillig_blake2s/src/main.nr index 5bd52666ae9..fc095a1654c 100644 --- a/test_programs/execution_success/brillig_blake2s/src/main.nr +++ b/test_programs/execution_success/brillig_blake2s/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; // Tests a very simple program. // // The features being tested is blake2s in brillig diff --git a/test_programs/execution_success/brillig_blake3/src/main.nr b/test_programs/execution_success/brillig_blake3/src/main.nr index 05a5b31f936..2f3f4984157 100644 --- a/test_programs/execution_success/brillig_blake3/src/main.nr +++ b/test_programs/execution_success/brillig_blake3/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; unconstrained fn main(x: [u8; 5], result: [u8; 32]) { let digest = std::hash::blake3(x); diff --git a/test_programs/execution_success/brillig_cow_regression/src/main.nr b/test_programs/execution_success/brillig_cow_regression/src/main.nr index 1cae9b1ba41..7cd50860978 100644 --- a/test_programs/execution_success/brillig_cow_regression/src/main.nr +++ b/test_programs/execution_success/brillig_cow_regression/src/main.nr @@ -25,7 +25,7 @@ struct NewContractData { impl NewContractData { fn hash(self) -> Field { - dep::std::hash::pedersen_hash([self.contract_address, self.portal_contract_address]) + std::hash::pedersen_hash([self.contract_address, self.portal_contract_address]) } } @@ -173,6 +173,6 @@ unconstrained fn main(kernel_data: DataToHash) -> pub [Field; NUM_FIELDS_PER_SHA } } - let sha_digest = dep::std::hash::sha256(hash_input_flattened); + let sha_digest = std::hash::sha256(hash_input_flattened); U256::from_bytes32(sha_digest).to_u128_limbs() } diff --git a/test_programs/execution_success/brillig_ecdsa_secp256k1/src/main.nr b/test_programs/execution_success/brillig_ecdsa_secp256k1/src/main.nr index 5d84d885567..0ade00d77de 100644 --- a/test_programs/execution_success/brillig_ecdsa_secp256k1/src/main.nr +++ b/test_programs/execution_success/brillig_ecdsa_secp256k1/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; // Tests a very simple program. // // The features being tested is ecdsa in brillig diff --git a/test_programs/execution_success/brillig_ecdsa_secp256r1/src/main.nr b/test_programs/execution_success/brillig_ecdsa_secp256r1/src/main.nr index 9da07f531aa..8718663afbc 100644 --- a/test_programs/execution_success/brillig_ecdsa_secp256r1/src/main.nr +++ b/test_programs/execution_success/brillig_ecdsa_secp256r1/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; // Tests a very simple program. // // The features being tested is ecdsa in brillig diff --git a/test_programs/execution_success/brillig_fns_as_values/src/main.nr b/test_programs/execution_success/brillig_fns_as_values/src/main.nr index 9248bff2f4c..8a02f43178d 100644 --- a/test_programs/execution_success/brillig_fns_as_values/src/main.nr +++ b/test_programs/execution_success/brillig_fns_as_values/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; struct MyStruct { operation: fn (u32) -> u32, diff --git a/test_programs/execution_success/brillig_hash_to_field/src/main.nr b/test_programs/execution_success/brillig_hash_to_field/src/main.nr index 53ed85b3ddd..b297b3f4771 100644 --- a/test_programs/execution_success/brillig_hash_to_field/src/main.nr +++ b/test_programs/execution_success/brillig_hash_to_field/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; // Tests a very simple program. // // The features being tested is hash_to_field in brillig diff --git a/test_programs/execution_success/brillig_keccak/src/main.nr b/test_programs/execution_success/brillig_keccak/src/main.nr index a300bc18279..5cb6a298d85 100644 --- a/test_programs/execution_success/brillig_keccak/src/main.nr +++ b/test_programs/execution_success/brillig_keccak/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; // Tests a very simple program. // // The features being tested is keccak256 in brillig diff --git a/test_programs/execution_success/brillig_oracle/src/main.nr b/test_programs/execution_success/brillig_oracle/src/main.nr index 6a9e5806621..0305cb06978 100644 --- a/test_programs/execution_success/brillig_oracle/src/main.nr +++ b/test_programs/execution_success/brillig_oracle/src/main.nr @@ -1,5 +1,5 @@ -use dep::std::slice; -use dep::std::test::OracleMock; +use std::slice; +use std::test::OracleMock; // Tests oracle usage in brillig/unconstrained functions fn main(_x: Field) { diff --git a/test_programs/execution_success/brillig_pedersen/src/main.nr b/test_programs/execution_success/brillig_pedersen/src/main.nr index 2379818c454..a667ba8d23f 100644 --- a/test_programs/execution_success/brillig_pedersen/src/main.nr +++ b/test_programs/execution_success/brillig_pedersen/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; unconstrained fn main(x: Field, y: Field, salt: Field, out_x: Field, out_y: Field, out_hash: Field) { let res = std::hash::pedersen_commitment_with_separator([x, y], 0); diff --git a/test_programs/execution_success/brillig_scalar_mul/src/main.nr b/test_programs/execution_success/brillig_scalar_mul/src/main.nr index c7c3a85a4ff..63c0462f1b2 100644 --- a/test_programs/execution_success/brillig_scalar_mul/src/main.nr +++ b/test_programs/execution_success/brillig_scalar_mul/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; unconstrained fn main( a: Field, diff --git a/test_programs/execution_success/brillig_schnorr/src/main.nr b/test_programs/execution_success/brillig_schnorr/src/main.nr index 03c635b4f6f..573695129c6 100644 --- a/test_programs/execution_success/brillig_schnorr/src/main.nr +++ b/test_programs/execution_success/brillig_schnorr/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; // Note: If main has any unsized types, then the verifier will never be able // to figure out the circuit instance unconstrained fn main( diff --git a/test_programs/execution_success/brillig_sha256/src/main.nr b/test_programs/execution_success/brillig_sha256/src/main.nr index e76109df9c3..63f5d00d7ae 100644 --- a/test_programs/execution_success/brillig_sha256/src/main.nr +++ b/test_programs/execution_success/brillig_sha256/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; // Tests a very simple program. // // The features being tested is sha256 in brillig diff --git a/test_programs/execution_success/brillig_slices/src/main.nr b/test_programs/execution_success/brillig_slices/src/main.nr index 2cf1850f151..89f838a3a57 100644 --- a/test_programs/execution_success/brillig_slices/src/main.nr +++ b/test_programs/execution_success/brillig_slices/src/main.nr @@ -1,4 +1,4 @@ -use dep::std::slice; +use std::slice; unconstrained fn main(x: Field, y: Field) { let mut slice: [Field] = &[y, x]; assert(slice.len() == 2); diff --git a/test_programs/execution_success/brillig_to_bits/src/main.nr b/test_programs/execution_success/brillig_to_bits/src/main.nr index 7ff3d2467b5..d037a9f41ed 100644 --- a/test_programs/execution_success/brillig_to_bits/src/main.nr +++ b/test_programs/execution_success/brillig_to_bits/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; unconstrained fn main() { let field = 1000; diff --git a/test_programs/execution_success/brillig_to_bytes_integration/src/main.nr b/test_programs/execution_success/brillig_to_bytes_integration/src/main.nr index e8e5b9db9ca..70004b3c49f 100644 --- a/test_programs/execution_success/brillig_to_bytes_integration/src/main.nr +++ b/test_programs/execution_success/brillig_to_bytes_integration/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; unconstrained fn main(x: Field, _y: Field) { // The result of this byte array will be big-endian diff --git a/test_programs/execution_success/brillig_wrapping/src/main.nr b/test_programs/execution_success/brillig_wrapping/src/main.nr index 4153a466057..b6846b418ef 100644 --- a/test_programs/execution_success/brillig_wrapping/src/main.nr +++ b/test_programs/execution_success/brillig_wrapping/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; unconstrained fn main(x: u8, y: u8) { assert(std::wrapping_sub(x, 1) == y); diff --git a/test_programs/execution_success/conditional_1/src/main.nr b/test_programs/execution_success/conditional_1/src/main.nr index 5064c82bce9..6b4714a3442 100644 --- a/test_programs/execution_success/conditional_1/src/main.nr +++ b/test_programs/execution_success/conditional_1/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn sort(mut a: [u32; 4]) -> [u32; 4] { for i in 1..4 { diff --git a/test_programs/execution_success/conditional_2/src/main.nr b/test_programs/execution_success/conditional_2/src/main.nr index 5b3f64f6be5..bb8c8ad4d8e 100644 --- a/test_programs/execution_success/conditional_2/src/main.nr +++ b/test_programs/execution_success/conditional_2/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn must_be_zero(x: u8) { assert(x == 0); diff --git a/test_programs/execution_success/conditional_regression_short_circuit/src/main.nr b/test_programs/execution_success/conditional_regression_short_circuit/src/main.nr index d260fa49dc3..c707aa8b42c 100644 --- a/test_programs/execution_success/conditional_regression_short_circuit/src/main.nr +++ b/test_programs/execution_success/conditional_regression_short_circuit/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main(a: u32, mut c: [u32; 4], x: [u8; 5], result: pub [u8; 32]) { //regression for short-circuit2 diff --git a/test_programs/execution_success/databus/src/main.nr b/test_programs/execution_success/databus/src/main.nr index 1cf95be8a22..217a73f7476 100644 --- a/test_programs/execution_success/databus/src/main.nr +++ b/test_programs/execution_success/databus/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main(mut x: u32, y: call_data u32, z: call_data [u32; 4]) -> return_data u32 { let a = z[x]; diff --git a/test_programs/execution_success/diamond_deps_0/src/main.nr b/test_programs/execution_success/diamond_deps_0/src/main.nr index ca95c6e0aa8..690d6fc9fc8 100644 --- a/test_programs/execution_success/diamond_deps_0/src/main.nr +++ b/test_programs/execution_success/diamond_deps_0/src/main.nr @@ -1,6 +1,6 @@ -use dep::dep1::call_dep1_then_dep2; -use dep::dep2::call_dep2; -use dep::dep2::RESOLVE_THIS; +use dep1::call_dep1_then_dep2; +use dep2::call_dep2; +use dep2::RESOLVE_THIS; fn main(x: Field, y: pub Field) -> pub Field { call_dep1_then_dep2(x, y) + call_dep2(x, y) + RESOLVE_THIS diff --git a/test_programs/execution_success/double_verify_nested_proof/src/main.nr b/test_programs/execution_success/double_verify_nested_proof/src/main.nr index 95d4b6f6995..0946ce4e238 100644 --- a/test_programs/execution_success/double_verify_nested_proof/src/main.nr +++ b/test_programs/execution_success/double_verify_nested_proof/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; // This circuit aggregates two recursive proofs from `double_verify_proof_recursive`. // Recursive aggregation is a backend-specific process and it is expected for backends diff --git a/test_programs/execution_success/double_verify_proof/src/main.nr b/test_programs/execution_success/double_verify_proof/src/main.nr index d832ce0f049..7a88bf7c5c9 100644 --- a/test_programs/execution_success/double_verify_proof/src/main.nr +++ b/test_programs/execution_success/double_verify_proof/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; // This circuit aggregates two proofs from `assert_statement_recursive`. fn main( diff --git a/test_programs/execution_success/double_verify_proof_recursive/src/main.nr b/test_programs/execution_success/double_verify_proof_recursive/src/main.nr index 86b4971c3a6..d488333cdf6 100644 --- a/test_programs/execution_success/double_verify_proof_recursive/src/main.nr +++ b/test_programs/execution_success/double_verify_proof_recursive/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; // This circuit aggregates two proofs from `assert_statement_recursive`. #[recursive] diff --git a/test_programs/execution_success/ecdsa_secp256k1/src/main.nr b/test_programs/execution_success/ecdsa_secp256k1/src/main.nr index ac0359e4bb8..6e10ca34455 100644 --- a/test_programs/execution_success/ecdsa_secp256k1/src/main.nr +++ b/test_programs/execution_success/ecdsa_secp256k1/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main( message: [u8; 38], diff --git a/test_programs/execution_success/ecdsa_secp256r1/src/main.nr b/test_programs/execution_success/ecdsa_secp256r1/src/main.nr index c64e390d652..b5463f4d03a 100644 --- a/test_programs/execution_success/ecdsa_secp256r1/src/main.nr +++ b/test_programs/execution_success/ecdsa_secp256r1/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main(hashed_message: [u8; 32], pub_key_x: [u8; 32], pub_key_y: [u8; 32], signature: [u8; 64]) { let valid_signature = std::ecdsa_secp256r1::verify_signature(pub_key_x, pub_key_y, signature, hashed_message); diff --git a/test_programs/execution_success/eddsa/src/main.nr b/test_programs/execution_success/eddsa/src/main.nr index 012c8466f2f..34938e90dba 100644 --- a/test_programs/execution_success/eddsa/src/main.nr +++ b/test_programs/execution_success/eddsa/src/main.nr @@ -1,9 +1,9 @@ -use dep::std::compat; -use dep::std::ec::consts::te::baby_jubjub; -use dep::std::ec::tecurve::affine::Point as TEPoint; -use dep::std::hash; -use dep::std::eddsa::{eddsa_to_pub, eddsa_poseidon_verify, eddsa_verify_with_hasher}; -use dep::std::hash::poseidon2::Poseidon2Hasher; +use std::compat; +use std::ec::consts::te::baby_jubjub; +use std::ec::tecurve::affine::Point as TEPoint; +use std::hash; +use std::eddsa::{eddsa_to_pub, eddsa_poseidon_verify, eddsa_verify_with_hasher}; +use std::hash::poseidon2::Poseidon2Hasher; fn main(msg: pub Field, _priv_key_a: Field, _priv_key_b: Field) { // Skip this test for non-bn254 backends diff --git a/test_programs/execution_success/fold_numeric_generic_poseidon/src/main.nr b/test_programs/execution_success/fold_numeric_generic_poseidon/src/main.nr index f9f3e75789b..7d12d63634b 100644 --- a/test_programs/execution_success/fold_numeric_generic_poseidon/src/main.nr +++ b/test_programs/execution_success/fold_numeric_generic_poseidon/src/main.nr @@ -1,4 +1,4 @@ -use dep::std::hash::{pedersen_hash_with_separator, poseidon2::Poseidon2}; +use std::hash::{pedersen_hash_with_separator, poseidon2::Poseidon2}; global NUM_HASHES = 2; global HASH_LENGTH = 10; diff --git a/test_programs/execution_success/hash_to_field/src/main.nr b/test_programs/execution_success/hash_to_field/src/main.nr index 242b5ecbc18..1e243781ed7 100644 --- a/test_programs/execution_success/hash_to_field/src/main.nr +++ b/test_programs/execution_success/hash_to_field/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main(input: Field) -> pub Field { std::hash::hash_to_field(&[input]) diff --git a/test_programs/execution_success/hashmap/src/main.nr b/test_programs/execution_success/hashmap/src/main.nr index 76daa594a89..8cf70cc5970 100644 --- a/test_programs/execution_success/hashmap/src/main.nr +++ b/test_programs/execution_success/hashmap/src/main.nr @@ -1,9 +1,9 @@ mod utils; -use dep::std::collections::map::HashMap; -use dep::std::hash::BuildHasherDefault; -use dep::std::hash::poseidon2::Poseidon2Hasher; -use dep::std::cmp::Eq; +use std::collections::map::HashMap; +use std::hash::BuildHasherDefault; +use std::hash::poseidon2::Poseidon2Hasher; +use std::cmp::Eq; use utils::cut; diff --git a/test_programs/execution_success/import/src/main.nr b/test_programs/execution_success/import/src/main.nr index 7dcc16fed16..0f5aa7e5460 100644 --- a/test_programs/execution_success/import/src/main.nr +++ b/test_programs/execution_success/import/src/main.nr @@ -2,7 +2,7 @@ mod import; use crate::import::hello; fn main(x: Field, y: Field) { - let _k = dep::std::hash::pedersen_commitment([x]); + let _k = std::hash::pedersen_commitment([x]); let _l = hello(x); assert(x != import::hello(y)); diff --git a/test_programs/execution_success/keccak256/src/main.nr b/test_programs/execution_success/keccak256/src/main.nr index eb401fe614c..0558a6e7245 100644 --- a/test_programs/execution_success/keccak256/src/main.nr +++ b/test_programs/execution_success/keccak256/src/main.nr @@ -1,5 +1,5 @@ // docs:start:keccak256 -use dep::std; +use std; fn main(x: Field, result: [u8; 32]) { // We use the `as` keyword here to denote the fact that we want to take just the first byte from the x Field diff --git a/test_programs/execution_success/merkle_insert/src/main.nr b/test_programs/execution_success/merkle_insert/src/main.nr index ac9a7b34ea3..8dfa98d3077 100644 --- a/test_programs/execution_success/merkle_insert/src/main.nr +++ b/test_programs/execution_success/merkle_insert/src/main.nr @@ -1,5 +1,5 @@ -use dep::std; -use dep::std::hash::mimc; +use std; +use std::hash::mimc; fn main( old_root: Field, diff --git a/test_programs/execution_success/modulus/src/main.nr b/test_programs/execution_success/modulus/src/main.nr index 35f63fdc8c5..75cf312b645 100644 --- a/test_programs/execution_success/modulus/src/main.nr +++ b/test_programs/execution_success/modulus/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main(bn254_modulus_be_bytes: [u8; 32], bn254_modulus_be_bits: [u1; 254]) { let modulus_size = std::field::modulus_num_bits(); diff --git a/test_programs/execution_success/operator_overloading/src/main.nr b/test_programs/execution_success/operator_overloading/src/main.nr index 3956ea5c577..c2c831d0c1e 100644 --- a/test_programs/execution_success/operator_overloading/src/main.nr +++ b/test_programs/execution_success/operator_overloading/src/main.nr @@ -1,5 +1,5 @@ -use dep::std::ops::{Add, Sub, Mul, Div, Rem, BitAnd, BitOr, BitXor, Shl, Shr}; -use dep::std::cmp::Ordering; +use std::ops::{Add, Sub, Mul, Div, Rem, BitAnd, BitOr, BitXor, Shl, Shr}; +use std::cmp::Ordering; // x = 3, y = 9 fn main(x: u32, y: u32) { diff --git a/test_programs/execution_success/pedersen_check/src/main.nr b/test_programs/execution_success/pedersen_check/src/main.nr index 90ef218249b..3405e6daee2 100644 --- a/test_programs/execution_success/pedersen_check/src/main.nr +++ b/test_programs/execution_success/pedersen_check/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main(x: Field, y: Field, salt: Field, out_x: Field, out_y: Field, out_hash: Field) { let res = std::hash::pedersen_commitment([x, y]); diff --git a/test_programs/execution_success/pedersen_commitment/src/main.nr b/test_programs/execution_success/pedersen_commitment/src/main.nr index 83cbe20851d..1670fa99598 100644 --- a/test_programs/execution_success/pedersen_commitment/src/main.nr +++ b/test_programs/execution_success/pedersen_commitment/src/main.nr @@ -1,5 +1,5 @@ // docs:start:pedersen-commitment -use dep::std; +use std; fn main(x: Field, y: Field, expected_commitment: std::hash::PedersenPoint) { let commitment = std::hash::pedersen_commitment([x, y]); diff --git a/test_programs/execution_success/pedersen_hash/src/main.nr b/test_programs/execution_success/pedersen_hash/src/main.nr index 20c7de12d6c..42712df370f 100644 --- a/test_programs/execution_success/pedersen_hash/src/main.nr +++ b/test_programs/execution_success/pedersen_hash/src/main.nr @@ -1,5 +1,5 @@ // docs:start:pedersen-hash -use dep::std; +use std; fn main(x: Field, y: Field, expected_hash: Field) { let hash = std::hash::pedersen_hash([x, y]); diff --git a/test_programs/execution_success/poseidon_bn254_hash/src/main.nr b/test_programs/execution_success/poseidon_bn254_hash/src/main.nr index a1607956190..cf1c190e5c9 100644 --- a/test_programs/execution_success/poseidon_bn254_hash/src/main.nr +++ b/test_programs/execution_success/poseidon_bn254_hash/src/main.nr @@ -1,6 +1,6 @@ // docs:start:poseidon -use dep::std::hash::poseidon; -use dep::std::hash::poseidon2; +use std::hash::poseidon; +use std::hash::poseidon2; fn main(x1: [Field; 2], y1: pub Field, x2: [Field; 4], y2: pub Field, x3: [Field; 4], y3: Field) { let hash1 = poseidon::bn254::hash_2(x1); diff --git a/test_programs/execution_success/poseidonsponge_x5_254/src/main.nr b/test_programs/execution_success/poseidonsponge_x5_254/src/main.nr index 910a17c8c89..137f3e5d2a6 100644 --- a/test_programs/execution_success/poseidonsponge_x5_254/src/main.nr +++ b/test_programs/execution_success/poseidonsponge_x5_254/src/main.nr @@ -1,4 +1,4 @@ -use dep::std::hash::poseidon; +use std::hash::poseidon; fn main(x: [Field; 7]) { // Test optimized sponge diff --git a/test_programs/execution_success/prelude/src/main.nr b/test_programs/execution_success/prelude/src/main.nr index 226341f1e7b..4fe6080222e 100644 --- a/test_programs/execution_success/prelude/src/main.nr +++ b/test_programs/execution_success/prelude/src/main.nr @@ -8,8 +8,8 @@ fn main() { mod a { // We don't want to give an error due to re-importing elements that are already in the prelude. - use dep::std::collections::vec::Vec; - use dep::std::option::Option; + use std::collections::vec::Vec; + use std::option::Option; fn main() { let _xs = Vec::new(); diff --git a/test_programs/execution_success/regression_3051/src/main.nr b/test_programs/execution_success/regression_3051/src/main.nr index 2e7d10fd7b0..90eb652db7a 100644 --- a/test_programs/execution_success/regression_3051/src/main.nr +++ b/test_programs/execution_success/regression_3051/src/main.nr @@ -19,6 +19,6 @@ impl Bar for u64 { } fn main() { - dep::std::println(1.foo()); - dep::std::println(1.bar()); + std::println(1.foo()); + std::println(1.bar()); } diff --git a/test_programs/execution_success/regression_3394/src/main.nr b/test_programs/execution_success/regression_3394/src/main.nr index 94b6c818ff2..bcca4f36396 100644 --- a/test_programs/execution_success/regression_3394/src/main.nr +++ b/test_programs/execution_success/regression_3394/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main() { let x : i8 = -128; diff --git a/test_programs/execution_success/regression_4124/src/main.nr b/test_programs/execution_success/regression_4124/src/main.nr index 49ff68ee6ad..2b0e65a0b6c 100644 --- a/test_programs/execution_success/regression_4124/src/main.nr +++ b/test_programs/execution_success/regression_4124/src/main.nr @@ -1,4 +1,4 @@ -use dep::std::option::Option; +use std::option::Option; trait MyDeserialize { fn deserialize(fields: [Field; N]) -> Self; @@ -11,7 +11,7 @@ impl MyDeserialize<1> for Field { } pub fn storage_read() -> [Field; N] { - dep::std::unsafe::zeroed() + std::unsafe::zeroed() } struct PublicMutable { diff --git a/test_programs/execution_success/regression_4449/src/main.nr b/test_programs/execution_success/regression_4449/src/main.nr index 454a93f5d1a..ca7f239bd4e 100644 --- a/test_programs/execution_success/regression_4449/src/main.nr +++ b/test_programs/execution_success/regression_4449/src/main.nr @@ -1,5 +1,5 @@ // Regression test for issue #4449 -use dep::std; +use std; fn main(x: u8, result: [u8; 32]) { let x = x % 31; diff --git a/test_programs/execution_success/regression_method_cannot_be_found/src/main.nr b/test_programs/execution_success/regression_method_cannot_be_found/src/main.nr index 1a6931a6870..fb6e664e1d7 100644 --- a/test_programs/execution_success/regression_method_cannot_be_found/src/main.nr +++ b/test_programs/execution_success/regression_method_cannot_be_found/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; struct Item { id: Field, } diff --git a/test_programs/execution_success/scalar_mul/src/main.nr b/test_programs/execution_success/scalar_mul/src/main.nr index e20f47907db..d092c614b87 100644 --- a/test_programs/execution_success/scalar_mul/src/main.nr +++ b/test_programs/execution_success/scalar_mul/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main( a: Field, diff --git a/test_programs/execution_success/schnorr/src/main.nr b/test_programs/execution_success/schnorr/src/main.nr index 9e2838c34d9..4fa06583604 100644 --- a/test_programs/execution_success/schnorr/src/main.nr +++ b/test_programs/execution_success/schnorr/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; // Note: If main has any unsized types, then the verifier will never be able // to figure out the circuit instance fn main( diff --git a/test_programs/execution_success/sha256/src/main.nr b/test_programs/execution_success/sha256/src/main.nr index d4240ded8b3..41e51e639b5 100644 --- a/test_programs/execution_success/sha256/src/main.nr +++ b/test_programs/execution_success/sha256/src/main.nr @@ -9,7 +9,7 @@ // // Not yet here: For R1CS, it is more about manipulating arithmetic gates to get performance // This can be done in ACIR! -use dep::std; +use std; fn main(x: Field, result: [u8; 32]) { // We use the `as` keyword here to denote the fact that we want to take just the first byte from the x Field diff --git a/test_programs/execution_success/sha2_byte/src/main.nr b/test_programs/execution_success/sha2_byte/src/main.nr index fa8ddfbdf69..b61cfbd473c 100644 --- a/test_programs/execution_success/sha2_byte/src/main.nr +++ b/test_programs/execution_success/sha2_byte/src/main.nr @@ -1,5 +1,5 @@ // Test Noir implementations of SHA256 and SHA512 on a one-byte message. -use dep::std; +use std; fn main(x: Field, result256: [u8; 32], result512: [u8; 64]) { let digest256 = std::sha256::digest([x as u8]); diff --git a/test_programs/execution_success/signed_comparison/src/main.nr b/test_programs/execution_success/signed_comparison/src/main.nr index d020be380fb..27ff51865f7 100644 --- a/test_programs/execution_success/signed_comparison/src/main.nr +++ b/test_programs/execution_success/signed_comparison/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main(mut x: i8, mut y: i8, z: i8) { let mut s1: i8 = 5; diff --git a/test_programs/execution_success/signed_division/src/main.nr b/test_programs/execution_success/signed_division/src/main.nr index 6289a2f9ed9..1831fd59d31 100644 --- a/test_programs/execution_success/signed_division/src/main.nr +++ b/test_programs/execution_success/signed_division/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; // Testing signed integer division: // 7/3 = 2 // -7/3 = -2 diff --git a/test_programs/execution_success/simple_print/src/main.nr b/test_programs/execution_success/simple_print/src/main.nr index 6038b995af0..5e164a16e0a 100644 --- a/test_programs/execution_success/simple_print/src/main.nr +++ b/test_programs/execution_success/simple_print/src/main.nr @@ -1,6 +1,6 @@ // Simple program for testing the logging // of single witnesses and witness arrays. -use dep::std; +use std; fn main(x: Field, y: pub Field) { std::println(x); diff --git a/test_programs/execution_success/simple_shield/src/main.nr b/test_programs/execution_success/simple_shield/src/main.nr index c46d3b4594c..39933b2e846 100644 --- a/test_programs/execution_success/simple_shield/src/main.nr +++ b/test_programs/execution_success/simple_shield/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main( // Public key of note diff --git a/test_programs/execution_success/slices/src/main.nr b/test_programs/execution_success/slices/src/main.nr index b20e3478898..b5b0a6a018f 100644 --- a/test_programs/execution_success/slices/src/main.nr +++ b/test_programs/execution_success/slices/src/main.nr @@ -1,5 +1,5 @@ -use dep::std::slice; -use dep::std; +use std::slice; +use std; fn main(x: Field, y: pub Field) { let mut slice = &[0; 2]; diff --git a/test_programs/execution_success/strings/src/main.nr b/test_programs/execution_success/strings/src/main.nr index cff229d368a..e5553d684f6 100644 --- a/test_programs/execution_success/strings/src/main.nr +++ b/test_programs/execution_success/strings/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; // Test global string literals global HELLO_WORLD = "hello world"; diff --git a/test_programs/execution_success/to_bytes_integration/src/main.nr b/test_programs/execution_success/to_bytes_integration/src/main.nr index 3c43caf1806..8adab30e9b0 100644 --- a/test_programs/execution_success/to_bytes_integration/src/main.nr +++ b/test_programs/execution_success/to_bytes_integration/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main(x: Field, a: Field) { let y: Field = 2040124; diff --git a/test_programs/execution_success/traits_in_crates_1/crate1/src/lib.nr b/test_programs/execution_success/traits_in_crates_1/crate1/src/lib.nr index 62dd5a2c111..e36a263093a 100644 --- a/test_programs/execution_success/traits_in_crates_1/crate1/src/lib.nr +++ b/test_programs/execution_success/traits_in_crates_1/crate1/src/lib.nr @@ -2,7 +2,7 @@ trait MyTrait { fn Add10(&mut self); } -impl MyTrait for dep::crate2::MyStruct { +impl MyTrait for crate2::MyStruct { fn Add10(&mut self) { self.Q += 10; } diff --git a/test_programs/execution_success/traits_in_crates_1/src/main.nr b/test_programs/execution_success/traits_in_crates_1/src/main.nr index 7ba2f63c5c0..2afec29ee1f 100644 --- a/test_programs/execution_success/traits_in_crates_1/src/main.nr +++ b/test_programs/execution_success/traits_in_crates_1/src/main.nr @@ -1,5 +1,5 @@ fn main(x: Field, y: pub Field) { - let mut V = dep::crate2::MyStruct { Q: x }; + let mut V = crate2::MyStruct { Q: x }; V.Add10(); assert(V.Q == y); } diff --git a/test_programs/execution_success/traits_in_crates_2/crate2/src/lib.nr b/test_programs/execution_success/traits_in_crates_2/crate2/src/lib.nr index 38870489131..fe6a94a4a95 100644 --- a/test_programs/execution_success/traits_in_crates_2/crate2/src/lib.nr +++ b/test_programs/execution_success/traits_in_crates_2/crate2/src/lib.nr @@ -2,7 +2,7 @@ struct MyStruct { Q: Field, } -impl dep::crate1::MyTrait for MyStruct { +impl crate1::MyTrait for MyStruct { fn Add10(&mut self) { self.Q += 10; } diff --git a/test_programs/execution_success/traits_in_crates_2/src/main.nr b/test_programs/execution_success/traits_in_crates_2/src/main.nr index 7ba2f63c5c0..2afec29ee1f 100644 --- a/test_programs/execution_success/traits_in_crates_2/src/main.nr +++ b/test_programs/execution_success/traits_in_crates_2/src/main.nr @@ -1,5 +1,5 @@ fn main(x: Field, y: pub Field) { - let mut V = dep::crate2::MyStruct { Q: x }; + let mut V = crate2::MyStruct { Q: x }; V.Add10(); assert(V.Q == y); } diff --git a/test_programs/execution_success/u128/src/main.nr b/test_programs/execution_success/u128/src/main.nr index a403571ea74..4bbdcd1dd26 100644 --- a/test_programs/execution_success/u128/src/main.nr +++ b/test_programs/execution_success/u128/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main(mut x: u32, y: u32, z: u32, big_int: U128, hexa: str<7>) { let a = U128::from_u64s_le(x as u64, x as u64); diff --git a/test_programs/execution_success/unit_value/src/main.nr b/test_programs/execution_success/unit_value/src/main.nr index f3844e03cf2..a488f267b4c 100644 --- a/test_programs/execution_success/unit_value/src/main.nr +++ b/test_programs/execution_success/unit_value/src/main.nr @@ -1,5 +1,5 @@ fn get_transaction() { - dep::std::unsafe::zeroed() + std::unsafe::zeroed() } fn main() { diff --git a/test_programs/noir_test_success/brillig_overflow_checks/src/main.nr b/test_programs/noir_test_success/brillig_overflow_checks/src/main.nr index 5d73ef96d49..35a0c44218f 100644 --- a/test_programs/noir_test_success/brillig_overflow_checks/src/main.nr +++ b/test_programs/noir_test_success/brillig_overflow_checks/src/main.nr @@ -1,4 +1,4 @@ -use dep::std::field::bn254::{TWO_POW_128, assert_gt}; +use std::field::bn254::{TWO_POW_128, assert_gt}; #[test(should_fail_with = "attempt to add with overflow")] unconstrained fn test_overflow_add() { diff --git a/test_programs/noir_test_success/field_comparisons/src/main.nr b/test_programs/noir_test_success/field_comparisons/src/main.nr index 105d82ca755..8613e6d6c4f 100644 --- a/test_programs/noir_test_success/field_comparisons/src/main.nr +++ b/test_programs/noir_test_success/field_comparisons/src/main.nr @@ -1,4 +1,4 @@ -use dep::std::field::bn254::{TWO_POW_128, assert_gt}; +use std::field::bn254::{TWO_POW_128, assert_gt}; #[test(should_fail)] fn test_assert_gt_should_fail_eq() { diff --git a/test_programs/noir_test_success/mock_oracle/src/main.nr b/test_programs/noir_test_success/mock_oracle/src/main.nr index d840ffaef66..4d3dd8d030b 100644 --- a/test_programs/noir_test_success/mock_oracle/src/main.nr +++ b/test_programs/noir_test_success/mock_oracle/src/main.nr @@ -1,4 +1,4 @@ -use dep::std::test::OracleMock; +use std::test::OracleMock; struct Point { x: Field, diff --git a/test_programs/noir_test_success/should_fail_with_matches/src/main.nr b/test_programs/noir_test_success/should_fail_with_matches/src/main.nr index d2b7d155a32..05bdb501819 100644 --- a/test_programs/noir_test_success/should_fail_with_matches/src/main.nr +++ b/test_programs/noir_test_success/should_fail_with_matches/src/main.nr @@ -10,10 +10,10 @@ fn test_should_fail_without_match() { #[test(should_fail_with = "Not equal")] fn test_should_fail_with_runtime_match() { - assert_eq(dep::std::hash::pedersen_commitment([27]).x, 0, "Not equal"); + assert_eq(std::hash::pedersen_commitment([27]).x, 0, "Not equal"); } #[test(should_fail)] fn test_should_fail_without_runtime_match() { - assert_eq(dep::std::hash::pedersen_commitment([27]).x, 0); + assert_eq(std::hash::pedersen_commitment([27]).x, 0); } diff --git a/test_programs/test_libraries/diamond_deps_1/src/lib.nr b/test_programs/test_libraries/diamond_deps_1/src/lib.nr index 60c001ec64e..d76ce5a05e9 100644 --- a/test_programs/test_libraries/diamond_deps_1/src/lib.nr +++ b/test_programs/test_libraries/diamond_deps_1/src/lib.nr @@ -1,4 +1,4 @@ -use dep::dep2::call_dep2; +use dep2::call_dep2; pub fn call_dep1_then_dep2(x: Field, y: Field) -> Field { call_dep2(x, y) diff --git a/test_programs/test_libraries/exporting_lib/src/lib.nr b/test_programs/test_libraries/exporting_lib/src/lib.nr index bfb1819132a..fdd9f139d41 100644 --- a/test_programs/test_libraries/exporting_lib/src/lib.nr +++ b/test_programs/test_libraries/exporting_lib/src/lib.nr @@ -4,6 +4,6 @@ struct MyStruct { type FooStruct = MyStruct; -fn is_struct_zero(val: MyStruct) -> bool { +pub fn is_struct_zero(val: MyStruct) -> bool { val.inner == 0 } diff --git a/test_programs/test_libraries/reexporting_lib/src/lib.nr b/test_programs/test_libraries/reexporting_lib/src/lib.nr index f12dfe01ecd..1bced548304 100644 --- a/test_programs/test_libraries/reexporting_lib/src/lib.nr +++ b/test_programs/test_libraries/reexporting_lib/src/lib.nr @@ -1,3 +1,3 @@ -use dep::exporting_lib::{MyStruct, FooStruct}; +use exporting_lib::{MyStruct, FooStruct}; -use dep::exporting_lib as lib; +use exporting_lib as lib; diff --git a/tooling/debugger/src/source_code_printer.rs b/tooling/debugger/src/source_code_printer.rs index e298eb8aadd..ad511563477 100644 --- a/tooling/debugger/src/source_code_printer.rs +++ b/tooling/debugger/src/source_code_printer.rs @@ -143,7 +143,7 @@ fn render_line( // // Consider for example the file (line numbers added to facilitate this doc): // ``` -// 1 use dep::std::hash::poseidon; +// 1 use std::hash::poseidon; // 2 // 3 fn main(x1: [Field; 2], y1: pub Field, x2: [Field; 4], y2: pub Field) { // 4 let hash1 = poseidon::bn254::hash_2(x1); @@ -157,7 +157,7 @@ fn render_line( // // If the location to render is `poseidon::bn254::hash_2(x1)`, we'll render the file as: // ``` -// 1 use dep::std::hash::poseidon; +// 1 use std::hash::poseidon; // 2 // 3 fn main(x1: [Field; 2], y1: pub Field, x2: [Field; 4], y2: pub Field) { // 4 let hash1 = poseidon::bn254::hash_2(x1); diff --git a/tooling/nargo_fmt/src/rewrite/imports.rs b/tooling/nargo_fmt/src/rewrite/imports.rs index 564ef3fa370..6432b950608 100644 --- a/tooling/nargo_fmt/src/rewrite/imports.rs +++ b/tooling/nargo_fmt/src/rewrite/imports.rs @@ -12,7 +12,6 @@ use crate::{ pub(crate) enum UseSegment { Ident(String, Option), List(Vec), - Dep, Crate, } @@ -48,7 +47,6 @@ impl UseSegment { format!("{{{list_str}}}") } } - UseSegment::Dep => "dep".into(), UseSegment::Crate => "crate".into(), } } @@ -65,7 +63,6 @@ impl UseTree { match use_tree.prefix.kind { ast::PathKind::Crate => result.path.push(UseSegment::Crate), - ast::PathKind::Dep => result.path.push(UseSegment::Dep), ast::PathKind::Plain => {} }; diff --git a/tooling/nargo_fmt/tests/expected/contract.nr b/tooling/nargo_fmt/tests/expected/contract.nr index 97a6ebd6b77..e3a5877725a 100644 --- a/tooling/nargo_fmt/tests/expected/contract.nr +++ b/tooling/nargo_fmt/tests/expected/contract.nr @@ -3,11 +3,11 @@ // Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. // Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. contract Benchmarking { - use dep::aztec::protocol_types::abis::function_selector::FunctionSelector; + use aztec::protocol_types::abis::function_selector::FunctionSelector; - use dep::value_note::{utils::{increment, decrement}, value_note::{VALUE_NOTE_LEN, ValueNote, ValueNoteMethods}}; + use value_note::{utils::{increment, decrement}, value_note::{VALUE_NOTE_LEN, ValueNote, ValueNoteMethods}}; - use dep::aztec::{ + use aztec::{ context::Context, note::{note_getter_options::NoteGetterOptions, note_header::NoteHeader}, log::emit_unencrypted_log, state_vars::{Map, PublicMutable, PrivateSet}, types::type_serialization::field_serialization::{FieldSerializationMethods, FIELD_SERIALIZED_LEN}, diff --git a/tooling/nargo_fmt/tests/expected/import_braces.nr b/tooling/nargo_fmt/tests/expected/import_braces.nr index 49c9d09001e..9c74c477f5f 100644 --- a/tooling/nargo_fmt/tests/expected/import_braces.nr +++ b/tooling/nargo_fmt/tests/expected/import_braces.nr @@ -1 +1 @@ -use dep::std::hash::sha256; +use std::hash::sha256; diff --git a/tooling/nargo_fmt/tests/expected/let.nr b/tooling/nargo_fmt/tests/expected/let.nr index c57801155a0..df03f7c0b04 100644 --- a/tooling/nargo_fmt/tests/expected/let.nr +++ b/tooling/nargo_fmt/tests/expected/let.nr @@ -51,10 +51,10 @@ fn let_() { let expr = Expr { /*A boolean literal (true, false).*/ kind: ExprKind::Bool(true) }; - let mut V = dep::crate2::MyStruct { Q: x }; - let mut V = dep::crate2::MyStruct {}; - let mut V = dep::crate2::MyStruct {/*test*/}; - let mut V = dep::crate2::MyStruct { + let mut V = crate2::MyStruct { Q: x }; + let mut V = crate2::MyStruct {}; + let mut V = crate2::MyStruct {/*test*/}; + let mut V = crate2::MyStruct { // sad }; } diff --git a/tooling/nargo_fmt/tests/expected/print.nr b/tooling/nargo_fmt/tests/expected/print.nr index 3bce0941da2..417467f977f 100644 --- a/tooling/nargo_fmt/tests/expected/print.nr +++ b/tooling/nargo_fmt/tests/expected/print.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main() { std::print("Hello world"); diff --git a/tooling/nargo_fmt/tests/expected/print2.nr b/tooling/nargo_fmt/tests/expected/print2.nr index 3bce0941da2..417467f977f 100644 --- a/tooling/nargo_fmt/tests/expected/print2.nr +++ b/tooling/nargo_fmt/tests/expected/print2.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main() { std::print("Hello world"); diff --git a/tooling/nargo_fmt/tests/expected/singleton_import.nr b/tooling/nargo_fmt/tests/expected/singleton_import.nr new file mode 100644 index 00000000000..6df6580589c --- /dev/null +++ b/tooling/nargo_fmt/tests/expected/singleton_import.nr @@ -0,0 +1,2 @@ +use std; +use some_crate; diff --git a/tooling/nargo_fmt/tests/input/contract.nr b/tooling/nargo_fmt/tests/input/contract.nr index 97a6ebd6b77..e3a5877725a 100644 --- a/tooling/nargo_fmt/tests/input/contract.nr +++ b/tooling/nargo_fmt/tests/input/contract.nr @@ -3,11 +3,11 @@ // Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. // Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. contract Benchmarking { - use dep::aztec::protocol_types::abis::function_selector::FunctionSelector; + use aztec::protocol_types::abis::function_selector::FunctionSelector; - use dep::value_note::{utils::{increment, decrement}, value_note::{VALUE_NOTE_LEN, ValueNote, ValueNoteMethods}}; + use value_note::{utils::{increment, decrement}, value_note::{VALUE_NOTE_LEN, ValueNote, ValueNoteMethods}}; - use dep::aztec::{ + use aztec::{ context::Context, note::{note_getter_options::NoteGetterOptions, note_header::NoteHeader}, log::emit_unencrypted_log, state_vars::{Map, PublicMutable, PrivateSet}, types::type_serialization::field_serialization::{FieldSerializationMethods, FIELD_SERIALIZED_LEN}, diff --git a/tooling/nargo_fmt/tests/input/import_braces.nr b/tooling/nargo_fmt/tests/input/import_braces.nr index 88c7e9562a8..0647bbaa580 100644 --- a/tooling/nargo_fmt/tests/input/import_braces.nr +++ b/tooling/nargo_fmt/tests/input/import_braces.nr @@ -1 +1 @@ -use dep::std::hash::{sha256}; \ No newline at end of file +use std::hash::{sha256}; diff --git a/tooling/nargo_fmt/tests/input/let.nr b/tooling/nargo_fmt/tests/input/let.nr index 67c4ab8bd52..4918a92a51a 100644 --- a/tooling/nargo_fmt/tests/input/let.nr +++ b/tooling/nargo_fmt/tests/input/let.nr @@ -26,10 +26,10 @@ kind: ExprKind::Bool(true), let expr = Expr {/*A boolean literal (true, false).*/kind: ExprKind::Bool(true),}; - let mut V = dep::crate2::MyStruct { Q: x }; - let mut V = dep::crate2::MyStruct {}; - let mut V = dep::crate2::MyStruct {/*test*/}; - let mut V = dep::crate2::MyStruct { + let mut V = crate2::MyStruct { Q: x }; + let mut V = crate2::MyStruct {}; + let mut V = crate2::MyStruct {/*test*/}; + let mut V = crate2::MyStruct { // sad }; } diff --git a/tooling/nargo_fmt/tests/input/print.nr b/tooling/nargo_fmt/tests/input/print.nr index 3bce0941da2..417467f977f 100644 --- a/tooling/nargo_fmt/tests/input/print.nr +++ b/tooling/nargo_fmt/tests/input/print.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main() { std::print("Hello world"); diff --git a/tooling/nargo_fmt/tests/input/print2.nr b/tooling/nargo_fmt/tests/input/print2.nr index 3bce0941da2..417467f977f 100644 --- a/tooling/nargo_fmt/tests/input/print2.nr +++ b/tooling/nargo_fmt/tests/input/print2.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main() { std::print("Hello world"); diff --git a/tooling/nargo_fmt/tests/input/singleton_import.nr b/tooling/nargo_fmt/tests/input/singleton_import.nr new file mode 100644 index 00000000000..6df6580589c --- /dev/null +++ b/tooling/nargo_fmt/tests/input/singleton_import.nr @@ -0,0 +1,2 @@ +use std; +use some_crate; diff --git a/tooling/noir_js/test/noir_compiled_examples/assert_lt/src/main.nr b/tooling/noir_js/test/noir_compiled_examples/assert_lt/src/main.nr index a9aaae5f2f7..79a1d892d89 100644 --- a/tooling/noir_js/test/noir_compiled_examples/assert_lt/src/main.nr +++ b/tooling/noir_js/test/noir_compiled_examples/assert_lt/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main(x: u64, y: pub u64) -> pub u64 { // We include a println statement to show that noirJS will ignore this and continue execution From 425116f806be8f6e6bb964ef86130e6d9a180646 Mon Sep 17 00:00:00 2001 From: "Michael J. Klein" Date: Tue, 30 Apr 2024 12:28:04 -0400 Subject: [PATCH 02/26] removing from aztec_macros, expected-to-be failing test_programs, etc --- .../compute_note_hash_and_nullifier.rs | 8 +++---- .../src/transforms/contract_interface.rs | 24 +++++++++---------- aztec_macros/src/transforms/note_interface.rs | 14 +++++------ aztec_macros/src/transforms/storage.rs | 4 ++-- .../circuits/recursion/src/main.nr | 2 +- compiler/noirc_frontend/src/debug/mod.rs | 2 +- compiler/noirc_frontend/src/parser/parser.rs | 2 +- .../wasm/test/fixtures/deps/lib-a/src/lib.nr | 2 +- .../fixtures/deps/lib-c/src/module/foo.nr | 2 +- .../test/fixtures/noir-contract/src/main.nr | 2 +- .../wasm/test/fixtures/with-deps/src/main.nr | 2 +- docs/docs/how_to/merkle-proof.mdx | 2 +- .../docs/noir/concepts/data_types/integers.md | 2 +- docs/docs/noir/concepts/data_types/slices.mdx | 2 +- docs/docs/noir/concepts/data_types/strings.md | 2 +- docs/docs/noir/concepts/traits.md | 4 ++-- .../modules_packages_crates/dependencies.md | 12 +++++----- .../standard_library/containers/hashmap.md | 2 +- .../cryptographic_primitives/ec_primitives.md | 2 +- .../cryptographic_primitives/eddsa.mdx | 2 +- docs/docs/noir/standard_library/recursion.md | 2 +- .../array_length_defaulting/src/main.nr | 2 +- .../assert_constant_fail/src/main.nr | 2 +- .../brillig_nested_slices/src/main.nr | 2 +- .../dep_impl_primitive/src/main.nr | 2 +- .../compile_failure/depend_on_bin/src/main.nr | 2 +- .../negate_unsigned/src/main.nr | 2 +- .../orphaned_trait_impl/src/main.nr | 2 +- .../restricted_bit_sizes/src/main.nr | 2 +- .../div_by_zero_constants/src/main.nr | 2 +- .../div_by_zero_numerator_witness/src/main.nr | 2 +- .../div_by_zero_witness/src/main.nr | 2 +- .../hashmap_load_factor/src/main.nr | 6 ++--- .../should_fail_mismatch/src/main.nr | 2 +- 34 files changed, 63 insertions(+), 63 deletions(-) diff --git a/aztec_macros/src/transforms/compute_note_hash_and_nullifier.rs b/aztec_macros/src/transforms/compute_note_hash_and_nullifier.rs index f624cde9969..6ca92a50417 100644 --- a/aztec_macros/src/transforms/compute_note_hash_and_nullifier.rs +++ b/aztec_macros/src/transforms/compute_note_hash_and_nullifier.rs @@ -174,7 +174,7 @@ fn generate_compute_note_hash_and_nullifier_source( format!( " unconstrained fn compute_note_hash_and_nullifier( - contract_address: dep::aztec::protocol_types::address::AztecAddress, + contract_address: aztec::protocol_types::address::AztecAddress, nonce: Field, storage_slot: Field, note_type_id: Field, @@ -191,7 +191,7 @@ fn generate_compute_note_hash_and_nullifier_source( let if_statements: Vec = note_types.iter().map(|note_type| format!( "if (note_type_id == {0}::get_note_type_id()) {{ - dep::aztec::note::utils::compute_note_hash_and_nullifier({0}::deserialize_content, note_header, serialized_note) + aztec::note::utils::compute_note_hash_and_nullifier({0}::deserialize_content, note_header, serialized_note) }}" , note_type)).collect(); @@ -205,13 +205,13 @@ fn generate_compute_note_hash_and_nullifier_source( format!( " unconstrained fn compute_note_hash_and_nullifier( - contract_address: dep::aztec::protocol_types::address::AztecAddress, + contract_address: aztec::protocol_types::address::AztecAddress, nonce: Field, storage_slot: Field, note_type_id: Field, serialized_note: [Field; {}] ) -> pub [Field; 4] {{ - let note_header = dep::aztec::prelude::NoteHeader::new(contract_address, nonce, storage_slot); + let note_header = aztec::prelude::NoteHeader::new(contract_address, nonce, storage_slot); {} }}", diff --git a/aztec_macros/src/transforms/contract_interface.rs b/aztec_macros/src/transforms/contract_interface.rs index 5f68ce98c8a..3ff7556f751 100644 --- a/aztec_macros/src/transforms/contract_interface.rs +++ b/aztec_macros/src/transforms/contract_interface.rs @@ -29,8 +29,8 @@ use crate::utils::{ // for i in 0..third_arg.len() { // args_acc = args_acc.append(third_arg[i].serialize().as_slice()); // } -// let args_hash = dep::aztec::hash::hash_args(args_acc); -// assert(args_hash == dep::aztec::oracle::arguments::pack_arguments(args_acc)); +// let args_hash = aztec::hash::hash_args(args_acc); +// assert(args_hash == aztec::oracle::arguments::pack_arguments(args_acc)); // PublicCallInterface { // target_contract: self.target_contract, // selector: FunctionSelector::from_signature("SELECTOR_PLACEHOLDER"), @@ -55,7 +55,7 @@ pub fn stub_function(aztec_visibility: &str, func: &NoirFunction) -> String { .join(", "); let fn_return_type: noirc_frontend::ast::UnresolvedType = func.return_type(); - let fn_selector = format!("dep::aztec::protocol_types::abis::function_selector::FunctionSelector::from_signature(\"{}\")", SELECTOR_PLACEHOLDER); + let fn_selector = format!("aztec::protocol_types::abis::function_selector::FunctionSelector::from_signature(\"{}\")", SELECTOR_PLACEHOLDER); let parameters = func.parameters(); let is_void = if matches!(fn_return_type.typ, UnresolvedTypeData::Unit) { "Void" } else { "" }; @@ -90,8 +90,8 @@ pub fn stub_function(aztec_visibility: &str, func: &NoirFunction) -> String { format!( "let mut args_acc: [Field] = &[]; {} - let args_hash = dep::aztec::hash::hash_args(args_acc); - assert(args_hash == dep::aztec::oracle::arguments::pack_arguments(args_acc));", + let args_hash = aztec::hash::hash_args(args_acc); + assert(args_hash == aztec::oracle::arguments::pack_arguments(args_acc));", call_args ) } else { @@ -100,7 +100,7 @@ pub fn stub_function(aztec_visibility: &str, func: &NoirFunction) -> String { let fn_body = format!( "{} - dep::aztec::context::{}{}CallInterface {{ + aztec::context::{}{}CallInterface {{ target_contract: self.target_contract, selector: {}, args_hash, @@ -108,7 +108,7 @@ pub fn stub_function(aztec_visibility: &str, func: &NoirFunction) -> String { args_hash, aztec_visibility, is_void, fn_selector, ); format!( - "pub fn {}(self, {}) -> dep::aztec::context::{}{}CallInterface{} {{ + "pub fn {}(self, {}) -> aztec::context::{}{}CallInterface{} {{ {} }}", fn_name, fn_parameters, aztec_visibility, is_void, return_type_hint, fn_body @@ -122,7 +122,7 @@ pub fn stub_function(aztec_visibility: &str, func: &NoirFunction) -> String { ); let fn_body = format!( "{} - dep::aztec::context::Avm{}CallInterface {{ + aztec::context::Avm{}CallInterface {{ target_contract: self.target_contract, selector: {}, args: args_acc, @@ -130,7 +130,7 @@ pub fn stub_function(aztec_visibility: &str, func: &NoirFunction) -> String { args, is_void, fn_selector, ); format!( - "pub fn {}(self, {}) -> dep::aztec::context::Avm{}CallInterface{} {{ + "pub fn {}(self, {}) -> aztec::context::Avm{}CallInterface{} {{ {} }}", fn_name, fn_parameters, is_void, return_type_hint, fn_body @@ -149,14 +149,14 @@ pub fn generate_contract_interface( let contract_interface = format!( " struct {0} {{ - target_contract: dep::aztec::protocol_types::address::AztecAddress + target_contract: aztec::protocol_types::address::AztecAddress }} impl {0} {{ {1} pub fn at( - target_contract: dep::aztec::protocol_types::address::AztecAddress + target_contract: aztec::protocol_types::address::AztecAddress ) -> Self {{ Self {{ target_contract }} }} @@ -164,7 +164,7 @@ pub fn generate_contract_interface( #[contract_library_method] pub fn at( - target_contract: dep::aztec::protocol_types::address::AztecAddress + target_contract: aztec::protocol_types::address::AztecAddress ) -> {0} {{ {0} {{ target_contract }} }} diff --git a/aztec_macros/src/transforms/note_interface.rs b/aztec_macros/src/transforms/note_interface.rs index f183c69b27a..ba57e984d90 100644 --- a/aztec_macros/src/transforms/note_interface.rs +++ b/aztec_macros/src/transforms/note_interface.rs @@ -199,7 +199,7 @@ fn generate_note_get_header( ) -> Result { let function_source = format!( " - fn get_header(note: {}) -> dep::aztec::note::note_header::NoteHeader {{ + fn get_header(note: {}) -> aztec::note::note_header::NoteHeader {{ note.{} }} ", @@ -229,7 +229,7 @@ fn generate_note_set_header( ) -> Result { let function_source = format!( " - fn set_header(self: &mut {}, header: dep::aztec::note::note_header::NoteHeader) {{ + fn set_header(self: &mut {}, header: aztec::note::note_header::NoteHeader) {{ self.{} = header; }} ", @@ -418,7 +418,7 @@ fn generate_note_properties_fn( // Automatically generate the method to compute the note's content hash as: // fn compute_note_content_hash(self: NoteType) -> Field { -// dep::aztec::hash::pedersen_hash(self.serialize_content(), dep::aztec::protocol_types::constants::GENERATOR_INDEX__NOTE_CONTENT_HASH) +// aztec::hash::pedersen_hash(self.serialize_content(), aztec::protocol_types::constants::GENERATOR_INDEX__NOTE_CONTENT_HASH) // } // fn generate_compute_note_content_hash( @@ -428,7 +428,7 @@ fn generate_compute_note_content_hash( let function_source = format!( " fn compute_note_content_hash(self: {}) -> Field {{ - dep::aztec::hash::pedersen_hash(self.serialize_content(), dep::aztec::protocol_types::constants::GENERATOR_INDEX__NOTE_CONTENT_HASH) + aztec::hash::pedersen_hash(self.serialize_content(), aztec::protocol_types::constants::GENERATOR_INDEX__NOTE_CONTENT_HASH) }} ", note_type @@ -488,7 +488,7 @@ fn generate_note_properties_struct_source( .filter_map(|(field_name, _)| { if field_name != note_header_field_name { Some(format!( - "{}: dep::aztec::note::note_getter_options::PropertySelector", + "{}: aztec::note::note_getter_options::PropertySelector", field_name )) } else { @@ -518,7 +518,7 @@ fn generate_note_properties_fn_source( .filter_map(|(index, (field_name, _))| { if field_name != note_header_field_name { Some(format!( - "{}: dep::aztec::note::note_getter_options::PropertySelector {{ index: {}, offset: 0, length: 32 }}", + "{}: aztec::note::note_getter_options::PropertySelector {{ index: {}, offset: 0, length: 32 }}", field_name, index )) @@ -596,7 +596,7 @@ fn generate_note_deserialize_content_source( } } else { format!( - "{}: dep::aztec::note::note_header::NoteHeader::empty()", + "{}: aztec::note::note_header::NoteHeader::empty()", note_header_field_name ) } diff --git a/aztec_macros/src/transforms/storage.rs b/aztec_macros/src/transforms/storage.rs index 1e3cc011715..ef2179a28d3 100644 --- a/aztec_macros/src/transforms/storage.rs +++ b/aztec_macros/src/transforms/storage.rs @@ -452,10 +452,10 @@ pub fn generate_storage_layout( let mut storable_fields_impl = vec![]; definition.fields.iter().enumerate().for_each(|(index, (field_ident, field_type))| { - storable_fields.push(format!("{}: dep::aztec::prelude::Storable", field_ident, index)); + storable_fields.push(format!("{}: aztec::prelude::Storable", field_ident, index)); generic_args.push(format!("N{}", index)); storable_fields_impl.push(format!( - "{}: dep::aztec::prelude::Storable {{ slot: 0, typ: \"{}\" }}", + "{}: aztec::prelude::Storable {{ slot: 0, typ: \"{}\" }}", field_ident, field_type.to_string().replace("plain::", "") )); diff --git a/compiler/integration-tests/circuits/recursion/src/main.nr b/compiler/integration-tests/circuits/recursion/src/main.nr index 173207766fb..4f8d1713f3b 100644 --- a/compiler/integration-tests/circuits/recursion/src/main.nr +++ b/compiler/integration-tests/circuits/recursion/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main( verification_key: [Field; 114], diff --git a/compiler/noirc_frontend/src/debug/mod.rs b/compiler/noirc_frontend/src/debug/mod.rs index 3e7d123398b..ef612449f64 100644 --- a/compiler/noirc_frontend/src/debug/mod.rs +++ b/compiler/noirc_frontend/src/debug/mod.rs @@ -467,7 +467,7 @@ impl DebugInstrumenter { .join(",\n"); let (program, errors) = parse_program(&format!( r#" - use dep::__debug::{{ + use __debug::{{ __debug_var_assign, __debug_var_drop, __debug_fn_enter, diff --git a/compiler/noirc_frontend/src/parser/parser.rs b/compiler/noirc_frontend/src/parser/parser.rs index 4a85f6cb18f..6993c48a0ed 100644 --- a/compiler/noirc_frontend/src/parser/parser.rs +++ b/compiler/noirc_frontend/src/parser/parser.rs @@ -1642,7 +1642,7 @@ mod test { "use foo::{bar, hello}", "use foo::{bar as bar2, hello}", "use foo::{bar as bar2, hello::{foo}, nested::{foo, bar}}", - "use dep::{std::println, bar::baz}", + "use std::{println, bar::baz}", ]; let invalid_use_statements = [ diff --git a/compiler/wasm/test/fixtures/deps/lib-a/src/lib.nr b/compiler/wasm/test/fixtures/deps/lib-a/src/lib.nr index 3f8fa051daf..c38188d0119 100644 --- a/compiler/wasm/test/fixtures/deps/lib-a/src/lib.nr +++ b/compiler/wasm/test/fixtures/deps/lib-a/src/lib.nr @@ -1,4 +1,4 @@ -use dep::lib_b::assert_non_zero; +use lib_b::assert_non_zero; pub fn divide(a: u64, b: u64) -> u64 { assert_non_zero(b); diff --git a/compiler/wasm/test/fixtures/deps/lib-c/src/module/foo.nr b/compiler/wasm/test/fixtures/deps/lib-c/src/module/foo.nr index 0376cd4cb87..23b6659b3c5 100644 --- a/compiler/wasm/test/fixtures/deps/lib-c/src/module/foo.nr +++ b/compiler/wasm/test/fixtures/deps/lib-c/src/module/foo.nr @@ -1,3 +1,3 @@ pub fn bar(param: Field) -> Field { - dep::std::hash::pedersen_hash([param]) + std::hash::pedersen_hash([param]) } diff --git a/compiler/wasm/test/fixtures/noir-contract/src/main.nr b/compiler/wasm/test/fixtures/noir-contract/src/main.nr index fc1dc8a5a17..6f63850e3a0 100644 --- a/compiler/wasm/test/fixtures/noir-contract/src/main.nr +++ b/compiler/wasm/test/fixtures/noir-contract/src/main.nr @@ -1,5 +1,5 @@ contract TestContract { - use dep::test::module::foo; + use test::module::foo; fn constructor(param: Field, pub_param: pub Field) -> pub [Field; 2] { [foo::bar(param), param + pub_param] diff --git a/compiler/wasm/test/fixtures/with-deps/src/main.nr b/compiler/wasm/test/fixtures/with-deps/src/main.nr index 056bcc180b4..fe9e7f9ca77 100644 --- a/compiler/wasm/test/fixtures/with-deps/src/main.nr +++ b/compiler/wasm/test/fixtures/with-deps/src/main.nr @@ -1,4 +1,4 @@ -use dep::lib_a::divide; +use lib_a::divide; fn main(x: u64, y: pub u64) { divide(x, y); } diff --git a/docs/docs/how_to/merkle-proof.mdx b/docs/docs/how_to/merkle-proof.mdx index 16c425bed76..ec588f9a801 100644 --- a/docs/docs/how_to/merkle-proof.mdx +++ b/docs/docs/how_to/merkle-proof.mdx @@ -12,7 +12,7 @@ Let's walk through an example of a merkle membership proof in Noir that proves t in a merkle tree. ```rust -use dep::std; +use std; fn main(message : [Field; 62], index : Field, hashpath : [Field; 40], root : Field) { let leaf = std::hash::hash_to_field(message.as_slice()); diff --git a/docs/docs/noir/concepts/data_types/integers.md b/docs/docs/noir/concepts/data_types/integers.md index 1c6b375db49..2914a5a5f0e 100644 --- a/docs/docs/noir/concepts/data_types/integers.md +++ b/docs/docs/noir/concepts/data_types/integers.md @@ -147,7 +147,7 @@ fn wrapping_mul(x: T, y: T) -> T; Example of how it is used: ```rust -use dep::std; +use std; fn main(x: u8, y: u8) -> pub u8 { std::wrapping_add(x, y) diff --git a/docs/docs/noir/concepts/data_types/slices.mdx b/docs/docs/noir/concepts/data_types/slices.mdx index 4eccc677b80..37cb25e2641 100644 --- a/docs/docs/noir/concepts/data_types/slices.mdx +++ b/docs/docs/noir/concepts/data_types/slices.mdx @@ -12,7 +12,7 @@ import Experimental from '@site/src/components/Notes/_experimental.mdx'; A slice is a dynamically-sized view into a sequence of elements. They can be resized at runtime, but because they don't own the data, they cannot be returned from a circuit. You can treat slices as arrays without a constrained size. ```rust -use dep::std::slice; +use std::slice; fn main() -> pub Field { let mut slice: [Field] = &[0; 2]; diff --git a/docs/docs/noir/concepts/data_types/strings.md b/docs/docs/noir/concepts/data_types/strings.md index 311dfd64416..afb73c44d52 100644 --- a/docs/docs/noir/concepts/data_types/strings.md +++ b/docs/docs/noir/concepts/data_types/strings.md @@ -20,7 +20,7 @@ You can use strings in `assert()` functions or print them with `println()`. See more about [Logging](../../standard_library/logging). ```rust -use dep::std; +use std; fn main(message : pub str<11>, hex_as_string : str<4>) { println(message); diff --git a/docs/docs/noir/concepts/traits.md b/docs/docs/noir/concepts/traits.md index ef1445a5907..df7cb9ebda0 100644 --- a/docs/docs/noir/concepts/traits.md +++ b/docs/docs/noir/concepts/traits.md @@ -372,13 +372,13 @@ impls for any trait we need on it. ```rust struct Wrapper { - foo: dep::some_library::Foo, + foo: some_library::Foo, } impl Default for Wrapper { fn default() -> Wrapper { Wrapper { - foo: dep::some_library::Foo::new(), + foo: some_library::Foo::new(), } } } diff --git a/docs/docs/noir/modules_packages_crates/dependencies.md b/docs/docs/noir/modules_packages_crates/dependencies.md index 04c1703d929..51aeefd0972 100644 --- a/docs/docs/noir/modules_packages_crates/dependencies.md +++ b/docs/docs/noir/modules_packages_crates/dependencies.md @@ -70,15 +70,15 @@ You can import a dependency to a Noir file using the following syntax. For examp ecrecover-noir library and local lib_a referenced above: ```rust -use dep::ecrecover; -use dep::lib_a; +use ecrecover; +use lib_a; ``` You can also import only the specific parts of dependency that you want to use, like so: ```rust -use dep::std::hash::sha256; -use dep::std::scalar_mul::fixed_base_embedded_curve; +use std::hash::sha256; +use std::scalar_mul::fixed_base_embedded_curve; ``` Lastly, as demonstrated in the @@ -86,7 +86,7 @@ Lastly, as demonstrated in the can import multiple items in the same line by enclosing them in curly braces: ```rust -use dep::std::ec::tecurve::affine::{Curve, Point}; +use std::ec::tecurve::affine::{Curve, Point}; ``` We don't have a way to consume libraries from inside a [workspace](./workspaces) as external dependencies right now. @@ -100,7 +100,7 @@ Note that when you import a dependency, you also get access to all of the depend For example, the [phy_vector](https://github.com/resurgencelabs/phy_vector) library imports an [fraction](https://github.com/resurgencelabs/fraction) library. If you're importing the phy_vector library, then you can access the functions in fractions library like so: ```rust -use dep::phy_vector; +use phy_vector; fn main(x : Field, y : pub Field) { //... diff --git a/docs/docs/noir/standard_library/containers/hashmap.md b/docs/docs/noir/standard_library/containers/hashmap.md index 2b9f4895722..651e7f5723b 100644 --- a/docs/docs/noir/standard_library/containers/hashmap.md +++ b/docs/docs/noir/standard_library/containers/hashmap.md @@ -21,7 +21,7 @@ Example: ```rust // Create a mapping from Fields to u32s with a maximum length of 12 // using a poseidon2 hasher -use dep::std::hash::poseidon2::Poseidon2Hasher; +use std::hash::poseidon2::Poseidon2Hasher; let mut map: HashMap> = HashMap::default(); map.insert(1, 2); diff --git a/docs/docs/noir/standard_library/cryptographic_primitives/ec_primitives.md b/docs/docs/noir/standard_library/cryptographic_primitives/ec_primitives.md index d2b42d67b7c..f839b4a228e 100644 --- a/docs/docs/noir/standard_library/cryptographic_primitives/ec_primitives.md +++ b/docs/docs/noir/standard_library/cryptographic_primitives/ec_primitives.md @@ -81,7 +81,7 @@ from the private key. This is a matter of using scalar multiplication. In the ca for example, this code would do: ```rust -use dep::std::ec::tecurve::affine::{Curve, Point}; +use std::ec::tecurve::affine::{Curve, Point}; fn bjj_pub_key(priv_key: Field) -> Point { diff --git a/docs/docs/noir/standard_library/cryptographic_primitives/eddsa.mdx b/docs/docs/noir/standard_library/cryptographic_primitives/eddsa.mdx index c2c0624dfad..74b2bc26bdc 100644 --- a/docs/docs/noir/standard_library/cryptographic_primitives/eddsa.mdx +++ b/docs/docs/noir/standard_library/cryptographic_primitives/eddsa.mdx @@ -17,7 +17,7 @@ fn eddsa_poseidon_verify(public_key_x : Field, public_key_y : Field, signature_s It is also possible to specify the hash algorithm used for the signature by using the `eddsa_verify_with_hasher` function with a parameter implementing the Hasher trait. For instance, if you want to use Poseidon2 instead, you can do the following: ```rust -use dep::std::hash::poseidon2::Poseidon2Hasher; +use std::hash::poseidon2::Poseidon2Hasher; let mut hasher = Poseidon2Hasher::default(); eddsa_verify_with_hasher(pub_key_a.x, pub_key_a.y, s_a, r8_a.x, r8_a.y, msg, &mut hasher); diff --git a/docs/docs/noir/standard_library/recursion.md b/docs/docs/noir/standard_library/recursion.md index a93894043dc..62a2e436b69 100644 --- a/docs/docs/noir/standard_library/recursion.md +++ b/docs/docs/noir/standard_library/recursion.md @@ -42,7 +42,7 @@ This is a black box function. Read [this section](./black_box_fns) to learn more ## Example usage ```rust -use dep::std; +use std; fn main( verification_key : [Field; 114], diff --git a/test_programs/compile_failure/array_length_defaulting/src/main.nr b/test_programs/compile_failure/array_length_defaulting/src/main.nr index 216a9ae3f0c..40543db2870 100644 --- a/test_programs/compile_failure/array_length_defaulting/src/main.nr +++ b/test_programs/compile_failure/array_length_defaulting/src/main.nr @@ -1,5 +1,5 @@ fn main() { - let x = dep::std::unsafe::zeroed(); + let x = std::unsafe::zeroed(); foo(x); } diff --git a/test_programs/compile_failure/assert_constant_fail/src/main.nr b/test_programs/compile_failure/assert_constant_fail/src/main.nr index cf682607083..b8d5d255228 100644 --- a/test_programs/compile_failure/assert_constant_fail/src/main.nr +++ b/test_programs/compile_failure/assert_constant_fail/src/main.nr @@ -1,4 +1,4 @@ -use dep::std::assert_constant; +use std::assert_constant; fn main(x: Field) { foo(5, x); diff --git a/test_programs/compile_failure/brillig_nested_slices/src/main.nr b/test_programs/compile_failure/brillig_nested_slices/src/main.nr index 3d8a6748ccf..ee61195cf8f 100644 --- a/test_programs/compile_failure/brillig_nested_slices/src/main.nr +++ b/test_programs/compile_failure/brillig_nested_slices/src/main.nr @@ -1,4 +1,4 @@ -use dep::std::slice; +use std::slice; // Tests nested slice passing to/from functions unconstrained fn push_back_to_slice(slice: [T], item: T) -> [T] { slice.push_back(item) diff --git a/test_programs/compile_failure/dep_impl_primitive/src/main.nr b/test_programs/compile_failure/dep_impl_primitive/src/main.nr index e61ae82b62c..40578574c75 100644 --- a/test_programs/compile_failure/dep_impl_primitive/src/main.nr +++ b/test_programs/compile_failure/dep_impl_primitive/src/main.nr @@ -1,4 +1,4 @@ -use dep::bad_impl; +use bad_impl; fn main(x: Field) { x.something(); diff --git a/test_programs/compile_failure/depend_on_bin/src/main.nr b/test_programs/compile_failure/depend_on_bin/src/main.nr index 4e03e8eb41e..d7aff600fe6 100644 --- a/test_programs/compile_failure/depend_on_bin/src/main.nr +++ b/test_programs/compile_failure/depend_on_bin/src/main.nr @@ -1,4 +1,4 @@ -use dep::bin_dep; +use bin_dep; fn main(x : Field) { assert(x == 1); diff --git a/test_programs/compile_failure/negate_unsigned/src/main.nr b/test_programs/compile_failure/negate_unsigned/src/main.nr index db5f9b0820f..79212acaf42 100644 --- a/test_programs/compile_failure/negate_unsigned/src/main.nr +++ b/test_programs/compile_failure/negate_unsigned/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main() { let var = -1 as u8; diff --git a/test_programs/compile_failure/orphaned_trait_impl/src/main.nr b/test_programs/compile_failure/orphaned_trait_impl/src/main.nr index dfd88d8f074..dd04aa454b2 100644 --- a/test_programs/compile_failure/orphaned_trait_impl/src/main.nr +++ b/test_programs/compile_failure/orphaned_trait_impl/src/main.nr @@ -1,4 +1,4 @@ -impl dep::crate1::MyTrait for dep::crate2::MyStruct { +impl crate1::MyTrait for crate2::MyStruct { } fn main(x: Field, y: pub Field) { diff --git a/test_programs/compile_failure/restricted_bit_sizes/src/main.nr b/test_programs/compile_failure/restricted_bit_sizes/src/main.nr index 01e72bfcfd7..a3fea13cc3a 100644 --- a/test_programs/compile_failure/restricted_bit_sizes/src/main.nr +++ b/test_programs/compile_failure/restricted_bit_sizes/src/main.nr @@ -1,4 +1,4 @@ -use dep::std::assert_constant; +use std::assert_constant; fn main() -> pub u63 { 5 diff --git a/test_programs/execution_failure/div_by_zero_constants/src/main.nr b/test_programs/execution_failure/div_by_zero_constants/src/main.nr index 58adc5444b1..58108769b35 100644 --- a/test_programs/execution_failure/div_by_zero_constants/src/main.nr +++ b/test_programs/execution_failure/div_by_zero_constants/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main() { let a: Field = 3 / 0; diff --git a/test_programs/execution_failure/div_by_zero_numerator_witness/src/main.nr b/test_programs/execution_failure/div_by_zero_numerator_witness/src/main.nr index f51b26d5ba1..b3e0b43982a 100644 --- a/test_programs/execution_failure/div_by_zero_numerator_witness/src/main.nr +++ b/test_programs/execution_failure/div_by_zero_numerator_witness/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main(x: Field) { let a: Field = x / 0; diff --git a/test_programs/execution_failure/div_by_zero_witness/src/main.nr b/test_programs/execution_failure/div_by_zero_witness/src/main.nr index a814f88f320..c4fb68e6c57 100644 --- a/test_programs/execution_failure/div_by_zero_witness/src/main.nr +++ b/test_programs/execution_failure/div_by_zero_witness/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; // It is expected that `y` must be equal to 0. fn main(x: Field, y: pub Field) { let a: Field = x / y; diff --git a/test_programs/execution_failure/hashmap_load_factor/src/main.nr b/test_programs/execution_failure/hashmap_load_factor/src/main.nr index 907c3628142..e95da67a084 100644 --- a/test_programs/execution_failure/hashmap_load_factor/src/main.nr +++ b/test_programs/execution_failure/hashmap_load_factor/src/main.nr @@ -1,6 +1,6 @@ -use dep::std::collections::map::HashMap; -use dep::std::hash::BuildHasherDefault; -use dep::std::hash::poseidon2::Poseidon2Hasher; +use std::collections::map::HashMap; +use std::hash::BuildHasherDefault; +use std::hash::poseidon2::Poseidon2Hasher; struct Entry{ key: Field, diff --git a/test_programs/noir_test_failure/should_fail_mismatch/src/main.nr b/test_programs/noir_test_failure/should_fail_mismatch/src/main.nr index 253e999ce07..08a9234a752 100644 --- a/test_programs/noir_test_failure/should_fail_mismatch/src/main.nr +++ b/test_programs/noir_test_failure/should_fail_mismatch/src/main.nr @@ -11,5 +11,5 @@ fn test_with_extra_space() { #[test(should_fail_with = "Not equal")] fn test_runtime_mismatch() { // We use a pedersen commitment here so that the assertion failure is only known at runtime. - assert_eq(dep::std::hash::pedersen_commitment([27]).x, 0, "Not equal "); + assert_eq(std::hash::pedersen_commitment([27]).x, 0, "Not equal "); } From ec7eb40074e7475aa65476520203d8c2950938c1 Mon Sep 17 00:00:00 2001 From: "Michael J. Klein" Date: Tue, 30 Apr 2024 13:12:36 -0400 Subject: [PATCH 03/26] only resolve path externally when unresolved internally, i.e. not when other errors occur, make backwards compatible --- .../src/transforms/contract_interface.rs | 5 +++- aztec_macros/src/transforms/note_interface.rs | 10 ++----- .../src/hir/resolution/import.rs | 29 +++++++++++------- compiler/noirc_frontend/src/lexer/token.rs | 3 ++ .../noirc_frontend/src/noir_parser.lalrpop | 4 +-- .../noirc_frontend/src/parser/parser/path.rs | 30 +++++++++++-------- 6 files changed, 47 insertions(+), 34 deletions(-) diff --git a/aztec_macros/src/transforms/contract_interface.rs b/aztec_macros/src/transforms/contract_interface.rs index 3ff7556f751..25cff7a4f7a 100644 --- a/aztec_macros/src/transforms/contract_interface.rs +++ b/aztec_macros/src/transforms/contract_interface.rs @@ -55,7 +55,10 @@ pub fn stub_function(aztec_visibility: &str, func: &NoirFunction) -> String { .join(", "); let fn_return_type: noirc_frontend::ast::UnresolvedType = func.return_type(); - let fn_selector = format!("aztec::protocol_types::abis::function_selector::FunctionSelector::from_signature(\"{}\")", SELECTOR_PLACEHOLDER); + let fn_selector = format!( + "aztec::protocol_types::abis::function_selector::FunctionSelector::from_signature(\"{}\")", + SELECTOR_PLACEHOLDER + ); let parameters = func.parameters(); let is_void = if matches!(fn_return_type.typ, UnresolvedTypeData::Unit) { "Void" } else { "" }; diff --git a/aztec_macros/src/transforms/note_interface.rs b/aztec_macros/src/transforms/note_interface.rs index ba57e984d90..d4190e57263 100644 --- a/aztec_macros/src/transforms/note_interface.rs +++ b/aztec_macros/src/transforms/note_interface.rs @@ -487,10 +487,7 @@ fn generate_note_properties_struct_source( .iter() .filter_map(|(field_name, _)| { if field_name != note_header_field_name { - Some(format!( - "{}: aztec::note::note_getter_options::PropertySelector", - field_name - )) + Some(format!("{}: aztec::note::note_getter_options::PropertySelector", field_name)) } else { None } @@ -595,10 +592,7 @@ fn generate_note_deserialize_content_source( ) } } else { - format!( - "{}: aztec::note::note_header::NoteHeader::empty()", - note_header_field_name - ) + format!("{}: aztec::note::note_header::NoteHeader::empty()", note_header_field_name) } }) .collect::>() diff --git a/compiler/noirc_frontend/src/hir/resolution/import.rs b/compiler/noirc_frontend/src/hir/resolution/import.rs index 83a452a5cad..3db77937a05 100644 --- a/compiler/noirc_frontend/src/hir/resolution/import.rs +++ b/compiler/noirc_frontend/src/hir/resolution/import.rs @@ -41,6 +41,12 @@ pub enum PathResolutionError { Private(Ident), } +impl PathResolutionError { + fn is_unresolved(&self) -> bool { + matches!(self, Self::Unresolved(_)) + } +} + #[derive(Debug)] pub struct ResolvedImport { // name of the namespace, either last path segment or an alias @@ -159,18 +165,19 @@ fn resolve_path_to_ns( allow_contracts, ); - if result.is_ok() { - result - } else { - // TODO: combine error messages? - resolve_external_dep( - def_map, - import_directive, - def_maps, - allow_contracts, - importing_crate, - ) + // Attempt to resolve externally when unresolved + if let Err(ref result_err) = result { + if result_err.is_unresolved() { + return resolve_external_dep( + def_map, + import_directive, + def_maps, + allow_contracts, + importing_crate, + ); + } } + result } } } diff --git a/compiler/noirc_frontend/src/lexer/token.rs b/compiler/noirc_frontend/src/lexer/token.rs index 607094b4350..82e17ac3912 100644 --- a/compiler/noirc_frontend/src/lexer/token.rs +++ b/compiler/noirc_frontend/src/lexer/token.rs @@ -834,6 +834,7 @@ pub enum Keyword { Continue, Contract, Crate, + Dep, Distinct, Else, Field, @@ -878,6 +879,7 @@ impl fmt::Display for Keyword { Keyword::Continue => write!(f, "continue"), Keyword::Contract => write!(f, "contract"), Keyword::Crate => write!(f, "crate"), + Keyword::Dep => write!(f, "dep"), Keyword::Distinct => write!(f, "distinct"), Keyword::Else => write!(f, "else"), Keyword::Field => write!(f, "Field"), @@ -925,6 +927,7 @@ impl Keyword { "continue" => Keyword::Continue, "contract" => Keyword::Contract, "crate" => Keyword::Crate, + "dep" => Keyword::Dep, "distinct" => Keyword::Distinct, "else" => Keyword::Else, "Field" => Keyword::Field, diff --git a/compiler/noirc_frontend/src/noir_parser.lalrpop b/compiler/noirc_frontend/src/noir_parser.lalrpop index a68046f44f4..dbdc50193af 100644 --- a/compiler/noirc_frontend/src/noir_parser.lalrpop +++ b/compiler/noirc_frontend/src/noir_parser.lalrpop @@ -66,6 +66,7 @@ extern { "continue" => BorrowedToken::Keyword(noir_token::Keyword::Continue), "contract" => BorrowedToken::Keyword(noir_token::Keyword::Contract), "crate" => BorrowedToken::Keyword(noir_token::Keyword::Crate), + "dep" => BorrowedToken::Keyword(noir_token::Keyword::Dep), "distinct" => BorrowedToken::Keyword(noir_token::Keyword::Distinct), "else" => BorrowedToken::Keyword(noir_token::Keyword::Else), "Field" => BorrowedToken::Keyword(noir_token::Keyword::Field), @@ -124,8 +125,7 @@ pub(crate) Path: Path = { Path { segments, kind, span } }, - // TODO: still needed with PathKind::Plain now that "dep::.." is gone? - => { + "dep" "::" => { let kind = PathKind::Plain; let span = Span::from(lo as u32..hi as u32); Path { segments, kind, span } diff --git a/compiler/noirc_frontend/src/parser/parser/path.rs b/compiler/noirc_frontend/src/parser/parser/path.rs index 1ba4b49d183..9f45c355418 100644 --- a/compiler/noirc_frontend/src/parser/parser/path.rs +++ b/compiler/noirc_frontend/src/parser/parser/path.rs @@ -8,21 +8,24 @@ use chumsky::prelude::*; use super::{ident, keyword}; pub(super) fn path() -> impl NoirParser { + let idents = || ident().separated_by(just(Token::DoubleColon)).at_least(1); let make_path = |kind| move |segments, span| Path { segments, kind, span }; + let prefix = |key| keyword(key).ignore_then(just(Token::DoubleColon)); - let idents = || ident().separated_by(just(Token::DoubleColon)).at_least(1); - let crate_path = - || prefix(Keyword::Crate).ignore_then(idents()).map_with_span(make_path(PathKind::Crate)); + let path_kind = |key, kind| prefix(key).ignore_then(idents()).map_with_span(make_path(kind)); - choice((crate_path(), idents().map_with_span(make_path(PathKind::Plain)))) + choice(( + path_kind(Keyword::Crate, PathKind::Crate), + path_kind(Keyword::Dep, PathKind::Plain), + idents().map_with_span(make_path(PathKind::Plain)), + )) } fn empty_path() -> impl NoirParser { - let make_path = |opt_crate: Option, span| { - let kind = if opt_crate.is_some() { PathKind::Crate } else { PathKind::Plain }; - Path { segments: Vec::new(), kind, span } - }; - keyword(Keyword::Crate).or_not().map_with_span(make_path) + let make_path = |kind| move |_, span| Path { segments: Vec::new(), kind, span }; + let path_kind = |key, kind| keyword(key).map_with_span(make_path(kind)); + + choice((path_kind(Keyword::Crate, PathKind::Crate), path_kind(Keyword::Dep, PathKind::Plain))) } pub(super) fn maybe_empty_path() -> impl NoirParser { @@ -40,6 +43,7 @@ mod test { ("std", vec!["std"]), ("std::hash", vec!["std", "hash"]), ("std::hash::collections", vec!["std", "hash", "collections"]), + ("dep::foo::bar", vec!["foo", "bar"]), ("foo::bar", vec!["foo", "bar"]), ("crate::std::hash", vec!["std", "hash"]), ]; @@ -58,9 +62,8 @@ mod test { fn parse_path_kinds() { let cases = vec![ ("std", PathKind::Plain), + ("dep::hash::collections", PathKind::Plain), ("hash::collections", PathKind::Plain), - ("dep", PathKind::Plain), - ("foo::dep", PathKind::Plain), ("crate::std::hash", PathKind::Crate), ]; @@ -69,6 +72,9 @@ mod test { assert_eq!(path.kind, expected_path_kind); } - parse_all_failing(path(), vec!["crate", "crate::std::crate", "foo::bar::crate"]); + parse_all_failing( + path(), + vec!["crate", "crate::std::crate", "foo::bar::crate", "foo::dep"], + ); } } From 91e003ea20b4d0c68cf7743090be99700fde96ca Mon Sep 17 00:00:00 2001 From: "Michael J. Klein" Date: Tue, 30 Apr 2024 14:44:41 -0400 Subject: [PATCH 04/26] add PathKind::Dep back in 1) to ease distinguishing deprecated case, 2) so that it can be used for the '::' prefix later, add deprecation warning --- compiler/noirc_frontend/src/ast/statement.rs | 2 ++ compiler/noirc_frontend/src/hir/resolution/import.rs | 2 +- compiler/noirc_frontend/src/parser/errors.rs | 7 +++++++ compiler/noirc_frontend/src/parser/parser/path.rs | 12 ++++++++++-- tooling/nargo_fmt/src/rewrite/imports.rs | 2 +- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/compiler/noirc_frontend/src/ast/statement.rs b/compiler/noirc_frontend/src/ast/statement.rs index 16ed56f1ce0..a1a0b73fb67 100644 --- a/compiler/noirc_frontend/src/ast/statement.rs +++ b/compiler/noirc_frontend/src/ast/statement.rs @@ -290,6 +290,7 @@ pub struct ImportStatement { #[derive(Debug, PartialEq, Eq, Copy, Clone, Hash)] pub enum PathKind { Crate, + Dep, Plain, } @@ -734,6 +735,7 @@ impl Display for PathKind { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { PathKind::Crate => write!(f, "crate"), + PathKind::Dep => write!(f, "::"), PathKind::Plain => write!(f, "plain"), } } diff --git a/compiler/noirc_frontend/src/hir/resolution/import.rs b/compiler/noirc_frontend/src/hir/resolution/import.rs index 3db77937a05..8a932ffaddf 100644 --- a/compiler/noirc_frontend/src/hir/resolution/import.rs +++ b/compiler/noirc_frontend/src/hir/resolution/import.rs @@ -155,7 +155,7 @@ fn resolve_path_to_ns( allow_contracts, ) } - crate::ast::PathKind::Plain => { + crate::ast::PathKind::Plain | crate::ast::PathKind::Dep => { let result = resolve_name_in_module( crate_id, importing_crate, diff --git a/compiler/noirc_frontend/src/parser/errors.rs b/compiler/noirc_frontend/src/parser/errors.rs index af3d4caa145..26a18a18732 100644 --- a/compiler/noirc_frontend/src/parser/errors.rs +++ b/compiler/noirc_frontend/src/parser/errors.rs @@ -20,6 +20,8 @@ pub enum ParserErrorReason { MissingSeparatingSemi, #[error("constrain keyword is deprecated")] ConstrainDeprecated, + #[error("'dep::' prefix in paths is deprecated")] + DepPathPrefixDeprecated, #[error("Expression is invalid in an array-length type: '{0}'. Only unsigned integer constants, globals, generics, +, -, *, /, and % may be used in this context.")] InvalidArrayLengthExpression(Expression), #[error("Early 'return' is unsupported")] @@ -148,6 +150,11 @@ impl<'a> From<&'a ParserError> for Diagnostic { "The 'constrain' keyword is deprecated. Please use the 'assert' function instead.".into(), error.span, ), + ParserErrorReason::DepPathPrefixDeprecated => Diagnostic::simple_error( + "'dep::' prefix in paths is deprecated".into(), + "'dep::' prefix in paths is deprecated. Please use the path without 'dep::'.".into(), + error.span, + ), ParserErrorReason::ComptimeDeprecated => Diagnostic::simple_warning( "Use of deprecated keyword 'comptime'".into(), "The 'comptime' keyword has been deprecated. It can be removed without affecting your program".into(), diff --git a/compiler/noirc_frontend/src/parser/parser/path.rs b/compiler/noirc_frontend/src/parser/parser/path.rs index 9f45c355418..afa27e02a1e 100644 --- a/compiler/noirc_frontend/src/parser/parser/path.rs +++ b/compiler/noirc_frontend/src/parser/parser/path.rs @@ -1,5 +1,5 @@ use crate::ast::{Path, PathKind}; -use crate::parser::NoirParser; +use crate::parser::{NoirParser, ParserError, ParserErrorReason}; use crate::token::{Keyword, Token}; @@ -16,9 +16,17 @@ pub(super) fn path() -> impl NoirParser { choice(( path_kind(Keyword::Crate, PathKind::Crate), - path_kind(Keyword::Dep, PathKind::Plain), + path_kind(Keyword::Dep, PathKind::Dep), idents().map_with_span(make_path(PathKind::Plain)), )) + .validate(|mut expr, span, emit| { + if expr.kind == PathKind::Dep { + expr.kind = PathKind::Plain; + emit(ParserError::with_reason(ParserErrorReason::DepPathPrefixDeprecated, span)); + } + expr + }) + } fn empty_path() -> impl NoirParser { diff --git a/tooling/nargo_fmt/src/rewrite/imports.rs b/tooling/nargo_fmt/src/rewrite/imports.rs index 6432b950608..7e4bc7c1dda 100644 --- a/tooling/nargo_fmt/src/rewrite/imports.rs +++ b/tooling/nargo_fmt/src/rewrite/imports.rs @@ -63,7 +63,7 @@ impl UseTree { match use_tree.prefix.kind { ast::PathKind::Crate => result.path.push(UseSegment::Crate), - ast::PathKind::Plain => {} + ast::PathKind::Plain | ast::PathKind::Dep => {} }; result.path.extend( From 22ec8c78c0ed95f0665db182c728a3fc7a16588a Mon Sep 17 00:00:00 2001 From: "Michael J. Klein" Date: Tue, 30 Apr 2024 14:46:51 -0400 Subject: [PATCH 05/26] cargo fmt/clippy --- compiler/noirc_frontend/src/parser/parser/path.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler/noirc_frontend/src/parser/parser/path.rs b/compiler/noirc_frontend/src/parser/parser/path.rs index afa27e02a1e..1e18b7e8986 100644 --- a/compiler/noirc_frontend/src/parser/parser/path.rs +++ b/compiler/noirc_frontend/src/parser/parser/path.rs @@ -26,7 +26,6 @@ pub(super) fn path() -> impl NoirParser { } expr }) - } fn empty_path() -> impl NoirParser { From 552b29bd6dc26b9df4c6de4f3a6110ce197926d5 Mon Sep 17 00:00:00 2001 From: "Michael J. Klein" Date: Tue, 30 Apr 2024 15:04:45 -0400 Subject: [PATCH 06/26] fix tests failing from deprecation warning --- compiler/noirc_frontend/src/parser/parser/path.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/noirc_frontend/src/parser/parser/path.rs b/compiler/noirc_frontend/src/parser/parser/path.rs index 1e18b7e8986..5e5607f0be2 100644 --- a/compiler/noirc_frontend/src/parser/parser/path.rs +++ b/compiler/noirc_frontend/src/parser/parser/path.rs @@ -50,7 +50,7 @@ mod test { ("std", vec!["std"]), ("std::hash", vec!["std", "hash"]), ("std::hash::collections", vec!["std", "hash", "collections"]), - ("dep::foo::bar", vec!["foo", "bar"]), + ("foo::bar", vec!["foo", "bar"]), ("foo::bar", vec!["foo", "bar"]), ("crate::std::hash", vec!["std", "hash"]), ]; @@ -69,7 +69,6 @@ mod test { fn parse_path_kinds() { let cases = vec![ ("std", PathKind::Plain), - ("dep::hash::collections", PathKind::Plain), ("hash::collections", PathKind::Plain), ("crate::std::hash", PathKind::Crate), ]; From c8ba6f5800d9d6cdcf66059d160645e50cd1283f Mon Sep 17 00:00:00 2001 From: Michael J Klein Date: Wed, 1 May 2024 17:09:34 -0400 Subject: [PATCH 07/26] Update compiler/noirc_frontend/src/parser/errors.rs Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com> --- compiler/noirc_frontend/src/parser/errors.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/noirc_frontend/src/parser/errors.rs b/compiler/noirc_frontend/src/parser/errors.rs index 26a18a18732..77e24057079 100644 --- a/compiler/noirc_frontend/src/parser/errors.rs +++ b/compiler/noirc_frontend/src/parser/errors.rs @@ -150,7 +150,7 @@ impl<'a> From<&'a ParserError> for Diagnostic { "The 'constrain' keyword is deprecated. Please use the 'assert' function instead.".into(), error.span, ), - ParserErrorReason::DepPathPrefixDeprecated => Diagnostic::simple_error( + ParserErrorReason::DepPathPrefixDeprecated => Diagnostic::simple_warning( "'dep::' prefix in paths is deprecated".into(), "'dep::' prefix in paths is deprecated. Please use the path without 'dep::'.".into(), error.span, From 51bbb0e6ae5fb7cfd18cc0013a01e018571bc03b Mon Sep 17 00:00:00 2001 From: Michael J Klein Date: Wed, 1 May 2024 17:09:54 -0400 Subject: [PATCH 08/26] Update compiler/noirc_frontend/src/hir/resolution/import.rs Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com> --- .../src/hir/resolution/import.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/compiler/noirc_frontend/src/hir/resolution/import.rs b/compiler/noirc_frontend/src/hir/resolution/import.rs index 8a932ffaddf..7e147791466 100644 --- a/compiler/noirc_frontend/src/hir/resolution/import.rs +++ b/compiler/noirc_frontend/src/hir/resolution/import.rs @@ -166,16 +166,14 @@ fn resolve_path_to_ns( ); // Attempt to resolve externally when unresolved - if let Err(ref result_err) = result { - if result_err.is_unresolved() { - return resolve_external_dep( - def_map, - import_directive, - def_maps, - allow_contracts, - importing_crate, - ); - } + if let Err(PathResolutionError::Unresolved(_)) = result { + return resolve_external_dep( + def_map, + import_directive, + def_maps, + allow_contracts, + importing_crate, + ); } result } From 0da34b237b886fabca4ce4cc41f894b7f8e047df Mon Sep 17 00:00:00 2001 From: "Michael J. Klein" Date: Wed, 8 May 2024 23:59:54 -0400 Subject: [PATCH 09/26] wip responding to review comments, distinguish deprecated path kind from '::path', only resolve plain path as external when the first segment isn't found, rename DepPathPrefixDeprecated -> LitDepPathPrefixDeprecated, add distinct parsing case for '::path' with tests, remove test missing a Nargo.toml, add test_programs for overlapping cases --- compiler/noirc_frontend/src/ast/statement.rs | 6 +- .../src/hir/resolution/import.rs | 58 +++++++++++++------ compiler/noirc_frontend/src/parser/errors.rs | 4 +- .../noirc_frontend/src/parser/parser/path.rs | 12 ++-- .../overlapping_dep_and_mod/Nargo.toml | 6 ++ .../overlapping_dep_and_mod/bin/Nargo.toml | 8 +++ .../overlapping_dep_and_mod/bin/src/main.nr | 11 ++++ .../overlapping_dep_and_mod/foo/Nargo.toml | 7 +++ .../overlapping_dep_and_mod/foo/src/lib.nr | 5 ++ .../dep_submodule_overlap/Nargo.toml | 8 +++ .../dep_submodule_overlap/src/lib.nr | 7 +++ .../dep_submodule_overlap/src/main.nr | 10 ++++ .../brillig_scalar_mul/src/main.nr | 32 ---------- .../overlapping_dep_and_mod_fix/Nargo.toml | 6 ++ .../bin/Nargo.toml | 8 +++ .../bin/Prover.toml | 0 .../bin/src/main.nr | 14 +++++ .../foo/Nargo.toml | 7 +++ .../foo/src/lib.nr | 5 ++ .../execution_success/scalar_mul/src/main.nr | 31 ---------- tooling/nargo_fmt/src/rewrite/imports.rs | 2 +- 21 files changed, 158 insertions(+), 89 deletions(-) create mode 100644 test_programs/compile_failure/overlapping_dep_and_mod/Nargo.toml create mode 100644 test_programs/compile_failure/overlapping_dep_and_mod/bin/Nargo.toml create mode 100644 test_programs/compile_failure/overlapping_dep_and_mod/bin/src/main.nr create mode 100644 test_programs/compile_failure/overlapping_dep_and_mod/foo/Nargo.toml create mode 100644 test_programs/compile_failure/overlapping_dep_and_mod/foo/src/lib.nr create mode 100644 test_programs/compile_success_empty/dep_submodule_overlap/Nargo.toml create mode 100644 test_programs/compile_success_empty/dep_submodule_overlap/src/lib.nr create mode 100644 test_programs/compile_success_empty/dep_submodule_overlap/src/main.nr delete mode 100644 test_programs/execution_success/brillig_scalar_mul/src/main.nr create mode 100644 test_programs/execution_success/overlapping_dep_and_mod_fix/Nargo.toml create mode 100644 test_programs/execution_success/overlapping_dep_and_mod_fix/bin/Nargo.toml create mode 100644 test_programs/execution_success/overlapping_dep_and_mod_fix/bin/Prover.toml create mode 100644 test_programs/execution_success/overlapping_dep_and_mod_fix/bin/src/main.nr create mode 100644 test_programs/execution_success/overlapping_dep_and_mod_fix/foo/Nargo.toml create mode 100644 test_programs/execution_success/overlapping_dep_and_mod_fix/foo/src/lib.nr delete mode 100644 test_programs/execution_success/scalar_mul/src/main.nr diff --git a/compiler/noirc_frontend/src/ast/statement.rs b/compiler/noirc_frontend/src/ast/statement.rs index a1a0b73fb67..c3554c4f131 100644 --- a/compiler/noirc_frontend/src/ast/statement.rs +++ b/compiler/noirc_frontend/src/ast/statement.rs @@ -290,7 +290,10 @@ pub struct ImportStatement { #[derive(Debug, PartialEq, Eq, Copy, Clone, Hash)] pub enum PathKind { Crate, + /// "::path" Dep, + /// "dep::" (deprecated) + LitDep, Plain, } @@ -735,7 +738,8 @@ impl Display for PathKind { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { PathKind::Crate => write!(f, "crate"), - PathKind::Dep => write!(f, "::"), + PathKind::Dep => write!(f, ""), + PathKind::LitDep => write!(f, "dep"), PathKind::Plain => write!(f, "plain"), } } diff --git a/compiler/noirc_frontend/src/hir/resolution/import.rs b/compiler/noirc_frontend/src/hir/resolution/import.rs index 7e147791466..43fba98a6d5 100644 --- a/compiler/noirc_frontend/src/hir/resolution/import.rs +++ b/compiler/noirc_frontend/src/hir/resolution/import.rs @@ -41,12 +41,6 @@ pub enum PathResolutionError { Private(Ident), } -impl PathResolutionError { - fn is_unresolved(&self) -> bool { - matches!(self, Self::Unresolved(_)) - } -} - #[derive(Debug)] pub struct ResolvedImport { // name of the namespace, either last path segment or an alias @@ -155,18 +149,26 @@ fn resolve_path_to_ns( allow_contracts, ) } - crate::ast::PathKind::Plain | crate::ast::PathKind::Dep => { - let result = resolve_name_in_module( - crate_id, - importing_crate, - import_path, - import_directive.module_id, - def_maps, - allow_contracts, - ); + crate::ast::PathKind::Plain => { + + // There is a possibility that the import path is empty + // In that case, early return + if import_path.is_empty() { + return resolve_name_in_module( + crate_id, + importing_crate, + import_path, + import_directive.module_id, + def_maps, + allow_contracts, + ); + } - // Attempt to resolve externally when unresolved - if let Err(PathResolutionError::Unresolved(_)) = result { + let current_mod_id = ModuleId { krate: crate_id, local_id: import_directive.module_id }; + let current_mod = &def_map.modules[current_mod_id.local_id.0]; + let first_segment = import_path.first().expect("ice: could not fetch first segment"); + if current_mod.find_name(first_segment).is_none() { + // Resolve externally when first segment is unresolved return resolve_external_dep( def_map, import_directive, @@ -175,8 +177,28 @@ fn resolve_path_to_ns( importing_crate, ); } - result + + resolve_name_in_module( + crate_id, + importing_crate, + import_path, + import_directive.module_id, + def_maps, + allow_contracts, + ) + } + + crate::ast::PathKind::Dep | crate::ast::PathKind::LitDep => { + resolve_external_dep( + def_map, + import_directive, + def_maps, + allow_contracts, + importing_crate, + ) + } + } } diff --git a/compiler/noirc_frontend/src/parser/errors.rs b/compiler/noirc_frontend/src/parser/errors.rs index bb239439110..a1a4dbeedc6 100644 --- a/compiler/noirc_frontend/src/parser/errors.rs +++ b/compiler/noirc_frontend/src/parser/errors.rs @@ -21,7 +21,7 @@ pub enum ParserErrorReason { #[error("constrain keyword is deprecated")] ConstrainDeprecated, #[error("'dep::' prefix in paths is deprecated")] - DepPathPrefixDeprecated, + LitDepPathPrefixDeprecated, #[error("Expression is invalid in an array-length type: '{0}'. Only unsigned integer constants, globals, generics, +, -, *, /, and % may be used in this context.")] InvalidArrayLengthExpression(Expression), #[error("Early 'return' is unsupported")] @@ -152,7 +152,7 @@ impl<'a> From<&'a ParserError> for Diagnostic { "The 'constrain' keyword is deprecated. Please use the 'assert' function instead.".into(), error.span, ), - ParserErrorReason::DepPathPrefixDeprecated => Diagnostic::simple_warning( + ParserErrorReason::LitDepPathPrefixDeprecated => Diagnostic::simple_warning( "'dep::' prefix in paths is deprecated".into(), "'dep::' prefix in paths is deprecated. Please use the path without 'dep::'.".into(), error.span, diff --git a/compiler/noirc_frontend/src/parser/parser/path.rs b/compiler/noirc_frontend/src/parser/parser/path.rs index 5e5607f0be2..6deb56c85e4 100644 --- a/compiler/noirc_frontend/src/parser/parser/path.rs +++ b/compiler/noirc_frontend/src/parser/parser/path.rs @@ -13,16 +13,18 @@ pub(super) fn path() -> impl NoirParser { let prefix = |key| keyword(key).ignore_then(just(Token::DoubleColon)); let path_kind = |key, kind| prefix(key).ignore_then(idents()).map_with_span(make_path(kind)); + let double_colon_dep = || just(Token::DoubleColon).ignore_then(idents()).map_with_span(make_path(PathKind::Dep)); choice(( + double_colon_dep(), path_kind(Keyword::Crate, PathKind::Crate), - path_kind(Keyword::Dep, PathKind::Dep), + path_kind(Keyword::Dep, PathKind::LitDep), idents().map_with_span(make_path(PathKind::Plain)), )) .validate(|mut expr, span, emit| { - if expr.kind == PathKind::Dep { + if expr.kind == PathKind::LitDep { expr.kind = PathKind::Plain; - emit(ParserError::with_reason(ParserErrorReason::DepPathPrefixDeprecated, span)); + emit(ParserError::with_reason(ParserErrorReason::LitDepPathPrefixDeprecated, span)); } expr }) @@ -53,6 +55,7 @@ mod test { ("foo::bar", vec!["foo", "bar"]), ("foo::bar", vec!["foo", "bar"]), ("crate::std::hash", vec!["std", "hash"]), + ("::some::hash", vec!["some", "hash"]), ]; for (src, expected_segments) in cases { @@ -62,7 +65,7 @@ mod test { } } - parse_all_failing(path(), vec!["std::", "::std", "std::hash::", "foo::1"]); + parse_all_failing(path(), vec!["std::", "std::hash::", "foo::1"]); } #[test] @@ -71,6 +74,7 @@ mod test { ("std", PathKind::Plain), ("hash::collections", PathKind::Plain), ("crate::std::hash", PathKind::Crate), + ("::some::hash", PathKind::Dep), ]; for (src, expected_path_kind) in cases { diff --git a/test_programs/compile_failure/overlapping_dep_and_mod/Nargo.toml b/test_programs/compile_failure/overlapping_dep_and_mod/Nargo.toml new file mode 100644 index 00000000000..b2c3e5f94be --- /dev/null +++ b/test_programs/compile_failure/overlapping_dep_and_mod/Nargo.toml @@ -0,0 +1,6 @@ +[workspace] +members = [ + "bin", + "foo", +] +default-member = "bin" diff --git a/test_programs/compile_failure/overlapping_dep_and_mod/bin/Nargo.toml b/test_programs/compile_failure/overlapping_dep_and_mod/bin/Nargo.toml new file mode 100644 index 00000000000..57e704462db --- /dev/null +++ b/test_programs/compile_failure/overlapping_dep_and_mod/bin/Nargo.toml @@ -0,0 +1,8 @@ +[package] +name = "overlapping_dep_and_mod" +type = "bin" +authors = [""] +compiler_version = ">=0.29.0" + +[dependencies] +foo = { path = "../foo" } diff --git a/test_programs/compile_failure/overlapping_dep_and_mod/bin/src/main.nr b/test_programs/compile_failure/overlapping_dep_and_mod/bin/src/main.nr new file mode 100644 index 00000000000..633fa8c0ffe --- /dev/null +++ b/test_programs/compile_failure/overlapping_dep_and_mod/bin/src/main.nr @@ -0,0 +1,11 @@ +// bin/main.nr + +fn main() -> pub Field { + foo::bar() + foo::baz() +} + +mod foo { + pub(crate) fn bar() -> Field { + 5 + } +} diff --git a/test_programs/compile_failure/overlapping_dep_and_mod/foo/Nargo.toml b/test_programs/compile_failure/overlapping_dep_and_mod/foo/Nargo.toml new file mode 100644 index 00000000000..857d4e722a8 --- /dev/null +++ b/test_programs/compile_failure/overlapping_dep_and_mod/foo/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "foo" +type = "lib" +authors = [""] +compiler_version = ">=0.29.0" + +[dependencies] diff --git a/test_programs/compile_failure/overlapping_dep_and_mod/foo/src/lib.nr b/test_programs/compile_failure/overlapping_dep_and_mod/foo/src/lib.nr new file mode 100644 index 00000000000..cb8392ed275 --- /dev/null +++ b/test_programs/compile_failure/overlapping_dep_and_mod/foo/src/lib.nr @@ -0,0 +1,5 @@ +// foo/lib.nr + +pub fn baz() -> Field { + 6 +} diff --git a/test_programs/compile_success_empty/dep_submodule_overlap/Nargo.toml b/test_programs/compile_success_empty/dep_submodule_overlap/Nargo.toml new file mode 100644 index 00000000000..0d5a6221ef2 --- /dev/null +++ b/test_programs/compile_success_empty/dep_submodule_overlap/Nargo.toml @@ -0,0 +1,8 @@ +[package] +name = "dep_submodule_overlap" +type = "bin" +authors = [""] +compiler_version = ">=0.28.0" + +[dependencies] +reexporting_lib = { path = "../../test_libraries/reexporting_lib" } diff --git a/test_programs/compile_success_empty/dep_submodule_overlap/src/lib.nr b/test_programs/compile_success_empty/dep_submodule_overlap/src/lib.nr new file mode 100644 index 00000000000..b1594d2c1b5 --- /dev/null +++ b/test_programs/compile_success_empty/dep_submodule_overlap/src/lib.nr @@ -0,0 +1,7 @@ + +struct MyStruct { + inner: Field +} + +type FooStruct = MyStruct; + diff --git a/test_programs/compile_success_empty/dep_submodule_overlap/src/main.nr b/test_programs/compile_success_empty/dep_submodule_overlap/src/main.nr new file mode 100644 index 00000000000..5facd106065 --- /dev/null +++ b/test_programs/compile_success_empty/dep_submodule_overlap/src/main.nr @@ -0,0 +1,10 @@ +use reexporting_lib::{FooStruct, MyStruct, lib}; + +mod lib; +use crate::lib::{FooStruct, MyStruct}; + +fn main() { + let x: FooStruct = MyStruct { inner: 0 }; + assert(lib::is_struct_zero(x)); +} + diff --git a/test_programs/execution_success/brillig_scalar_mul/src/main.nr b/test_programs/execution_success/brillig_scalar_mul/src/main.nr deleted file mode 100644 index 63c0462f1b2..00000000000 --- a/test_programs/execution_success/brillig_scalar_mul/src/main.nr +++ /dev/null @@ -1,32 +0,0 @@ -use std; - -unconstrained fn main( - a: Field, - a_pub_x: pub Field, - a_pub_y: pub Field, - b: Field, - b_pub_x: pub Field, - b_pub_y: pub Field -) { - let mut priv_key = a; - let mut pub_x: Field = a_pub_x; - let mut pub_y: Field = a_pub_y; - if a != 1 { - // Change `a` in Prover.toml to test input `b` - priv_key = b; - pub_x = b_pub_x; - pub_y = b_pub_y; - } - let res = std::scalar_mul::fixed_base_embedded_curve(priv_key, 0); - assert(res[0] == pub_x); - assert(res[1] == pub_y); - - let pub_point= std::scalar_mul::EmbeddedCurvePoint { x: pub_x, y: pub_y }; - let g1_y = 17631683881184975370165255887551781615748388533673675138860; - let g1= std::scalar_mul::EmbeddedCurvePoint { x: 1, y: g1_y }; - - let res = pub_point.double(); - let double = g1.add(g1); - - assert(double.x == res.x); -} diff --git a/test_programs/execution_success/overlapping_dep_and_mod_fix/Nargo.toml b/test_programs/execution_success/overlapping_dep_and_mod_fix/Nargo.toml new file mode 100644 index 00000000000..b2c3e5f94be --- /dev/null +++ b/test_programs/execution_success/overlapping_dep_and_mod_fix/Nargo.toml @@ -0,0 +1,6 @@ +[workspace] +members = [ + "bin", + "foo", +] +default-member = "bin" diff --git a/test_programs/execution_success/overlapping_dep_and_mod_fix/bin/Nargo.toml b/test_programs/execution_success/overlapping_dep_and_mod_fix/bin/Nargo.toml new file mode 100644 index 00000000000..57e704462db --- /dev/null +++ b/test_programs/execution_success/overlapping_dep_and_mod_fix/bin/Nargo.toml @@ -0,0 +1,8 @@ +[package] +name = "overlapping_dep_and_mod" +type = "bin" +authors = [""] +compiler_version = ">=0.29.0" + +[dependencies] +foo = { path = "../foo" } diff --git a/test_programs/execution_success/overlapping_dep_and_mod_fix/bin/Prover.toml b/test_programs/execution_success/overlapping_dep_and_mod_fix/bin/Prover.toml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test_programs/execution_success/overlapping_dep_and_mod_fix/bin/src/main.nr b/test_programs/execution_success/overlapping_dep_and_mod_fix/bin/src/main.nr new file mode 100644 index 00000000000..25a8ba912e2 --- /dev/null +++ b/test_programs/execution_success/overlapping_dep_and_mod_fix/bin/src/main.nr @@ -0,0 +1,14 @@ +// bin/main.nr + +fn main() -> pub Field { + assert(foo::bar() + ::foo::bar() == 11); + assert(foo::bar() == 5); + assert(::foo::bar() == 6); + foo::bar() + ::foo::bar() +} + +mod foo { + pub(crate) fn bar() -> Field { + 5 + } +} diff --git a/test_programs/execution_success/overlapping_dep_and_mod_fix/foo/Nargo.toml b/test_programs/execution_success/overlapping_dep_and_mod_fix/foo/Nargo.toml new file mode 100644 index 00000000000..857d4e722a8 --- /dev/null +++ b/test_programs/execution_success/overlapping_dep_and_mod_fix/foo/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "foo" +type = "lib" +authors = [""] +compiler_version = ">=0.29.0" + +[dependencies] diff --git a/test_programs/execution_success/overlapping_dep_and_mod_fix/foo/src/lib.nr b/test_programs/execution_success/overlapping_dep_and_mod_fix/foo/src/lib.nr new file mode 100644 index 00000000000..09283defed7 --- /dev/null +++ b/test_programs/execution_success/overlapping_dep_and_mod_fix/foo/src/lib.nr @@ -0,0 +1,5 @@ +// foo/lib.nr + +pub fn bar() -> Field { + 6 +} diff --git a/test_programs/execution_success/scalar_mul/src/main.nr b/test_programs/execution_success/scalar_mul/src/main.nr deleted file mode 100644 index d092c614b87..00000000000 --- a/test_programs/execution_success/scalar_mul/src/main.nr +++ /dev/null @@ -1,31 +0,0 @@ -use std; - -fn main( - a: Field, - a_pub_x: pub Field, - a_pub_y: pub Field, - b: Field, - b_pub_x: pub Field, - b_pub_y: pub Field -) { - let mut priv_key = a; - let mut pub_x: Field = a_pub_x; - let mut pub_y: Field = a_pub_y; - if a != 1 { - // Change `a` in Prover.toml to test input `b` - priv_key = b; - pub_x = b_pub_x; - pub_y = b_pub_y; - } - let res = std::scalar_mul::fixed_base_embedded_curve(priv_key, 0); - assert(res[0] == pub_x); - assert(res[1] == pub_y); - let pub_point= std::scalar_mul::EmbeddedCurvePoint { x: pub_x, y: pub_y }; - let g1_y = 17631683881184975370165255887551781615748388533673675138860; - let g1= std::scalar_mul::EmbeddedCurvePoint { x: 1, y: g1_y }; - - let res = pub_point.double(); - let double = g1.add(g1); - - assert(double.x == res.x); -} diff --git a/tooling/nargo_fmt/src/rewrite/imports.rs b/tooling/nargo_fmt/src/rewrite/imports.rs index 7e4bc7c1dda..5be4433237b 100644 --- a/tooling/nargo_fmt/src/rewrite/imports.rs +++ b/tooling/nargo_fmt/src/rewrite/imports.rs @@ -63,7 +63,7 @@ impl UseTree { match use_tree.prefix.kind { ast::PathKind::Crate => result.path.push(UseSegment::Crate), - ast::PathKind::Plain | ast::PathKind::Dep => {} + ast::PathKind::Plain | ast::PathKind::LitDep | ast::PathKind::Dep => {} }; result.path.extend( From a00b775b7a09ae7829797bebe481e813ab383d38 Mon Sep 17 00:00:00 2001 From: "Michael J. Klein" Date: Thu, 9 May 2024 15:15:58 -0400 Subject: [PATCH 10/26] remove LitDep and associated warning, revert parser --- compiler/noirc_frontend/src/ast/statement.rs | 6 +----- .../src/hir/resolution/import.rs | 19 +++++++------------ compiler/noirc_frontend/src/parser/errors.rs | 7 ------- .../noirc_frontend/src/parser/parser/path.rs | 17 +++-------------- tooling/nargo_fmt/src/rewrite/imports.rs | 2 +- 5 files changed, 12 insertions(+), 39 deletions(-) diff --git a/compiler/noirc_frontend/src/ast/statement.rs b/compiler/noirc_frontend/src/ast/statement.rs index c3554c4f131..0da39edfd85 100644 --- a/compiler/noirc_frontend/src/ast/statement.rs +++ b/compiler/noirc_frontend/src/ast/statement.rs @@ -290,10 +290,7 @@ pub struct ImportStatement { #[derive(Debug, PartialEq, Eq, Copy, Clone, Hash)] pub enum PathKind { Crate, - /// "::path" Dep, - /// "dep::" (deprecated) - LitDep, Plain, } @@ -738,8 +735,7 @@ impl Display for PathKind { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { PathKind::Crate => write!(f, "crate"), - PathKind::Dep => write!(f, ""), - PathKind::LitDep => write!(f, "dep"), + PathKind::Dep => write!(f, "dep"), PathKind::Plain => write!(f, "plain"), } } diff --git a/compiler/noirc_frontend/src/hir/resolution/import.rs b/compiler/noirc_frontend/src/hir/resolution/import.rs index 43fba98a6d5..ce6402ce7ba 100644 --- a/compiler/noirc_frontend/src/hir/resolution/import.rs +++ b/compiler/noirc_frontend/src/hir/resolution/import.rs @@ -150,7 +150,6 @@ fn resolve_path_to_ns( ) } crate::ast::PathKind::Plain => { - // There is a possibility that the import path is empty // In that case, early return if import_path.is_empty() { @@ -186,19 +185,15 @@ fn resolve_path_to_ns( def_maps, allow_contracts, ) - - } - - crate::ast::PathKind::Dep | crate::ast::PathKind::LitDep => { - resolve_external_dep( - def_map, - import_directive, - def_maps, - allow_contracts, - importing_crate, - ) } + crate::ast::PathKind::Dep => resolve_external_dep( + def_map, + import_directive, + def_maps, + allow_contracts, + importing_crate, + ), } } diff --git a/compiler/noirc_frontend/src/parser/errors.rs b/compiler/noirc_frontend/src/parser/errors.rs index a1a4dbeedc6..e6102bbcf58 100644 --- a/compiler/noirc_frontend/src/parser/errors.rs +++ b/compiler/noirc_frontend/src/parser/errors.rs @@ -21,8 +21,6 @@ pub enum ParserErrorReason { #[error("constrain keyword is deprecated")] ConstrainDeprecated, #[error("'dep::' prefix in paths is deprecated")] - LitDepPathPrefixDeprecated, - #[error("Expression is invalid in an array-length type: '{0}'. Only unsigned integer constants, globals, generics, +, -, *, /, and % may be used in this context.")] InvalidArrayLengthExpression(Expression), #[error("Early 'return' is unsupported")] EarlyReturn, @@ -152,11 +150,6 @@ impl<'a> From<&'a ParserError> for Diagnostic { "The 'constrain' keyword is deprecated. Please use the 'assert' function instead.".into(), error.span, ), - ParserErrorReason::LitDepPathPrefixDeprecated => Diagnostic::simple_warning( - "'dep::' prefix in paths is deprecated".into(), - "'dep::' prefix in paths is deprecated. Please use the path without 'dep::'.".into(), - error.span, - ), ParserErrorReason::ComptimeDeprecated => Diagnostic::simple_warning( "Use of deprecated keyword 'comptime'".into(), "The 'comptime' keyword has been deprecated. It can be removed without affecting your program".into(), diff --git a/compiler/noirc_frontend/src/parser/parser/path.rs b/compiler/noirc_frontend/src/parser/parser/path.rs index 6deb56c85e4..e40268af410 100644 --- a/compiler/noirc_frontend/src/parser/parser/path.rs +++ b/compiler/noirc_frontend/src/parser/parser/path.rs @@ -1,5 +1,5 @@ use crate::ast::{Path, PathKind}; -use crate::parser::{NoirParser, ParserError, ParserErrorReason}; +use crate::parser::NoirParser; use crate::token::{Keyword, Token}; @@ -13,21 +13,12 @@ pub(super) fn path() -> impl NoirParser { let prefix = |key| keyword(key).ignore_then(just(Token::DoubleColon)); let path_kind = |key, kind| prefix(key).ignore_then(idents()).map_with_span(make_path(kind)); - let double_colon_dep = || just(Token::DoubleColon).ignore_then(idents()).map_with_span(make_path(PathKind::Dep)); choice(( - double_colon_dep(), path_kind(Keyword::Crate, PathKind::Crate), - path_kind(Keyword::Dep, PathKind::LitDep), + path_kind(Keyword::Dep, PathKind::Dep), idents().map_with_span(make_path(PathKind::Plain)), )) - .validate(|mut expr, span, emit| { - if expr.kind == PathKind::LitDep { - expr.kind = PathKind::Plain; - emit(ParserError::with_reason(ParserErrorReason::LitDepPathPrefixDeprecated, span)); - } - expr - }) } fn empty_path() -> impl NoirParser { @@ -55,7 +46,6 @@ mod test { ("foo::bar", vec!["foo", "bar"]), ("foo::bar", vec!["foo", "bar"]), ("crate::std::hash", vec!["std", "hash"]), - ("::some::hash", vec!["some", "hash"]), ]; for (src, expected_segments) in cases { @@ -65,7 +55,7 @@ mod test { } } - parse_all_failing(path(), vec!["std::", "std::hash::", "foo::1"]); + parse_all_failing(path(), vec!["std::", "::std", "std::hash::", "foo::1"]); } #[test] @@ -74,7 +64,6 @@ mod test { ("std", PathKind::Plain), ("hash::collections", PathKind::Plain), ("crate::std::hash", PathKind::Crate), - ("::some::hash", PathKind::Dep), ]; for (src, expected_path_kind) in cases { diff --git a/tooling/nargo_fmt/src/rewrite/imports.rs b/tooling/nargo_fmt/src/rewrite/imports.rs index 5be4433237b..7e4bc7c1dda 100644 --- a/tooling/nargo_fmt/src/rewrite/imports.rs +++ b/tooling/nargo_fmt/src/rewrite/imports.rs @@ -63,7 +63,7 @@ impl UseTree { match use_tree.prefix.kind { ast::PathKind::Crate => result.path.push(UseSegment::Crate), - ast::PathKind::Plain | ast::PathKind::LitDep | ast::PathKind::Dep => {} + ast::PathKind::Plain | ast::PathKind::Dep => {} }; result.path.extend( From 97bfe7266534efd54bc6d3223f5fbad0c1e6f1e8 Mon Sep 17 00:00:00 2001 From: "Michael J. Klein" Date: Thu, 9 May 2024 16:04:04 -0400 Subject: [PATCH 11/26] update previous-approach '::path' tests, simplify dep/mod overlap test --- .../dep_submodule_overlap/Nargo.toml | 0 .../dep_submodule_overlap/src/lib.nr | 4 ---- .../compile_failure/dep_submodule_overlap/src/main.nr | 9 +++++++++ .../overlapping_dep_and_mod/bin/src/main.nr | 11 ----------- .../dep_submodule_overlap/src/main.nr | 10 ---------- .../overlapping_dep_and_mod/Nargo.toml | 0 .../overlapping_dep_and_mod/bin/Nargo.toml | 0 .../overlapping_dep_and_mod/bin/src/main.nr | 9 +++++++++ .../overlapping_dep_and_mod/foo/Nargo.toml | 0 .../overlapping_dep_and_mod/foo/src/lib.nr | 0 .../overlapping_dep_and_mod_fix/bin/src/main.nr | 6 +++--- 11 files changed, 21 insertions(+), 28 deletions(-) rename test_programs/{compile_success_empty => compile_failure}/dep_submodule_overlap/Nargo.toml (100%) rename test_programs/{compile_success_empty => compile_failure}/dep_submodule_overlap/src/lib.nr (55%) create mode 100644 test_programs/compile_failure/dep_submodule_overlap/src/main.nr delete mode 100644 test_programs/compile_failure/overlapping_dep_and_mod/bin/src/main.nr delete mode 100644 test_programs/compile_success_empty/dep_submodule_overlap/src/main.nr rename test_programs/{compile_failure => compile_success_empty}/overlapping_dep_and_mod/Nargo.toml (100%) rename test_programs/{compile_failure => compile_success_empty}/overlapping_dep_and_mod/bin/Nargo.toml (100%) create mode 100644 test_programs/compile_success_empty/overlapping_dep_and_mod/bin/src/main.nr rename test_programs/{compile_failure => compile_success_empty}/overlapping_dep_and_mod/foo/Nargo.toml (100%) rename test_programs/{compile_failure => compile_success_empty}/overlapping_dep_and_mod/foo/src/lib.nr (100%) diff --git a/test_programs/compile_success_empty/dep_submodule_overlap/Nargo.toml b/test_programs/compile_failure/dep_submodule_overlap/Nargo.toml similarity index 100% rename from test_programs/compile_success_empty/dep_submodule_overlap/Nargo.toml rename to test_programs/compile_failure/dep_submodule_overlap/Nargo.toml diff --git a/test_programs/compile_success_empty/dep_submodule_overlap/src/lib.nr b/test_programs/compile_failure/dep_submodule_overlap/src/lib.nr similarity index 55% rename from test_programs/compile_success_empty/dep_submodule_overlap/src/lib.nr rename to test_programs/compile_failure/dep_submodule_overlap/src/lib.nr index b1594d2c1b5..e2e82b2f5cd 100644 --- a/test_programs/compile_success_empty/dep_submodule_overlap/src/lib.nr +++ b/test_programs/compile_failure/dep_submodule_overlap/src/lib.nr @@ -1,7 +1,3 @@ - struct MyStruct { inner: Field } - -type FooStruct = MyStruct; - diff --git a/test_programs/compile_failure/dep_submodule_overlap/src/main.nr b/test_programs/compile_failure/dep_submodule_overlap/src/main.nr new file mode 100644 index 00000000000..c53630c53ca --- /dev/null +++ b/test_programs/compile_failure/dep_submodule_overlap/src/main.nr @@ -0,0 +1,9 @@ +use reexporting_lib::{MyStruct, lib}; + +mod lib; +use crate::lib::MyStruct; + +fn main() { + let x = MyStruct { inner: 0 }; + assert(lib::is_struct_zero(x)); +} diff --git a/test_programs/compile_failure/overlapping_dep_and_mod/bin/src/main.nr b/test_programs/compile_failure/overlapping_dep_and_mod/bin/src/main.nr deleted file mode 100644 index 633fa8c0ffe..00000000000 --- a/test_programs/compile_failure/overlapping_dep_and_mod/bin/src/main.nr +++ /dev/null @@ -1,11 +0,0 @@ -// bin/main.nr - -fn main() -> pub Field { - foo::bar() + foo::baz() -} - -mod foo { - pub(crate) fn bar() -> Field { - 5 - } -} diff --git a/test_programs/compile_success_empty/dep_submodule_overlap/src/main.nr b/test_programs/compile_success_empty/dep_submodule_overlap/src/main.nr deleted file mode 100644 index 5facd106065..00000000000 --- a/test_programs/compile_success_empty/dep_submodule_overlap/src/main.nr +++ /dev/null @@ -1,10 +0,0 @@ -use reexporting_lib::{FooStruct, MyStruct, lib}; - -mod lib; -use crate::lib::{FooStruct, MyStruct}; - -fn main() { - let x: FooStruct = MyStruct { inner: 0 }; - assert(lib::is_struct_zero(x)); -} - diff --git a/test_programs/compile_failure/overlapping_dep_and_mod/Nargo.toml b/test_programs/compile_success_empty/overlapping_dep_and_mod/Nargo.toml similarity index 100% rename from test_programs/compile_failure/overlapping_dep_and_mod/Nargo.toml rename to test_programs/compile_success_empty/overlapping_dep_and_mod/Nargo.toml diff --git a/test_programs/compile_failure/overlapping_dep_and_mod/bin/Nargo.toml b/test_programs/compile_success_empty/overlapping_dep_and_mod/bin/Nargo.toml similarity index 100% rename from test_programs/compile_failure/overlapping_dep_and_mod/bin/Nargo.toml rename to test_programs/compile_success_empty/overlapping_dep_and_mod/bin/Nargo.toml diff --git a/test_programs/compile_success_empty/overlapping_dep_and_mod/bin/src/main.nr b/test_programs/compile_success_empty/overlapping_dep_and_mod/bin/src/main.nr new file mode 100644 index 00000000000..1d9c917d91a --- /dev/null +++ b/test_programs/compile_success_empty/overlapping_dep_and_mod/bin/src/main.nr @@ -0,0 +1,9 @@ +fn main() { + let _ = foo::bar() + dep::foo::baz(); +} + +mod foo { + pub(crate) fn bar() -> Field { + 5 + } +} diff --git a/test_programs/compile_failure/overlapping_dep_and_mod/foo/Nargo.toml b/test_programs/compile_success_empty/overlapping_dep_and_mod/foo/Nargo.toml similarity index 100% rename from test_programs/compile_failure/overlapping_dep_and_mod/foo/Nargo.toml rename to test_programs/compile_success_empty/overlapping_dep_and_mod/foo/Nargo.toml diff --git a/test_programs/compile_failure/overlapping_dep_and_mod/foo/src/lib.nr b/test_programs/compile_success_empty/overlapping_dep_and_mod/foo/src/lib.nr similarity index 100% rename from test_programs/compile_failure/overlapping_dep_and_mod/foo/src/lib.nr rename to test_programs/compile_success_empty/overlapping_dep_and_mod/foo/src/lib.nr diff --git a/test_programs/execution_success/overlapping_dep_and_mod_fix/bin/src/main.nr b/test_programs/execution_success/overlapping_dep_and_mod_fix/bin/src/main.nr index 25a8ba912e2..16c940f12fc 100644 --- a/test_programs/execution_success/overlapping_dep_and_mod_fix/bin/src/main.nr +++ b/test_programs/execution_success/overlapping_dep_and_mod_fix/bin/src/main.nr @@ -1,10 +1,10 @@ // bin/main.nr fn main() -> pub Field { - assert(foo::bar() + ::foo::bar() == 11); + assert(foo::bar() + dep::foo::bar() == 11); assert(foo::bar() == 5); - assert(::foo::bar() == 6); - foo::bar() + ::foo::bar() + assert(dep::foo::bar() == 6); + foo::bar() + dep::foo::bar() } mod foo { From 8a4d138813a8e0832a450f8b79315e91d0a1df8c Mon Sep 17 00:00:00 2001 From: "Michael J. Klein" Date: Fri, 10 May 2024 12:24:29 -0400 Subject: [PATCH 12/26] add test for external vs local import without 'dep::' --- .../overlapping_dep_and_mod/Nargo.toml | 6 ++++++ .../overlapping_dep_and_mod/bin/Nargo.toml | 8 ++++++++ .../overlapping_dep_and_mod/bin/Prover.toml | 0 .../overlapping_dep_and_mod/bin/src/main.nr | 12 ++++++++++++ .../overlapping_dep_and_mod/foo/Nargo.toml | 7 +++++++ .../overlapping_dep_and_mod/foo/src/lib.nr | 3 +++ 6 files changed, 36 insertions(+) create mode 100644 test_programs/execution_failure/overlapping_dep_and_mod/Nargo.toml create mode 100644 test_programs/execution_failure/overlapping_dep_and_mod/bin/Nargo.toml create mode 100644 test_programs/execution_failure/overlapping_dep_and_mod/bin/Prover.toml create mode 100644 test_programs/execution_failure/overlapping_dep_and_mod/bin/src/main.nr create mode 100644 test_programs/execution_failure/overlapping_dep_and_mod/foo/Nargo.toml create mode 100644 test_programs/execution_failure/overlapping_dep_and_mod/foo/src/lib.nr diff --git a/test_programs/execution_failure/overlapping_dep_and_mod/Nargo.toml b/test_programs/execution_failure/overlapping_dep_and_mod/Nargo.toml new file mode 100644 index 00000000000..b2c3e5f94be --- /dev/null +++ b/test_programs/execution_failure/overlapping_dep_and_mod/Nargo.toml @@ -0,0 +1,6 @@ +[workspace] +members = [ + "bin", + "foo", +] +default-member = "bin" diff --git a/test_programs/execution_failure/overlapping_dep_and_mod/bin/Nargo.toml b/test_programs/execution_failure/overlapping_dep_and_mod/bin/Nargo.toml new file mode 100644 index 00000000000..57e704462db --- /dev/null +++ b/test_programs/execution_failure/overlapping_dep_and_mod/bin/Nargo.toml @@ -0,0 +1,8 @@ +[package] +name = "overlapping_dep_and_mod" +type = "bin" +authors = [""] +compiler_version = ">=0.29.0" + +[dependencies] +foo = { path = "../foo" } diff --git a/test_programs/execution_failure/overlapping_dep_and_mod/bin/Prover.toml b/test_programs/execution_failure/overlapping_dep_and_mod/bin/Prover.toml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test_programs/execution_failure/overlapping_dep_and_mod/bin/src/main.nr b/test_programs/execution_failure/overlapping_dep_and_mod/bin/src/main.nr new file mode 100644 index 00000000000..e7c16910a93 --- /dev/null +++ b/test_programs/execution_failure/overlapping_dep_and_mod/bin/src/main.nr @@ -0,0 +1,12 @@ +fn main() -> pub Field { + assert(foo::bar() + foo::bar() == 3); + assert(foo::bar() == 1); + assert(foo::bar() == 2); + foo::bar() + foo::bar() +} + +mod foo { + pub(crate) fn bar() -> Field { + 1 + } +} diff --git a/test_programs/execution_failure/overlapping_dep_and_mod/foo/Nargo.toml b/test_programs/execution_failure/overlapping_dep_and_mod/foo/Nargo.toml new file mode 100644 index 00000000000..857d4e722a8 --- /dev/null +++ b/test_programs/execution_failure/overlapping_dep_and_mod/foo/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "foo" +type = "lib" +authors = [""] +compiler_version = ">=0.29.0" + +[dependencies] diff --git a/test_programs/execution_failure/overlapping_dep_and_mod/foo/src/lib.nr b/test_programs/execution_failure/overlapping_dep_and_mod/foo/src/lib.nr new file mode 100644 index 00000000000..68e49f78305 --- /dev/null +++ b/test_programs/execution_failure/overlapping_dep_and_mod/foo/src/lib.nr @@ -0,0 +1,3 @@ +pub fn bar() -> Field { + 2 +} From 085d1f6e2e8c3f4d59352e7b870581a6bf5619dc Mon Sep 17 00:00:00 2001 From: "Michael J. Klein" Date: Fri, 10 May 2024 15:41:56 -0400 Subject: [PATCH 13/26] convert overlapping_dep_and_mod to a compile failure by moving expected overlap from dep::foo::bar != foo::bar to foo::bar/foo::baz (overlapping module name) --- .../overlapping_dep_and_mod/Nargo.toml | 0 .../overlapping_dep_and_mod/bin/Nargo.toml | 0 .../overlapping_dep_and_mod/bin/Prover.toml | 0 .../overlapping_dep_and_mod/bin/src/main.nr | 6 +++--- .../overlapping_dep_and_mod/foo/Nargo.toml | 0 .../compile_failure/overlapping_dep_and_mod/foo/src/lib.nr | 3 +++ .../overlapping_dep_and_mod/foo/src/lib.nr | 3 --- 7 files changed, 6 insertions(+), 6 deletions(-) rename test_programs/{execution_failure => compile_failure}/overlapping_dep_and_mod/Nargo.toml (100%) rename test_programs/{execution_failure => compile_failure}/overlapping_dep_and_mod/bin/Nargo.toml (100%) rename test_programs/{execution_failure => compile_failure}/overlapping_dep_and_mod/bin/Prover.toml (100%) rename test_programs/{execution_failure => compile_failure}/overlapping_dep_and_mod/bin/src/main.nr (54%) rename test_programs/{execution_failure => compile_failure}/overlapping_dep_and_mod/foo/Nargo.toml (100%) create mode 100644 test_programs/compile_failure/overlapping_dep_and_mod/foo/src/lib.nr delete mode 100644 test_programs/execution_failure/overlapping_dep_and_mod/foo/src/lib.nr diff --git a/test_programs/execution_failure/overlapping_dep_and_mod/Nargo.toml b/test_programs/compile_failure/overlapping_dep_and_mod/Nargo.toml similarity index 100% rename from test_programs/execution_failure/overlapping_dep_and_mod/Nargo.toml rename to test_programs/compile_failure/overlapping_dep_and_mod/Nargo.toml diff --git a/test_programs/execution_failure/overlapping_dep_and_mod/bin/Nargo.toml b/test_programs/compile_failure/overlapping_dep_and_mod/bin/Nargo.toml similarity index 100% rename from test_programs/execution_failure/overlapping_dep_and_mod/bin/Nargo.toml rename to test_programs/compile_failure/overlapping_dep_and_mod/bin/Nargo.toml diff --git a/test_programs/execution_failure/overlapping_dep_and_mod/bin/Prover.toml b/test_programs/compile_failure/overlapping_dep_and_mod/bin/Prover.toml similarity index 100% rename from test_programs/execution_failure/overlapping_dep_and_mod/bin/Prover.toml rename to test_programs/compile_failure/overlapping_dep_and_mod/bin/Prover.toml diff --git a/test_programs/execution_failure/overlapping_dep_and_mod/bin/src/main.nr b/test_programs/compile_failure/overlapping_dep_and_mod/bin/src/main.nr similarity index 54% rename from test_programs/execution_failure/overlapping_dep_and_mod/bin/src/main.nr rename to test_programs/compile_failure/overlapping_dep_and_mod/bin/src/main.nr index e7c16910a93..675e889b7e5 100644 --- a/test_programs/execution_failure/overlapping_dep_and_mod/bin/src/main.nr +++ b/test_programs/compile_failure/overlapping_dep_and_mod/bin/src/main.nr @@ -1,8 +1,8 @@ fn main() -> pub Field { - assert(foo::bar() + foo::bar() == 3); + assert(foo::bar() + foo::baz() == 3); assert(foo::bar() == 1); - assert(foo::bar() == 2); - foo::bar() + foo::bar() + assert(foo::baz() == 2); + foo::bar() + foo::baz() } mod foo { diff --git a/test_programs/execution_failure/overlapping_dep_and_mod/foo/Nargo.toml b/test_programs/compile_failure/overlapping_dep_and_mod/foo/Nargo.toml similarity index 100% rename from test_programs/execution_failure/overlapping_dep_and_mod/foo/Nargo.toml rename to test_programs/compile_failure/overlapping_dep_and_mod/foo/Nargo.toml diff --git a/test_programs/compile_failure/overlapping_dep_and_mod/foo/src/lib.nr b/test_programs/compile_failure/overlapping_dep_and_mod/foo/src/lib.nr new file mode 100644 index 00000000000..7834e2c9276 --- /dev/null +++ b/test_programs/compile_failure/overlapping_dep_and_mod/foo/src/lib.nr @@ -0,0 +1,3 @@ +pub fn baz() -> Field { + 2 +} diff --git a/test_programs/execution_failure/overlapping_dep_and_mod/foo/src/lib.nr b/test_programs/execution_failure/overlapping_dep_and_mod/foo/src/lib.nr deleted file mode 100644 index 68e49f78305..00000000000 --- a/test_programs/execution_failure/overlapping_dep_and_mod/foo/src/lib.nr +++ /dev/null @@ -1,3 +0,0 @@ -pub fn bar() -> Field { - 2 -} From 11f623525e9c147cca8a3ef476ef7a6cad458637 Mon Sep 17 00:00:00 2001 From: "Michael J. Klein" Date: Fri, 10 May 2024 15:53:04 -0400 Subject: [PATCH 14/26] add 'overlapping_dep_and_mod*' tests to excluded_dirs in formatting test (as they're a type of workspace test) --- test_programs/format.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_programs/format.sh b/test_programs/format.sh index 3c679b8689e..fa63d228752 100755 --- a/test_programs/format.sh +++ b/test_programs/format.sh @@ -2,7 +2,7 @@ set -e # These tests are incompatible with gas reporting -excluded_dirs=("workspace" "workspace_default_member" "workspace_reexport_bug") +excluded_dirs=("workspace" "overlapping_dep_and_mod" "overlapping_dep_and_mod_fix" "workspace_default_member" "workspace_reexport_bug") # These tests cause failures in CI with a stack overflow for some reason. ci_excluded_dirs=("eddsa") From 268490f876984b5b26e3bb9dc5059d1f2779506f Mon Sep 17 00:00:00 2001 From: "Michael J. Klein" Date: Fri, 10 May 2024 17:12:33 -0400 Subject: [PATCH 15/26] nargo fmt --- test_programs/execution_success/aes128_encrypt/src/main.nr | 2 +- .../execution_success/brillig_embedded_curve/src/main.nr | 2 +- test_programs/execution_success/embedded_curve_ops/src/main.nr | 2 +- .../no_predicates_numeric_generic_poseidon/src/main.nr | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test_programs/execution_success/aes128_encrypt/src/main.nr b/test_programs/execution_success/aes128_encrypt/src/main.nr index f6ed0f309c3..9392d7640f8 100644 --- a/test_programs/execution_success/aes128_encrypt/src/main.nr +++ b/test_programs/execution_success/aes128_encrypt/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; unconstrained fn decode_ascii(ascii: u8) -> u8 { if ascii < 58 { diff --git a/test_programs/execution_success/brillig_embedded_curve/src/main.nr b/test_programs/execution_success/brillig_embedded_curve/src/main.nr index 8a1a7f08975..78fb32e2802 100644 --- a/test_programs/execution_success/brillig_embedded_curve/src/main.nr +++ b/test_programs/execution_success/brillig_embedded_curve/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; unconstrained fn main(priv_key: Field, pub_x: pub Field, pub_y: pub Field) { let g1_y = 17631683881184975370165255887551781615748388533673675138860; diff --git a/test_programs/execution_success/embedded_curve_ops/src/main.nr b/test_programs/execution_success/embedded_curve_ops/src/main.nr index 3cb27d8c181..5e9ab91b45d 100644 --- a/test_programs/execution_success/embedded_curve_ops/src/main.nr +++ b/test_programs/execution_success/embedded_curve_ops/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main(priv_key: Field, pub_x: pub Field, pub_y: pub Field) { let g1_y = 17631683881184975370165255887551781615748388533673675138860; diff --git a/test_programs/execution_success/no_predicates_numeric_generic_poseidon/src/main.nr b/test_programs/execution_success/no_predicates_numeric_generic_poseidon/src/main.nr index dcb5e6bc5ca..94db8c2b414 100644 --- a/test_programs/execution_success/no_predicates_numeric_generic_poseidon/src/main.nr +++ b/test_programs/execution_success/no_predicates_numeric_generic_poseidon/src/main.nr @@ -1,4 +1,4 @@ -use dep::std::hash::{pedersen_hash_with_separator, poseidon2::Poseidon2}; +use std::hash::{pedersen_hash_with_separator, poseidon2::Poseidon2}; global NUM_HASHES = 2; global HASH_LENGTH = 10; From fb82de41b0c9db3d612ac2fb0a200204b9ed7eba Mon Sep 17 00:00:00 2001 From: "Michael J. Klein" Date: Mon, 10 Jun 2024 14:08:48 -0400 Subject: [PATCH 16/26] nargo fmt --- .../execution_success/ecdsa_secp256r1_3x/src/main.nr | 2 +- .../execution_success/is_unconstrained/src/main.nr | 2 +- test_programs/execution_success/regression_5045/src/main.nr | 4 ++-- .../execution_success/trait_method_mut_self/src/main.nr | 4 ++-- .../turbofish_call_func_diff_types/src/main.nr | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test_programs/execution_success/ecdsa_secp256r1_3x/src/main.nr b/test_programs/execution_success/ecdsa_secp256r1_3x/src/main.nr index e7a6be9d47a..54bc621bc6c 100644 --- a/test_programs/execution_success/ecdsa_secp256r1_3x/src/main.nr +++ b/test_programs/execution_success/ecdsa_secp256r1_3x/src/main.nr @@ -1,4 +1,4 @@ -use dep::std; +use std; fn main( hashed_message: [u8; 32], diff --git a/test_programs/execution_success/is_unconstrained/src/main.nr b/test_programs/execution_success/is_unconstrained/src/main.nr index af40af1029f..ddafc73c598 100644 --- a/test_programs/execution_success/is_unconstrained/src/main.nr +++ b/test_programs/execution_success/is_unconstrained/src/main.nr @@ -1,4 +1,4 @@ -use dep::std::runtime::is_unconstrained; +use std::runtime::is_unconstrained; fn check(should_be_unconstrained: bool) { assert_eq(should_be_unconstrained, is_unconstrained()); diff --git a/test_programs/execution_success/regression_5045/src/main.nr b/test_programs/execution_success/regression_5045/src/main.nr index 015fb1b2555..9188dd3d76d 100644 --- a/test_programs/execution_success/regression_5045/src/main.nr +++ b/test_programs/execution_success/regression_5045/src/main.nr @@ -1,5 +1,5 @@ -use dep::std::embedded_curve_ops::EmbeddedCurvePoint; -use dep::std::embedded_curve_ops::EmbeddedCurveScalar; +use std::embedded_curve_ops::EmbeddedCurvePoint; +use std::embedded_curve_ops::EmbeddedCurveScalar; fn main(is_active: bool) { let a = EmbeddedCurvePoint { diff --git a/test_programs/execution_success/trait_method_mut_self/src/main.nr b/test_programs/execution_success/trait_method_mut_self/src/main.nr index fa47fd5d881..9cc8375b140 100644 --- a/test_programs/execution_success/trait_method_mut_self/src/main.nr +++ b/test_programs/execution_success/trait_method_mut_self/src/main.nr @@ -1,5 +1,5 @@ -use dep::std::hash::Hasher; -use dep::std::hash::poseidon2::Poseidon2Hasher; +use std::hash::Hasher; +use std::hash::poseidon2::Poseidon2Hasher; fn main(x: Field, y: pub Field) { let mut a_mut_ref = AType { x }; diff --git a/test_programs/execution_success/turbofish_call_func_diff_types/src/main.nr b/test_programs/execution_success/turbofish_call_func_diff_types/src/main.nr index b880d3ae047..36c7d2926c1 100644 --- a/test_programs/execution_success/turbofish_call_func_diff_types/src/main.nr +++ b/test_programs/execution_success/turbofish_call_func_diff_types/src/main.nr @@ -1,6 +1,6 @@ -use dep::std::hash::Hasher; -use dep::std::hash::poseidon2::Poseidon2Hasher; -use dep::std::hash::poseidon::PoseidonHasher; +use std::hash::Hasher; +use std::hash::poseidon2::Poseidon2Hasher; +use std::hash::poseidon::PoseidonHasher; fn main(x: Field, y: pub Field) { let mut hasher = PoseidonHasher::default(); From 7b3eb424c540bdb9c62d1bc2fd8798aab0a17def Mon Sep 17 00:00:00 2001 From: Tom French Date: Mon, 17 Jun 2024 12:21:30 +0100 Subject: [PATCH 17/26] chore: fmt --- test_programs/execution_success/regression_5202/src/main.nr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_programs/execution_success/regression_5202/src/main.nr b/test_programs/execution_success/regression_5202/src/main.nr index e41b760b83e..2ebfd7890ba 100644 --- a/test_programs/execution_success/regression_5202/src/main.nr +++ b/test_programs/execution_success/regression_5202/src/main.nr @@ -1,4 +1,4 @@ -use dep::fraction::{Fraction, MAX, floor, toFraction, addFraction}; +use fraction::{Fraction, MAX, floor, toFraction, addFraction}; fn main() { let g1 = toFraction(true, 33333333, 5); From 9111c2a32594f4a1ee440833d57f8b7b66ba52a4 Mon Sep 17 00:00:00 2001 From: Tom French Date: Mon, 17 Jun 2024 12:29:04 +0100 Subject: [PATCH 18/26] chore: update new paths --- aztec_macros/src/transforms/contract_interface.rs | 2 +- .../circuits/assert_lt/src/main.nr | 3 --- examples/recursion/recurse_leaf/src/main.nr | 4 +--- examples/recursion/recurse_node/src/main.nr | 4 +--- .../benchmarks/bench_eddsa_poseidon/src/main.nr | 4 ++-- .../benchmarks/bench_poseidon_hash/src/main.nr | 2 +- .../benchmarks/bench_poseidon_hash_100/src/main.nr | 4 ++-- .../benchmarks/bench_poseidon_hash_30/src/main.nr | 4 ++-- .../benchmarks/bench_sha256_100/src/main.nr | 4 +--- .../benchmarks/bench_sha256_30/src/main.nr | 4 +--- .../turbofish_generic_count/src/main.nr | 3 +-- .../brillig_block_parameter_liveness/src/main.nr | 4 ++-- .../execution_success/generics/src/main.nr | 2 +- .../execution_success/regression_5045/src/main.nr | 2 +- .../execution_success/regression_5252/src/main.nr | 2 +- .../execution_success/slice_coercion/src/main.nr | 2 +- .../embedded_curve_ops/src/main.nr | 2 +- .../noir_test_success/regression_4561/src/main.nr | 4 ++-- .../should_fail_with_matches/src/main.nr | 14 +++++++------- 19 files changed, 29 insertions(+), 41 deletions(-) diff --git a/aztec_macros/src/transforms/contract_interface.rs b/aztec_macros/src/transforms/contract_interface.rs index 57786bbb943..e6ac43ad2c4 100644 --- a/aztec_macros/src/transforms/contract_interface.rs +++ b/aztec_macros/src/transforms/contract_interface.rs @@ -132,7 +132,7 @@ pub fn stub_function(aztec_visibility: &str, func: &NoirFunction, is_static_call target_contract: self.target_contract, selector: {}, args: args_acc, - gas_opts: dep::aztec::context::gas::GasOpts::default(), + gas_opts: aztec::context::gas::GasOpts::default(), }}", args, is_static, is_void, fn_selector, ); diff --git a/compiler/integration-tests/circuits/assert_lt/src/main.nr b/compiler/integration-tests/circuits/assert_lt/src/main.nr index b8e255ca492..47e229d6c8b 100644 --- a/compiler/integration-tests/circuits/assert_lt/src/main.nr +++ b/compiler/integration-tests/circuits/assert_lt/src/main.nr @@ -1,10 +1,7 @@ -use dep::std; - fn main(x: u64, y: pub u64) -> pub u64 { // We include a println statement to show that noirJS will ignore this and continue execution std::println("foo"); - assert(x < y); x + y } diff --git a/examples/recursion/recurse_leaf/src/main.nr b/examples/recursion/recurse_leaf/src/main.nr index b6a2b49b219..4859e84d49e 100644 --- a/examples/recursion/recurse_leaf/src/main.nr +++ b/examples/recursion/recurse_leaf/src/main.nr @@ -1,5 +1,3 @@ -use dep::std; - #[recursive] fn main( verification_key: [Field; 114], @@ -17,4 +15,4 @@ fn main( ); // Take output of previous proof and add another number to it. public_inputs[2] as u64 + num -} \ No newline at end of file +} diff --git a/examples/recursion/recurse_node/src/main.nr b/examples/recursion/recurse_node/src/main.nr index 7c983dcf050..60192493b54 100644 --- a/examples/recursion/recurse_node/src/main.nr +++ b/examples/recursion/recurse_node/src/main.nr @@ -1,5 +1,3 @@ -use dep::std; - fn main( verification_key: [Field; 114], public_inputs: pub [Field; 4], @@ -14,4 +12,4 @@ fn main( key_hash ); public_inputs[3] as u64 -} \ No newline at end of file +} diff --git a/test_programs/benchmarks/bench_eddsa_poseidon/src/main.nr b/test_programs/benchmarks/bench_eddsa_poseidon/src/main.nr index 31c2f1f2d13..cb853e48c30 100644 --- a/test_programs/benchmarks/bench_eddsa_poseidon/src/main.nr +++ b/test_programs/benchmarks/bench_eddsa_poseidon/src/main.nr @@ -1,4 +1,4 @@ -use dep::std::eddsa::{eddsa_poseidon_verify}; +use std::eddsa::eddsa_poseidon_verify; fn main( msg: pub Field, @@ -9,4 +9,4 @@ fn main( s: Field ) -> pub bool { eddsa_poseidon_verify(pub_key_x, pub_key_y, s, r8_x, r8_y, msg) -} \ No newline at end of file +} diff --git a/test_programs/benchmarks/bench_poseidon_hash/src/main.nr b/test_programs/benchmarks/bench_poseidon_hash/src/main.nr index 38adeef6ec7..9900e91c1d7 100644 --- a/test_programs/benchmarks/bench_poseidon_hash/src/main.nr +++ b/test_programs/benchmarks/bench_poseidon_hash/src/main.nr @@ -1,4 +1,4 @@ -use dep::std::hash::poseidon; +use std::hash::poseidon; fn main(input: [Field; 2]) -> pub Field { poseidon::bn254::hash_2(input) diff --git a/test_programs/benchmarks/bench_poseidon_hash_100/src/main.nr b/test_programs/benchmarks/bench_poseidon_hash_100/src/main.nr index fc9a5b7a970..1c9bbfe61bf 100644 --- a/test_programs/benchmarks/bench_poseidon_hash_100/src/main.nr +++ b/test_programs/benchmarks/bench_poseidon_hash_100/src/main.nr @@ -1,4 +1,4 @@ -use dep::std::hash; +use std::hash; global SIZE = 100; @@ -9,4 +9,4 @@ fn main(input: [[Field; 2]; SIZE]) -> pub [Field; SIZE] { } results -} \ No newline at end of file +} diff --git a/test_programs/benchmarks/bench_poseidon_hash_30/src/main.nr b/test_programs/benchmarks/bench_poseidon_hash_30/src/main.nr index 4d2d94e4946..3edb47e9f72 100644 --- a/test_programs/benchmarks/bench_poseidon_hash_30/src/main.nr +++ b/test_programs/benchmarks/bench_poseidon_hash_30/src/main.nr @@ -1,4 +1,4 @@ -use dep::std::hash; +use std::hash; global SIZE = 30; @@ -9,4 +9,4 @@ fn main(input: [[Field; 2]; SIZE]) -> pub [Field; SIZE] { } results -} \ No newline at end of file +} diff --git a/test_programs/benchmarks/bench_sha256_100/src/main.nr b/test_programs/benchmarks/bench_sha256_100/src/main.nr index d78ca8002d2..6df856a83fc 100644 --- a/test_programs/benchmarks/bench_sha256_100/src/main.nr +++ b/test_programs/benchmarks/bench_sha256_100/src/main.nr @@ -1,5 +1,3 @@ -use dep::std; - global SIZE = 100; fn main(input: [[u8; 2]; SIZE]) -> pub [[u8; 32]; SIZE] { @@ -9,4 +7,4 @@ fn main(input: [[u8; 2]; SIZE]) -> pub [[u8; 32]; SIZE] { } results -} \ No newline at end of file +} diff --git a/test_programs/benchmarks/bench_sha256_30/src/main.nr b/test_programs/benchmarks/bench_sha256_30/src/main.nr index fa66d626586..220c1cfbbed 100644 --- a/test_programs/benchmarks/bench_sha256_30/src/main.nr +++ b/test_programs/benchmarks/bench_sha256_30/src/main.nr @@ -1,5 +1,3 @@ -use dep::std; - global SIZE = 30; fn main(input: [[u8; 2]; SIZE]) -> pub [[u8; 32]; SIZE] { @@ -9,4 +7,4 @@ fn main(input: [[u8; 2]; SIZE]) -> pub [[u8; 32]; SIZE] { } results -} \ No newline at end of file +} diff --git a/test_programs/compile_failure/turbofish_generic_count/src/main.nr b/test_programs/compile_failure/turbofish_generic_count/src/main.nr index a360641fa15..4091b2f0581 100644 --- a/test_programs/compile_failure/turbofish_generic_count/src/main.nr +++ b/test_programs/compile_failure/turbofish_generic_count/src/main.nr @@ -1,4 +1,3 @@ - struct Bar { one: Field, two: Field, @@ -7,7 +6,7 @@ struct Bar { impl Bar { fn zeroed(_self: Self) -> A { - dep::std::unsafe::zeroed() + std::unsafe::zeroed() } } diff --git a/test_programs/execution_success/brillig_block_parameter_liveness/src/main.nr b/test_programs/execution_success/brillig_block_parameter_liveness/src/main.nr index 142290ecbe2..2809668c574 100644 --- a/test_programs/execution_success/brillig_block_parameter_liveness/src/main.nr +++ b/test_programs/execution_success/brillig_block_parameter_liveness/src/main.nr @@ -38,11 +38,11 @@ struct Outer { // If we don't take into account block parameter liveness, this function will need 5*500=2500 stack items unconstrained fn main(conditions: [bool; 5]) -> pub Outer { let out0 = if conditions[0] { - let mut outer: Outer = dep::std::unsafe::zeroed(); + let mut outer: Outer = std::unsafe::zeroed(); outer.middle_a.inner_a.a = 1; outer } else { - let mut outer: Outer= dep::std::unsafe::zeroed(); + let mut outer: Outer= std::unsafe::zeroed(); outer.middle_f.inner_c.d = 2; outer }; diff --git a/test_programs/execution_success/generics/src/main.nr b/test_programs/execution_success/generics/src/main.nr index c8616960559..f754fb96292 100644 --- a/test_programs/execution_success/generics/src/main.nr +++ b/test_programs/execution_success/generics/src/main.nr @@ -34,7 +34,7 @@ impl Bar { impl Bar { // This is to test that we can use turbofish on methods as well fn zeroed(_self: Self) -> A { - dep::std::unsafe::zeroed() + std::unsafe::zeroed() } } diff --git a/test_programs/execution_success/regression_5045/src/main.nr b/test_programs/execution_success/regression_5045/src/main.nr index 9188dd3d76d..cf39b2f97e4 100644 --- a/test_programs/execution_success/regression_5045/src/main.nr +++ b/test_programs/execution_success/regression_5045/src/main.nr @@ -11,7 +11,7 @@ fn main(is_active: bool) { if is_active { let bad = EmbeddedCurvePoint { x: 0, y: 5, is_infinite: false }; let d = bad.double(); - let e = dep::std::embedded_curve_ops::multi_scalar_mul( + let e = std::embedded_curve_ops::multi_scalar_mul( [a, bad], [EmbeddedCurveScalar { lo: 1, hi: 0 }, EmbeddedCurveScalar { lo: 1, hi: 0 }] ); diff --git a/test_programs/execution_success/regression_5252/src/main.nr b/test_programs/execution_success/regression_5252/src/main.nr index 315807c3396..0bfd596a777 100644 --- a/test_programs/execution_success/regression_5252/src/main.nr +++ b/test_programs/execution_success/regression_5252/src/main.nr @@ -1,4 +1,4 @@ -use dep::std::hash::{mimc, poseidon, poseidon2::Poseidon2}; +use std::hash::{mimc, poseidon, poseidon2::Poseidon2}; global NUM_HASHES = 3; global HASH_LENGTH = 20; diff --git a/test_programs/execution_success/slice_coercion/src/main.nr b/test_programs/execution_success/slice_coercion/src/main.nr index a7ba0443bd1..4a83b739523 100644 --- a/test_programs/execution_success/slice_coercion/src/main.nr +++ b/test_programs/execution_success/slice_coercion/src/main.nr @@ -23,5 +23,5 @@ fn main(expected: pub Field, first: Field) { fn regression_4967() { let var1: [(i32, u8)] = [(1, 2)]; assert(var1.len() == 1); - dep::std::println(var1); + std::println(var1); } diff --git a/test_programs/noir_test_success/embedded_curve_ops/src/main.nr b/test_programs/noir_test_success/embedded_curve_ops/src/main.nr index 9e3c5d87874..225e86397fd 100644 --- a/test_programs/noir_test_success/embedded_curve_ops/src/main.nr +++ b/test_programs/noir_test_success/embedded_curve_ops/src/main.nr @@ -1,4 +1,4 @@ -use dep::std::embedded_curve_ops::{EmbeddedCurvePoint, EmbeddedCurveScalar, multi_scalar_mul}; +use std::embedded_curve_ops::{EmbeddedCurvePoint, EmbeddedCurveScalar, multi_scalar_mul}; #[test] diff --git a/test_programs/noir_test_success/regression_4561/src/main.nr b/test_programs/noir_test_success/regression_4561/src/main.nr index 138f7e805b3..70c447b49af 100644 --- a/test_programs/noir_test_success/regression_4561/src/main.nr +++ b/test_programs/noir_test_success/regression_4561/src/main.nr @@ -1,5 +1,5 @@ // Regression test for issue #4561 -use dep::std::test::OracleMock; +use std::test::OracleMock; type TReturnElem = [Field; 3]; type TReturn = [TReturnElem; 2]; @@ -41,4 +41,4 @@ unconstrained fn two_nested_return_unconstrained() -> (Field, TReturn, Field, TR fn two_nested_return() { OracleMock::mock("two_nested_return").returns((0, [1, 2, 3, 4, 5, 6], 7, [1, 2, 3, 4, 5, 6])); assert_eq(two_nested_return_unconstrained(), (0, [[1, 2, 3], [4, 5, 6]], 7, [[1, 2, 3], [4, 5, 6]])); -} \ No newline at end of file +} diff --git a/test_programs/noir_test_success/should_fail_with_matches/src/main.nr b/test_programs/noir_test_success/should_fail_with_matches/src/main.nr index 3a94d257ea4..b713976643b 100644 --- a/test_programs/noir_test_success/should_fail_with_matches/src/main.nr +++ b/test_programs/noir_test_success/should_fail_with_matches/src/main.nr @@ -19,12 +19,12 @@ fn test_should_fail_without_runtime_match() { } struct InvalidPointError { - point: dep::std::embedded_curve_ops::EmbeddedCurvePoint, + point: std::embedded_curve_ops::EmbeddedCurvePoint, } #[test(should_fail_with = "InvalidPointError { point: EmbeddedCurvePoint { x: 0x1cea3a116d01eb94d568ef04c3dfbc39f96f015ed801ab8958e360d406503ce0, y: 0x2721b237df87234acc36a238b8f231a3d31d18fe3845fff4cc59f0bd873818f8, is_infinite: false } }")] fn test_should_fail_with_struct() { - let hash = dep::std::hash::pedersen_commitment([27]); + let hash = std::hash::pedersen_commitment([27]); assert_eq(hash.x, 0, InvalidPointError { point: hash }); } @@ -37,7 +37,7 @@ fn test_should_fail_with_basic_type_fmt_string() { #[test(should_fail_with = "Invalid hash: EmbeddedCurvePoint { x: 0x1cea3a116d01eb94d568ef04c3dfbc39f96f015ed801ab8958e360d406503ce0, y: 0x2721b237df87234acc36a238b8f231a3d31d18fe3845fff4cc59f0bd873818f8, is_infinite: false }")] fn test_should_fail_with_struct_fmt_string() { - let hash = dep::std::hash::pedersen_commitment([27]); + let hash = std::hash::pedersen_commitment([27]); assert_eq(hash.x, 0, f"Invalid hash: {hash}"); } @@ -55,17 +55,17 @@ unconstrained fn unconstrained_test_should_fail_without_match() { #[test(should_fail_with = "Not equal")] unconstrained fn unconstrained_test_should_fail_with_runtime_match() { - assert_eq(dep::std::hash::pedersen_commitment([27]).x, 0, "Not equal"); + assert_eq(std::hash::pedersen_commitment([27]).x, 0, "Not equal"); } #[test(should_fail)] unconstrained fn unconstrained_test_should_fail_without_runtime_match() { - assert_eq(dep::std::hash::pedersen_commitment([27]).x, 0); + assert_eq(std::hash::pedersen_commitment([27]).x, 0); } #[test(should_fail_with = "InvalidPointError { point: EmbeddedCurvePoint { x: 0x1cea3a116d01eb94d568ef04c3dfbc39f96f015ed801ab8958e360d406503ce0, y: 0x2721b237df87234acc36a238b8f231a3d31d18fe3845fff4cc59f0bd873818f8, is_infinite: false } }")] unconstrained fn unconstrained_test_should_fail_with_struct() { - let hash = dep::std::hash::pedersen_commitment([27]); + let hash = std::hash::pedersen_commitment([27]); assert_eq(hash.x, 0, InvalidPointError { point: hash }); } @@ -78,6 +78,6 @@ unconstrained fn unconstrained_test_should_fail_with_basic_type_fmt_string() { #[test(should_fail_with = "Invalid hash: EmbeddedCurvePoint { x: 0x1cea3a116d01eb94d568ef04c3dfbc39f96f015ed801ab8958e360d406503ce0, y: 0x2721b237df87234acc36a238b8f231a3d31d18fe3845fff4cc59f0bd873818f8, is_infinite: false }")] unconstrained fn unconstrained_test_should_fail_with_struct_fmt_string() { - let hash = dep::std::hash::pedersen_commitment([27]); + let hash = std::hash::pedersen_commitment([27]); assert_eq(hash.x, 0, f"Invalid hash: {hash}"); } From 0a876b3df0aa7ef17508a28b1771342916da5c96 Mon Sep 17 00:00:00 2001 From: Tom French Date: Mon, 17 Jun 2024 12:47:59 +0100 Subject: [PATCH 19/26] chore: fix naming of new test --- .../Nargo.toml | 0 .../bin/Nargo.toml | 0 .../bin/Prover.toml | 0 .../bin/src/main.nr | 0 .../foo/Nargo.toml | 0 .../foo/src/lib.nr | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename test_programs/execution_success/{overlapping_dep_and_mod_fix => overlapping_dep_and_mod}/Nargo.toml (100%) rename test_programs/execution_success/{overlapping_dep_and_mod_fix => overlapping_dep_and_mod}/bin/Nargo.toml (100%) rename test_programs/execution_success/{overlapping_dep_and_mod_fix => overlapping_dep_and_mod}/bin/Prover.toml (100%) rename test_programs/execution_success/{overlapping_dep_and_mod_fix => overlapping_dep_and_mod}/bin/src/main.nr (100%) rename test_programs/execution_success/{overlapping_dep_and_mod_fix => overlapping_dep_and_mod}/foo/Nargo.toml (100%) rename test_programs/execution_success/{overlapping_dep_and_mod_fix => overlapping_dep_and_mod}/foo/src/lib.nr (100%) diff --git a/test_programs/execution_success/overlapping_dep_and_mod_fix/Nargo.toml b/test_programs/execution_success/overlapping_dep_and_mod/Nargo.toml similarity index 100% rename from test_programs/execution_success/overlapping_dep_and_mod_fix/Nargo.toml rename to test_programs/execution_success/overlapping_dep_and_mod/Nargo.toml diff --git a/test_programs/execution_success/overlapping_dep_and_mod_fix/bin/Nargo.toml b/test_programs/execution_success/overlapping_dep_and_mod/bin/Nargo.toml similarity index 100% rename from test_programs/execution_success/overlapping_dep_and_mod_fix/bin/Nargo.toml rename to test_programs/execution_success/overlapping_dep_and_mod/bin/Nargo.toml diff --git a/test_programs/execution_success/overlapping_dep_and_mod_fix/bin/Prover.toml b/test_programs/execution_success/overlapping_dep_and_mod/bin/Prover.toml similarity index 100% rename from test_programs/execution_success/overlapping_dep_and_mod_fix/bin/Prover.toml rename to test_programs/execution_success/overlapping_dep_and_mod/bin/Prover.toml diff --git a/test_programs/execution_success/overlapping_dep_and_mod_fix/bin/src/main.nr b/test_programs/execution_success/overlapping_dep_and_mod/bin/src/main.nr similarity index 100% rename from test_programs/execution_success/overlapping_dep_and_mod_fix/bin/src/main.nr rename to test_programs/execution_success/overlapping_dep_and_mod/bin/src/main.nr diff --git a/test_programs/execution_success/overlapping_dep_and_mod_fix/foo/Nargo.toml b/test_programs/execution_success/overlapping_dep_and_mod/foo/Nargo.toml similarity index 100% rename from test_programs/execution_success/overlapping_dep_and_mod_fix/foo/Nargo.toml rename to test_programs/execution_success/overlapping_dep_and_mod/foo/Nargo.toml diff --git a/test_programs/execution_success/overlapping_dep_and_mod_fix/foo/src/lib.nr b/test_programs/execution_success/overlapping_dep_and_mod/foo/src/lib.nr similarity index 100% rename from test_programs/execution_success/overlapping_dep_and_mod_fix/foo/src/lib.nr rename to test_programs/execution_success/overlapping_dep_and_mod/foo/src/lib.nr From 407b22a3b8e20ed8a2839b6bf6ccf754283fb5fb Mon Sep 17 00:00:00 2001 From: Tom French Date: Mon, 17 Jun 2024 13:15:09 +0100 Subject: [PATCH 20/26] chore: restrict parallelism in `rebuild.sh` --- test_programs/rebuild.sh | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/test_programs/rebuild.sh b/test_programs/rebuild.sh index 2d4147cb08c..094c3902583 100755 --- a/test_programs/rebuild.sh +++ b/test_programs/rebuild.sh @@ -1,8 +1,6 @@ #!/usr/bin/env bash set -e -NO_PARALLEL=${1:-} - process_dir() { local dir=$1 local current_dir=$2 @@ -62,28 +60,7 @@ for dir in $current_dir/benchmarks/*; do dirs_to_process+=("$dir") done -# Process each directory in parallel -pids=() -if [ -z $NO_PARALLEL ]; then -for dir in "${dirs_to_process[@]}"; do - process_dir "$dir" "$current_dir" & - pids+=($!) -done -else -for dir in "${dirs_to_process[@]}"; do - process_dir "$dir" "$current_dir" - pids+=($!) -done -fi -# Check the exit status of each background job. -for pid in "${pids[@]}"; do - wait $pid || exit_status=$? -done +parallel -j0 process_dir {} "$current_dir" ::: ${dirs_to_process[@]} -# Exit with a failure status if any job failed. -if [ ! -z "$exit_status" ]; then - echo "Rebuild failed!" - exit $exit_status -fi echo "Rebuild Succeeded!" From ec2b819c71ca89df23a17c7a757761dea1e8b3d9 Mon Sep 17 00:00:00 2001 From: Tom French Date: Mon, 17 Jun 2024 13:18:33 +0100 Subject: [PATCH 21/26] chore: remove useless `use std` statements --- .../circuits/recursion/src/main.nr | 2 -- docs/docs/how_to/merkle-proof.mdx | 1 - docs/docs/noir/concepts/data_types/integers.md | 1 - docs/docs/noir/concepts/data_types/strings.md | 1 - docs/docs/noir/standard_library/recursion.md | 1 - .../compile_failure/negate_unsigned/src/main.nr | 2 -- .../conditional_regression_to_bits/src/main.nr | 2 -- .../compile_success_empty/intrinsic_die/src/main.nr | 1 - .../method_call_regression/src/main.nr | 2 -- .../regression_3635/src/main.nr | 2 -- .../compile_success_empty/str_as_bytes/src/main.nr | 1 - .../trait_default_implementation/src/main.nr | 2 -- .../trait_override_implementation/src/main.nr | 2 -- .../compile_success_empty/traits/src/main.nr | 2 -- .../div_by_zero_constants/src/main.nr | 2 -- .../div_by_zero_numerator_witness/src/main.nr | 2 -- .../div_by_zero_witness/src/main.nr | 1 - test_programs/execution_success/4_sub/src/main.nr | 1 - test_programs/execution_success/5_over/src/main.nr | 1 - test_programs/execution_success/6/src/main.nr | 1 - test_programs/execution_success/6_array/src/main.nr | 1 - test_programs/execution_success/7/src/main.nr | 1 - .../execution_success/aes128_encrypt/src/main.nr | 2 -- test_programs/execution_success/blake3/src/main.nr | 2 -- .../execution_success/brillig_blake2s/src/main.nr | 1 - .../execution_success/brillig_blake3/src/main.nr | 2 -- .../brillig_ecdsa_secp256k1/src/main.nr | 1 - .../brillig_ecdsa_secp256r1/src/main.nr | 1 - .../brillig_fns_as_values/src/main.nr | 2 -- .../brillig_hash_to_field/src/main.nr | 1 - .../execution_success/brillig_keccak/src/main.nr | 1 - .../execution_success/brillig_pedersen/src/main.nr | 2 -- .../execution_success/brillig_sha256/src/main.nr | 1 - .../execution_success/conditional_1/src/main.nr | 2 -- .../execution_success/conditional_2/src/main.nr | 2 -- .../src/main.nr | 2 -- test_programs/execution_success/databus/src/main.nr | 2 -- .../double_verify_nested_proof/src/main.nr | 1 - .../double_verify_proof/src/main.nr | 1 - .../double_verify_proof_recursive/src/main.nr | 1 - .../execution_success/ecdsa_secp256k1/src/main.nr | 2 -- .../execution_success/ecdsa_secp256r1/src/main.nr | 2 -- .../ecdsa_secp256r1_3x/src/main.nr | 2 -- .../embedded_curve_ops/src/main.nr | 2 -- .../execution_success/hash_to_field/src/main.nr | 2 -- .../execution_success/keccak256/src/main.nr | 1 - .../execution_success/merkle_insert/src/main.nr | 1 - test_programs/execution_success/modulus/src/main.nr | 2 -- .../execution_success/pedersen_check/src/main.nr | 2 -- .../pedersen_commitment/src/main.nr | 1 - .../execution_success/pedersen_hash/src/main.nr | 1 - .../execution_success/regression_3394/src/main.nr | 2 -- .../execution_success/regression_4449/src/main.nr | 1 - .../regression_method_cannot_be_found/src/main.nr | 1 - test_programs/execution_success/schnorr/src/main.nr | 13 ++----------- test_programs/execution_success/sha256/src/main.nr | 1 - .../execution_success/sha2_byte/src/main.nr | 1 - .../execution_success/signed_comparison/src/main.nr | 2 -- .../execution_success/signed_division/src/main.nr | 1 - .../execution_success/simple_print/src/main.nr | 1 - .../execution_success/simple_shield/src/main.nr | 2 -- test_programs/execution_success/slices/src/main.nr | 1 - test_programs/execution_success/strings/src/main.nr | 1 - test_programs/execution_success/to_bits/src/main.nr | 2 -- .../to_bytes_integration/src/main.nr | 2 -- .../wrapping_operations/src/main.nr | 2 -- tooling/nargo_fmt/tests/expected/print.nr | 2 -- tooling/nargo_fmt/tests/expected/print2.nr | 2 -- .../nargo_fmt/tests/expected/singleton_import.nr | 1 - tooling/nargo_fmt/tests/input/print.nr | 2 -- tooling/nargo_fmt/tests/input/print2.nr | 2 -- tooling/nargo_fmt/tests/input/singleton_import.nr | 1 - .../noir_compiled_examples/assert_lt/src/main.nr | 2 -- 73 files changed, 2 insertions(+), 120 deletions(-) diff --git a/compiler/integration-tests/circuits/recursion/src/main.nr b/compiler/integration-tests/circuits/recursion/src/main.nr index 4f8d1713f3b..94cae14daa7 100644 --- a/compiler/integration-tests/circuits/recursion/src/main.nr +++ b/compiler/integration-tests/circuits/recursion/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main( verification_key: [Field; 114], proof: [Field; 93], diff --git a/docs/docs/how_to/merkle-proof.mdx b/docs/docs/how_to/merkle-proof.mdx index ec588f9a801..0a128adb2de 100644 --- a/docs/docs/how_to/merkle-proof.mdx +++ b/docs/docs/how_to/merkle-proof.mdx @@ -12,7 +12,6 @@ Let's walk through an example of a merkle membership proof in Noir that proves t in a merkle tree. ```rust -use std; fn main(message : [Field; 62], index : Field, hashpath : [Field; 40], root : Field) { let leaf = std::hash::hash_to_field(message.as_slice()); diff --git a/docs/docs/noir/concepts/data_types/integers.md b/docs/docs/noir/concepts/data_types/integers.md index f66277534f5..a1d59bf3166 100644 --- a/docs/docs/noir/concepts/data_types/integers.md +++ b/docs/docs/noir/concepts/data_types/integers.md @@ -149,7 +149,6 @@ fn wrapping_mul(x: T, y: T) -> T; Example of how it is used: ```rust -use std; fn main(x: u8, y: u8) -> pub u8 { std::wrapping_add(x, y) diff --git a/docs/docs/noir/concepts/data_types/strings.md b/docs/docs/noir/concepts/data_types/strings.md index a6cece811cd..1fdee42425e 100644 --- a/docs/docs/noir/concepts/data_types/strings.md +++ b/docs/docs/noir/concepts/data_types/strings.md @@ -20,7 +20,6 @@ You can use strings in `assert()` functions or print them with `println()`. See more about [Logging](../../standard_library/logging.md). ```rust -use std; fn main(message : pub str<11>, hex_as_string : str<4>) { println(message); diff --git a/docs/docs/noir/standard_library/recursion.md b/docs/docs/noir/standard_library/recursion.md index 33ba9721c21..8cfb37fc52d 100644 --- a/docs/docs/noir/standard_library/recursion.md +++ b/docs/docs/noir/standard_library/recursion.md @@ -40,7 +40,6 @@ pub fn verify_proof(verification_key: [Field], proof: [Field], public_inputs: [F ## Example usage ```rust -use std; fn main( verification_key : [Field; 114], diff --git a/test_programs/compile_failure/negate_unsigned/src/main.nr b/test_programs/compile_failure/negate_unsigned/src/main.nr index 79212acaf42..4d3c5abe5a4 100644 --- a/test_programs/compile_failure/negate_unsigned/src/main.nr +++ b/test_programs/compile_failure/negate_unsigned/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main() { let var = -1 as u8; std::println(var); diff --git a/test_programs/compile_success_empty/conditional_regression_to_bits/src/main.nr b/test_programs/compile_success_empty/conditional_regression_to_bits/src/main.nr index d8b1be8df7c..9b5d95c11bc 100644 --- a/test_programs/compile_success_empty/conditional_regression_to_bits/src/main.nr +++ b/test_programs/compile_success_empty/conditional_regression_to_bits/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main() { //Regression for to_le_bits() constant evaluation // binary array representation of u8 1 diff --git a/test_programs/compile_success_empty/intrinsic_die/src/main.nr b/test_programs/compile_success_empty/intrinsic_die/src/main.nr index 884f69564a8..c6e269c155d 100644 --- a/test_programs/compile_success_empty/intrinsic_die/src/main.nr +++ b/test_programs/compile_success_empty/intrinsic_die/src/main.nr @@ -1,4 +1,3 @@ -use std; // This test checks that we perform dead-instruction-elimination on intrinsic functions. fn main(x: Field) { let hash = std::hash::pedersen_commitment([x]); diff --git a/test_programs/compile_success_empty/method_call_regression/src/main.nr b/test_programs/compile_success_empty/method_call_regression/src/main.nr index e5ddfa6a934..88b8dc57196 100644 --- a/test_programs/compile_success_empty/method_call_regression/src/main.nr +++ b/test_programs/compile_success_empty/method_call_regression/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main() { // s: Struct let s = Struct { b: () }; diff --git a/test_programs/compile_success_empty/regression_3635/src/main.nr b/test_programs/compile_success_empty/regression_3635/src/main.nr index 3aad972c102..edc6d8690e8 100644 --- a/test_programs/compile_success_empty/regression_3635/src/main.nr +++ b/test_programs/compile_success_empty/regression_3635/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main() { let x: u8 = 0x61; let y: u8 = "a".as_bytes()[0]; diff --git a/test_programs/compile_success_empty/str_as_bytes/src/main.nr b/test_programs/compile_success_empty/str_as_bytes/src/main.nr index d812f3156b6..1330924e501 100644 --- a/test_programs/compile_success_empty/str_as_bytes/src/main.nr +++ b/test_programs/compile_success_empty/str_as_bytes/src/main.nr @@ -1,4 +1,3 @@ -use std; fn main() { let a = "hello"; let b = a.as_bytes(); diff --git a/test_programs/compile_success_empty/trait_default_implementation/src/main.nr b/test_programs/compile_success_empty/trait_default_implementation/src/main.nr index 56299187bf7..90c375b6010 100644 --- a/test_programs/compile_success_empty/trait_default_implementation/src/main.nr +++ b/test_programs/compile_success_empty/trait_default_implementation/src/main.nr @@ -1,5 +1,3 @@ -use std; - trait MyDefault { fn my_default(x: Field, y: Field) -> Self; diff --git a/test_programs/compile_success_empty/trait_override_implementation/src/main.nr b/test_programs/compile_success_empty/trait_override_implementation/src/main.nr index 6c9bf55a560..21d89b1b261 100644 --- a/test_programs/compile_success_empty/trait_override_implementation/src/main.nr +++ b/test_programs/compile_success_empty/trait_override_implementation/src/main.nr @@ -1,5 +1,3 @@ -use std; - trait MyDefault { fn my_default(x: Field, y: Field) -> Self; diff --git a/test_programs/compile_success_empty/traits/src/main.nr b/test_programs/compile_success_empty/traits/src/main.nr index a69177b9cc7..0a5644e7530 100644 --- a/test_programs/compile_success_empty/traits/src/main.nr +++ b/test_programs/compile_success_empty/traits/src/main.nr @@ -1,5 +1,3 @@ -use std; - trait MyDefault { fn my_default(x: Field, y: Field) -> Self; } diff --git a/test_programs/execution_failure/div_by_zero_constants/src/main.nr b/test_programs/execution_failure/div_by_zero_constants/src/main.nr index 58108769b35..f90b3ef9429 100644 --- a/test_programs/execution_failure/div_by_zero_constants/src/main.nr +++ b/test_programs/execution_failure/div_by_zero_constants/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main() { let a: Field = 3 / 0; std::println(a); diff --git a/test_programs/execution_failure/div_by_zero_numerator_witness/src/main.nr b/test_programs/execution_failure/div_by_zero_numerator_witness/src/main.nr index b3e0b43982a..012e823b297 100644 --- a/test_programs/execution_failure/div_by_zero_numerator_witness/src/main.nr +++ b/test_programs/execution_failure/div_by_zero_numerator_witness/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main(x: Field) { let a: Field = x / 0; std::println(a); diff --git a/test_programs/execution_failure/div_by_zero_witness/src/main.nr b/test_programs/execution_failure/div_by_zero_witness/src/main.nr index c4fb68e6c57..eaa3c1f2a72 100644 --- a/test_programs/execution_failure/div_by_zero_witness/src/main.nr +++ b/test_programs/execution_failure/div_by_zero_witness/src/main.nr @@ -1,4 +1,3 @@ -use std; // It is expected that `y` must be equal to 0. fn main(x: Field, y: pub Field) { let a: Field = x / y; diff --git a/test_programs/execution_success/4_sub/src/main.nr b/test_programs/execution_success/4_sub/src/main.nr index 64bb3f1c444..2b4fc395705 100644 --- a/test_programs/execution_success/4_sub/src/main.nr +++ b/test_programs/execution_success/4_sub/src/main.nr @@ -1,4 +1,3 @@ -use std; // Test unsafe integer subtraction with underflow: 12 - 2418266113 = 1876701195 modulo 2^32 fn main(mut x: u32, y: u32, z: u32) { x = std::wrapping_sub(x,y); diff --git a/test_programs/execution_success/5_over/src/main.nr b/test_programs/execution_success/5_over/src/main.nr index a16488671d2..6c4153e4b49 100644 --- a/test_programs/execution_success/5_over/src/main.nr +++ b/test_programs/execution_success/5_over/src/main.nr @@ -1,4 +1,3 @@ -use std; // Test unsafe integer arithmetic // Test odd bits integer fn main(mut x: u32, y: u32) { diff --git a/test_programs/execution_success/6/src/main.nr b/test_programs/execution_success/6/src/main.nr index c8e9268e20e..8657199bd7f 100644 --- a/test_programs/execution_success/6/src/main.nr +++ b/test_programs/execution_success/6/src/main.nr @@ -5,7 +5,6 @@ // If you do not cast, it will take all the bytes from the field element! // Mimc input is an array of field elements // The function is called mimc_bn254 to emphasize its parameters are chosen for bn254 curve, it should be used only with a proving system using the same curve (e.g Plonk from Aztec) -use std; fn main(x: [u8; 5], result: pub [u8; 32]) { let mut digest = std::hash::sha256(x); diff --git a/test_programs/execution_success/6_array/src/main.nr b/test_programs/execution_success/6_array/src/main.nr index 81c619305ff..d7180c260ff 100644 --- a/test_programs/execution_success/6_array/src/main.nr +++ b/test_programs/execution_success/6_array/src/main.nr @@ -1,4 +1,3 @@ -use std; //Basic tests for arrays fn main(x: [u32; 5], y: [u32; 5], mut z: u32, t: u32) { let mut c = 2301; diff --git a/test_programs/execution_success/7/src/main.nr b/test_programs/execution_success/7/src/main.nr index a6aef65ef50..ad3fe1aadc8 100644 --- a/test_programs/execution_success/7/src/main.nr +++ b/test_programs/execution_success/7/src/main.nr @@ -2,7 +2,6 @@ // // Pre-alpha dependencies must now be prefixed with the word "dep". // The line below indicates that we would like to pull in the standard library dependency. -use std; fn main(x: [u8; 5], result: [u8; 32]) { let digest = std::hash::blake2s(x); diff --git a/test_programs/execution_success/aes128_encrypt/src/main.nr b/test_programs/execution_success/aes128_encrypt/src/main.nr index 9392d7640f8..cd7fb4772e2 100644 --- a/test_programs/execution_success/aes128_encrypt/src/main.nr +++ b/test_programs/execution_success/aes128_encrypt/src/main.nr @@ -1,5 +1,3 @@ -use std; - unconstrained fn decode_ascii(ascii: u8) -> u8 { if ascii < 58 { ascii - 48 diff --git a/test_programs/execution_success/blake3/src/main.nr b/test_programs/execution_success/blake3/src/main.nr index 861a54fcfee..fb056bfa848 100644 --- a/test_programs/execution_success/blake3/src/main.nr +++ b/test_programs/execution_success/blake3/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main(x: [u8; 5], result: [u8; 32]) { let digest = std::hash::blake3(x); assert(digest == result); diff --git a/test_programs/execution_success/brillig_blake2s/src/main.nr b/test_programs/execution_success/brillig_blake2s/src/main.nr index fc095a1654c..2743e02e920 100644 --- a/test_programs/execution_success/brillig_blake2s/src/main.nr +++ b/test_programs/execution_success/brillig_blake2s/src/main.nr @@ -1,4 +1,3 @@ -use std; // Tests a very simple program. // // The features being tested is blake2s in brillig diff --git a/test_programs/execution_success/brillig_blake3/src/main.nr b/test_programs/execution_success/brillig_blake3/src/main.nr index 2f3f4984157..64852d775f4 100644 --- a/test_programs/execution_success/brillig_blake3/src/main.nr +++ b/test_programs/execution_success/brillig_blake3/src/main.nr @@ -1,5 +1,3 @@ -use std; - unconstrained fn main(x: [u8; 5], result: [u8; 32]) { let digest = std::hash::blake3(x); assert(digest == result); diff --git a/test_programs/execution_success/brillig_ecdsa_secp256k1/src/main.nr b/test_programs/execution_success/brillig_ecdsa_secp256k1/src/main.nr index 0ade00d77de..78343dcd26c 100644 --- a/test_programs/execution_success/brillig_ecdsa_secp256k1/src/main.nr +++ b/test_programs/execution_success/brillig_ecdsa_secp256k1/src/main.nr @@ -1,4 +1,3 @@ -use std; // Tests a very simple program. // // The features being tested is ecdsa in brillig diff --git a/test_programs/execution_success/brillig_ecdsa_secp256r1/src/main.nr b/test_programs/execution_success/brillig_ecdsa_secp256r1/src/main.nr index 8718663afbc..48debadb012 100644 --- a/test_programs/execution_success/brillig_ecdsa_secp256r1/src/main.nr +++ b/test_programs/execution_success/brillig_ecdsa_secp256r1/src/main.nr @@ -1,4 +1,3 @@ -use std; // Tests a very simple program. // // The features being tested is ecdsa in brillig diff --git a/test_programs/execution_success/brillig_fns_as_values/src/main.nr b/test_programs/execution_success/brillig_fns_as_values/src/main.nr index 8a02f43178d..1476c447431 100644 --- a/test_programs/execution_success/brillig_fns_as_values/src/main.nr +++ b/test_programs/execution_success/brillig_fns_as_values/src/main.nr @@ -1,5 +1,3 @@ -use std; - struct MyStruct { operation: fn (u32) -> u32, } diff --git a/test_programs/execution_success/brillig_hash_to_field/src/main.nr b/test_programs/execution_success/brillig_hash_to_field/src/main.nr index b297b3f4771..78759bd84c6 100644 --- a/test_programs/execution_success/brillig_hash_to_field/src/main.nr +++ b/test_programs/execution_success/brillig_hash_to_field/src/main.nr @@ -1,4 +1,3 @@ -use std; // Tests a very simple program. // // The features being tested is hash_to_field in brillig diff --git a/test_programs/execution_success/brillig_keccak/src/main.nr b/test_programs/execution_success/brillig_keccak/src/main.nr index 5cb6a298d85..9150e38f208 100644 --- a/test_programs/execution_success/brillig_keccak/src/main.nr +++ b/test_programs/execution_success/brillig_keccak/src/main.nr @@ -1,4 +1,3 @@ -use std; // Tests a very simple program. // // The features being tested is keccak256 in brillig diff --git a/test_programs/execution_success/brillig_pedersen/src/main.nr b/test_programs/execution_success/brillig_pedersen/src/main.nr index a667ba8d23f..17c79f9d0ae 100644 --- a/test_programs/execution_success/brillig_pedersen/src/main.nr +++ b/test_programs/execution_success/brillig_pedersen/src/main.nr @@ -1,5 +1,3 @@ -use std; - unconstrained fn main(x: Field, y: Field, salt: Field, out_x: Field, out_y: Field, out_hash: Field) { let res = std::hash::pedersen_commitment_with_separator([x, y], 0); assert(res.x == out_x); diff --git a/test_programs/execution_success/brillig_sha256/src/main.nr b/test_programs/execution_success/brillig_sha256/src/main.nr index 63f5d00d7ae..fcc01978a0a 100644 --- a/test_programs/execution_success/brillig_sha256/src/main.nr +++ b/test_programs/execution_success/brillig_sha256/src/main.nr @@ -1,4 +1,3 @@ -use std; // Tests a very simple program. // // The features being tested is sha256 in brillig diff --git a/test_programs/execution_success/conditional_1/src/main.nr b/test_programs/execution_success/conditional_1/src/main.nr index 6b4714a3442..e7d780263b8 100644 --- a/test_programs/execution_success/conditional_1/src/main.nr +++ b/test_programs/execution_success/conditional_1/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn sort(mut a: [u32; 4]) -> [u32; 4] { for i in 1..4 { for j in 0..i { diff --git a/test_programs/execution_success/conditional_2/src/main.nr b/test_programs/execution_success/conditional_2/src/main.nr index bb8c8ad4d8e..ea23ec3cf3b 100644 --- a/test_programs/execution_success/conditional_2/src/main.nr +++ b/test_programs/execution_success/conditional_2/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn must_be_zero(x: u8) { assert(x == 0); } diff --git a/test_programs/execution_success/conditional_regression_short_circuit/src/main.nr b/test_programs/execution_success/conditional_regression_short_circuit/src/main.nr index c707aa8b42c..de5ad20a642 100644 --- a/test_programs/execution_success/conditional_regression_short_circuit/src/main.nr +++ b/test_programs/execution_success/conditional_regression_short_circuit/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main(a: u32, mut c: [u32; 4], x: [u8; 5], result: pub [u8; 32]) { //regression for short-circuit2 if 35 == a { diff --git a/test_programs/execution_success/databus/src/main.nr b/test_programs/execution_success/databus/src/main.nr index 217a73f7476..7e5c23d508d 100644 --- a/test_programs/execution_success/databus/src/main.nr +++ b/test_programs/execution_success/databus/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main(mut x: u32, y: call_data u32, z: call_data [u32; 4]) -> return_data u32 { let a = z[x]; a + foo(y) diff --git a/test_programs/execution_success/double_verify_nested_proof/src/main.nr b/test_programs/execution_success/double_verify_nested_proof/src/main.nr index 0946ce4e238..5f0eb1a5b53 100644 --- a/test_programs/execution_success/double_verify_nested_proof/src/main.nr +++ b/test_programs/execution_success/double_verify_nested_proof/src/main.nr @@ -1,4 +1,3 @@ -use std; // This circuit aggregates two recursive proofs from `double_verify_proof_recursive`. // Recursive aggregation is a backend-specific process and it is expected for backends diff --git a/test_programs/execution_success/double_verify_proof/src/main.nr b/test_programs/execution_success/double_verify_proof/src/main.nr index 7a88bf7c5c9..d3b909c3fa4 100644 --- a/test_programs/execution_success/double_verify_proof/src/main.nr +++ b/test_programs/execution_success/double_verify_proof/src/main.nr @@ -1,4 +1,3 @@ -use std; // This circuit aggregates two proofs from `assert_statement_recursive`. fn main( diff --git a/test_programs/execution_success/double_verify_proof_recursive/src/main.nr b/test_programs/execution_success/double_verify_proof_recursive/src/main.nr index d488333cdf6..2555bbc4758 100644 --- a/test_programs/execution_success/double_verify_proof_recursive/src/main.nr +++ b/test_programs/execution_success/double_verify_proof_recursive/src/main.nr @@ -1,4 +1,3 @@ -use std; // This circuit aggregates two proofs from `assert_statement_recursive`. #[recursive] diff --git a/test_programs/execution_success/ecdsa_secp256k1/src/main.nr b/test_programs/execution_success/ecdsa_secp256k1/src/main.nr index 6e10ca34455..7f0999fc360 100644 --- a/test_programs/execution_success/ecdsa_secp256k1/src/main.nr +++ b/test_programs/execution_success/ecdsa_secp256k1/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main( message: [u8; 38], hashed_message: [u8; 32], diff --git a/test_programs/execution_success/ecdsa_secp256r1/src/main.nr b/test_programs/execution_success/ecdsa_secp256r1/src/main.nr index b5463f4d03a..09f427c37d9 100644 --- a/test_programs/execution_success/ecdsa_secp256r1/src/main.nr +++ b/test_programs/execution_success/ecdsa_secp256r1/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main(hashed_message: [u8; 32], pub_key_x: [u8; 32], pub_key_y: [u8; 32], signature: [u8; 64]) { let valid_signature = std::ecdsa_secp256r1::verify_signature(pub_key_x, pub_key_y, signature, hashed_message); assert(valid_signature); diff --git a/test_programs/execution_success/ecdsa_secp256r1_3x/src/main.nr b/test_programs/execution_success/ecdsa_secp256r1_3x/src/main.nr index 54bc621bc6c..b5bd633915f 100644 --- a/test_programs/execution_success/ecdsa_secp256r1_3x/src/main.nr +++ b/test_programs/execution_success/ecdsa_secp256r1_3x/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main( hashed_message: [u8; 32], pub_key_x: [u8; 32], diff --git a/test_programs/execution_success/embedded_curve_ops/src/main.nr b/test_programs/execution_success/embedded_curve_ops/src/main.nr index b7f4d3d4433..4eeda39c6aa 100644 --- a/test_programs/execution_success/embedded_curve_ops/src/main.nr +++ b/test_programs/execution_success/embedded_curve_ops/src/main.nr @@ -1,5 +1,3 @@ -use std; - 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/test_programs/execution_success/hash_to_field/src/main.nr b/test_programs/execution_success/hash_to_field/src/main.nr index 1e243781ed7..bb4f829ec33 100644 --- a/test_programs/execution_success/hash_to_field/src/main.nr +++ b/test_programs/execution_success/hash_to_field/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main(input: Field) -> pub Field { std::hash::hash_to_field(&[input]) } diff --git a/test_programs/execution_success/keccak256/src/main.nr b/test_programs/execution_success/keccak256/src/main.nr index 0558a6e7245..ff18cae0c9c 100644 --- a/test_programs/execution_success/keccak256/src/main.nr +++ b/test_programs/execution_success/keccak256/src/main.nr @@ -1,5 +1,4 @@ // docs:start:keccak256 -use std; fn main(x: Field, result: [u8; 32]) { // We use the `as` keyword here to denote the fact that we want to take just the first byte from the x Field diff --git a/test_programs/execution_success/merkle_insert/src/main.nr b/test_programs/execution_success/merkle_insert/src/main.nr index 8dfa98d3077..a08088e847b 100644 --- a/test_programs/execution_success/merkle_insert/src/main.nr +++ b/test_programs/execution_success/merkle_insert/src/main.nr @@ -1,4 +1,3 @@ -use std; use std::hash::mimc; fn main( diff --git a/test_programs/execution_success/modulus/src/main.nr b/test_programs/execution_success/modulus/src/main.nr index 75cf312b645..c7d6a2e2c7d 100644 --- a/test_programs/execution_success/modulus/src/main.nr +++ b/test_programs/execution_success/modulus/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main(bn254_modulus_be_bytes: [u8; 32], bn254_modulus_be_bits: [u1; 254]) { let modulus_size = std::field::modulus_num_bits(); // NOTE: The constraints used in this circuit will only work when testing nargo with the plonk bn254 backend diff --git a/test_programs/execution_success/pedersen_check/src/main.nr b/test_programs/execution_success/pedersen_check/src/main.nr index 3405e6daee2..c71b2b570da 100644 --- a/test_programs/execution_success/pedersen_check/src/main.nr +++ b/test_programs/execution_success/pedersen_check/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main(x: Field, y: Field, salt: Field, out_x: Field, out_y: Field, out_hash: Field) { let res = std::hash::pedersen_commitment([x, y]); assert(res.x == out_x); diff --git a/test_programs/execution_success/pedersen_commitment/src/main.nr b/test_programs/execution_success/pedersen_commitment/src/main.nr index 6d1070cef7e..81c605a64dd 100644 --- a/test_programs/execution_success/pedersen_commitment/src/main.nr +++ b/test_programs/execution_success/pedersen_commitment/src/main.nr @@ -1,5 +1,4 @@ // docs:start:pedersen-commitment -use std; fn main(x: Field, y: Field, expected_commitment: std::embedded_curve_ops::EmbeddedCurvePoint) { let commitment = std::hash::pedersen_commitment([x, y]); diff --git a/test_programs/execution_success/pedersen_hash/src/main.nr b/test_programs/execution_success/pedersen_hash/src/main.nr index 42712df370f..f8ec56a9d98 100644 --- a/test_programs/execution_success/pedersen_hash/src/main.nr +++ b/test_programs/execution_success/pedersen_hash/src/main.nr @@ -1,5 +1,4 @@ // docs:start:pedersen-hash -use std; fn main(x: Field, y: Field, expected_hash: Field) { let hash = std::hash::pedersen_hash([x, y]); diff --git a/test_programs/execution_success/regression_3394/src/main.nr b/test_programs/execution_success/regression_3394/src/main.nr index bcca4f36396..59494253757 100644 --- a/test_programs/execution_success/regression_3394/src/main.nr +++ b/test_programs/execution_success/regression_3394/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main() { let x : i8 = -128; std::println(x); diff --git a/test_programs/execution_success/regression_4449/src/main.nr b/test_programs/execution_success/regression_4449/src/main.nr index ca7f239bd4e..66bab2e09f4 100644 --- a/test_programs/execution_success/regression_4449/src/main.nr +++ b/test_programs/execution_success/regression_4449/src/main.nr @@ -1,5 +1,4 @@ // Regression test for issue #4449 -use std; fn main(x: u8, result: [u8; 32]) { let x = x % 31; diff --git a/test_programs/execution_success/regression_method_cannot_be_found/src/main.nr b/test_programs/execution_success/regression_method_cannot_be_found/src/main.nr index fb6e664e1d7..c7db543f1bb 100644 --- a/test_programs/execution_success/regression_method_cannot_be_found/src/main.nr +++ b/test_programs/execution_success/regression_method_cannot_be_found/src/main.nr @@ -1,4 +1,3 @@ -use std; struct Item { id: Field, } diff --git a/test_programs/execution_success/schnorr/src/main.nr b/test_programs/execution_success/schnorr/src/main.nr index add65050a83..5bc0ca9fefb 100644 --- a/test_programs/execution_success/schnorr/src/main.nr +++ b/test_programs/execution_success/schnorr/src/main.nr @@ -1,4 +1,3 @@ -use std; use std::embedded_curve_ops; // Note: If main has any unsized types, then the verifier will never be able @@ -37,11 +36,7 @@ fn main( // Meanwhile, you have to use a message with 32 additional bytes: // If you want to verify a signature on a message of 10 bytes, you need to pass a message of length 42, // where the first 10 bytes are the one from the original message (the other bytes are not used) -pub fn verify_signature_noir( - public_key: embedded_curve_ops::EmbeddedCurvePoint, - signature: [u8; 64], - message: [u8; M] -) -> bool { +pub fn verify_signature_noir(public_key: embedded_curve_ops::EmbeddedCurvePoint, signature: [u8; 64], message: [u8; M]) -> bool { let N = message.len() - 32; //scalar lo/hi from bytes @@ -90,11 +85,7 @@ pub fn bytes_to_scalar(bytes: [u8; 64], offset: u32) -> embedded_curve_ops::Embe sig_s } -pub fn assert_valid_signature( - public_key: embedded_curve_ops::EmbeddedCurvePoint, - signature: [u8; 64], - message: [u8; M] -) { +pub fn assert_valid_signature(public_key: embedded_curve_ops::EmbeddedCurvePoint, signature: [u8; 64], message: [u8; M]) { let N = message.len() - 32; //scalar lo/hi from bytes let sig_s = bytes_to_scalar(signature, 0); diff --git a/test_programs/execution_success/sha256/src/main.nr b/test_programs/execution_success/sha256/src/main.nr index 41e51e639b5..4f999d349f0 100644 --- a/test_programs/execution_success/sha256/src/main.nr +++ b/test_programs/execution_success/sha256/src/main.nr @@ -9,7 +9,6 @@ // // Not yet here: For R1CS, it is more about manipulating arithmetic gates to get performance // This can be done in ACIR! -use std; fn main(x: Field, result: [u8; 32]) { // We use the `as` keyword here to denote the fact that we want to take just the first byte from the x Field diff --git a/test_programs/execution_success/sha2_byte/src/main.nr b/test_programs/execution_success/sha2_byte/src/main.nr index b61cfbd473c..aecd9fba2f3 100644 --- a/test_programs/execution_success/sha2_byte/src/main.nr +++ b/test_programs/execution_success/sha2_byte/src/main.nr @@ -1,5 +1,4 @@ // Test Noir implementations of SHA256 and SHA512 on a one-byte message. -use std; fn main(x: Field, result256: [u8; 32], result512: [u8; 64]) { let digest256 = std::sha256::digest([x as u8]); diff --git a/test_programs/execution_success/signed_comparison/src/main.nr b/test_programs/execution_success/signed_comparison/src/main.nr index 27ff51865f7..0fe72112f5a 100644 --- a/test_programs/execution_success/signed_comparison/src/main.nr +++ b/test_programs/execution_success/signed_comparison/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main(mut x: i8, mut y: i8, z: i8) { let mut s1: i8 = 5; let mut s2: i8 = 8; diff --git a/test_programs/execution_success/signed_division/src/main.nr b/test_programs/execution_success/signed_division/src/main.nr index 1831fd59d31..207ef59986b 100644 --- a/test_programs/execution_success/signed_division/src/main.nr +++ b/test_programs/execution_success/signed_division/src/main.nr @@ -1,4 +1,3 @@ -use std; // Testing signed integer division: // 7/3 = 2 // -7/3 = -2 diff --git a/test_programs/execution_success/simple_print/src/main.nr b/test_programs/execution_success/simple_print/src/main.nr index 5e164a16e0a..3a68f8cc4c3 100644 --- a/test_programs/execution_success/simple_print/src/main.nr +++ b/test_programs/execution_success/simple_print/src/main.nr @@ -1,6 +1,5 @@ // Simple program for testing the logging // of single witnesses and witness arrays. -use std; fn main(x: Field, y: pub Field) { std::println(x); diff --git a/test_programs/execution_success/simple_shield/src/main.nr b/test_programs/execution_success/simple_shield/src/main.nr index 40dfb9a68d5..d84288b9fd6 100644 --- a/test_programs/execution_success/simple_shield/src/main.nr +++ b/test_programs/execution_success/simple_shield/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main( // Public key of note // all notes have the same denomination diff --git a/test_programs/execution_success/slices/src/main.nr b/test_programs/execution_success/slices/src/main.nr index b5b0a6a018f..8be79cdc3c4 100644 --- a/test_programs/execution_success/slices/src/main.nr +++ b/test_programs/execution_success/slices/src/main.nr @@ -1,5 +1,4 @@ use std::slice; -use std; fn main(x: Field, y: pub Field) { let mut slice = &[0; 2]; diff --git a/test_programs/execution_success/strings/src/main.nr b/test_programs/execution_success/strings/src/main.nr index e5553d684f6..d28a9f483ac 100644 --- a/test_programs/execution_success/strings/src/main.nr +++ b/test_programs/execution_success/strings/src/main.nr @@ -1,4 +1,3 @@ -use std; // Test global string literals global HELLO_WORLD = "hello world"; diff --git a/test_programs/execution_success/to_bits/src/main.nr b/test_programs/execution_success/to_bits/src/main.nr index 7e3af98f24a..84ace83903a 100644 --- a/test_programs/execution_success/to_bits/src/main.nr +++ b/test_programs/execution_success/to_bits/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main() { let field = 1000; let be_bits = field.to_be_bits(16); diff --git a/test_programs/execution_success/to_bytes_integration/src/main.nr b/test_programs/execution_success/to_bytes_integration/src/main.nr index 8adab30e9b0..21c4ad90bfe 100644 --- a/test_programs/execution_success/to_bytes_integration/src/main.nr +++ b/test_programs/execution_success/to_bytes_integration/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main(x: Field, a: Field) { let y: Field = 2040124; let be_byte_array = y.to_be_bytes(31); diff --git a/test_programs/execution_success/wrapping_operations/src/main.nr b/test_programs/execution_success/wrapping_operations/src/main.nr index 093e7a182f6..d8345884c82 100644 --- a/test_programs/execution_success/wrapping_operations/src/main.nr +++ b/test_programs/execution_success/wrapping_operations/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main(x: u8, y: u8) { assert(std::wrapping_sub(x, 1) == y); assert(std::wrapping_add(y, 1) == x); diff --git a/tooling/nargo_fmt/tests/expected/print.nr b/tooling/nargo_fmt/tests/expected/print.nr index 417467f977f..d8404f674b0 100644 --- a/tooling/nargo_fmt/tests/expected/print.nr +++ b/tooling/nargo_fmt/tests/expected/print.nr @@ -1,5 +1,3 @@ -use std; - fn main() { std::print("Hello world"); std::println("Hello world"); diff --git a/tooling/nargo_fmt/tests/expected/print2.nr b/tooling/nargo_fmt/tests/expected/print2.nr index 417467f977f..d8404f674b0 100644 --- a/tooling/nargo_fmt/tests/expected/print2.nr +++ b/tooling/nargo_fmt/tests/expected/print2.nr @@ -1,5 +1,3 @@ -use std; - fn main() { std::print("Hello world"); std::println("Hello world"); diff --git a/tooling/nargo_fmt/tests/expected/singleton_import.nr b/tooling/nargo_fmt/tests/expected/singleton_import.nr index 6df6580589c..860efff84aa 100644 --- a/tooling/nargo_fmt/tests/expected/singleton_import.nr +++ b/tooling/nargo_fmt/tests/expected/singleton_import.nr @@ -1,2 +1 @@ -use std; use some_crate; diff --git a/tooling/nargo_fmt/tests/input/print.nr b/tooling/nargo_fmt/tests/input/print.nr index 417467f977f..d8404f674b0 100644 --- a/tooling/nargo_fmt/tests/input/print.nr +++ b/tooling/nargo_fmt/tests/input/print.nr @@ -1,5 +1,3 @@ -use std; - fn main() { std::print("Hello world"); std::println("Hello world"); diff --git a/tooling/nargo_fmt/tests/input/print2.nr b/tooling/nargo_fmt/tests/input/print2.nr index 417467f977f..d8404f674b0 100644 --- a/tooling/nargo_fmt/tests/input/print2.nr +++ b/tooling/nargo_fmt/tests/input/print2.nr @@ -1,5 +1,3 @@ -use std; - fn main() { std::print("Hello world"); std::println("Hello world"); diff --git a/tooling/nargo_fmt/tests/input/singleton_import.nr b/tooling/nargo_fmt/tests/input/singleton_import.nr index 6df6580589c..860efff84aa 100644 --- a/tooling/nargo_fmt/tests/input/singleton_import.nr +++ b/tooling/nargo_fmt/tests/input/singleton_import.nr @@ -1,2 +1 @@ -use std; use some_crate; diff --git a/tooling/noir_js/test/noir_compiled_examples/assert_lt/src/main.nr b/tooling/noir_js/test/noir_compiled_examples/assert_lt/src/main.nr index 79a1d892d89..5a20a92048f 100644 --- a/tooling/noir_js/test/noir_compiled_examples/assert_lt/src/main.nr +++ b/tooling/noir_js/test/noir_compiled_examples/assert_lt/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main(x: u64, y: pub u64) -> pub u64 { // We include a println statement to show that noirJS will ignore this and continue execution std::println("foo"); From c51cdd65ed099b8bedc7711213f1f947e48608ad Mon Sep 17 00:00:00 2001 From: Tom French Date: Mon, 17 Jun 2024 13:19:47 +0100 Subject: [PATCH 22/26] chore: clean up straggler --- test_programs/execution_success/u128/src/main.nr | 2 -- 1 file changed, 2 deletions(-) diff --git a/test_programs/execution_success/u128/src/main.nr b/test_programs/execution_success/u128/src/main.nr index 4bbdcd1dd26..d0835ccf30f 100644 --- a/test_programs/execution_success/u128/src/main.nr +++ b/test_programs/execution_success/u128/src/main.nr @@ -1,5 +1,3 @@ -use std; - fn main(mut x: u32, y: u32, z: u32, big_int: U128, hexa: str<7>) { let a = U128::from_u64s_le(x as u64, x as u64); let b = U128::from_u64s_le(y as u64, x as u64); From 74526c4079807b7eab8fce8b99185811f5796f60 Mon Sep 17 00:00:00 2001 From: Tom French Date: Mon, 17 Jun 2024 13:22:52 +0100 Subject: [PATCH 23/26] chore: revert change to formatter test --- tooling/nargo_fmt/tests/expected/singleton_import.nr | 1 + tooling/nargo_fmt/tests/input/singleton_import.nr | 1 + 2 files changed, 2 insertions(+) diff --git a/tooling/nargo_fmt/tests/expected/singleton_import.nr b/tooling/nargo_fmt/tests/expected/singleton_import.nr index 860efff84aa..6df6580589c 100644 --- a/tooling/nargo_fmt/tests/expected/singleton_import.nr +++ b/tooling/nargo_fmt/tests/expected/singleton_import.nr @@ -1 +1,2 @@ +use std; use some_crate; diff --git a/tooling/nargo_fmt/tests/input/singleton_import.nr b/tooling/nargo_fmt/tests/input/singleton_import.nr index 860efff84aa..6df6580589c 100644 --- a/tooling/nargo_fmt/tests/input/singleton_import.nr +++ b/tooling/nargo_fmt/tests/input/singleton_import.nr @@ -1 +1,2 @@ +use std; use some_crate; From a53fb5c6e4df725dfb9fe736b1791f99d617da0e Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Mon, 17 Jun 2024 13:31:50 +0100 Subject: [PATCH 24/26] Update compiler/noirc_frontend/src/parser/errors.rs --- compiler/noirc_frontend/src/parser/errors.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/noirc_frontend/src/parser/errors.rs b/compiler/noirc_frontend/src/parser/errors.rs index f6d9dbafb71..af3d4caa145 100644 --- a/compiler/noirc_frontend/src/parser/errors.rs +++ b/compiler/noirc_frontend/src/parser/errors.rs @@ -20,7 +20,7 @@ pub enum ParserErrorReason { MissingSeparatingSemi, #[error("constrain keyword is deprecated")] ConstrainDeprecated, - #[error("'dep::' prefix in paths is deprecated")] + #[error("Expression is invalid in an array-length type: '{0}'. Only unsigned integer constants, globals, generics, +, -, *, /, and % may be used in this context.")] InvalidArrayLengthExpression(Expression), #[error("Early 'return' is unsupported")] EarlyReturn, From ac9cdbc5f09b02c23a1645493dc072c5bf7addac Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Mon, 17 Jun 2024 13:34:31 +0100 Subject: [PATCH 25/26] Update docs/docs/noir/concepts/data_types/slices.mdx --- docs/docs/noir/concepts/data_types/slices.mdx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/docs/noir/concepts/data_types/slices.mdx b/docs/docs/noir/concepts/data_types/slices.mdx index 37cb25e2641..dff08d63ffb 100644 --- a/docs/docs/noir/concepts/data_types/slices.mdx +++ b/docs/docs/noir/concepts/data_types/slices.mdx @@ -12,9 +12,7 @@ import Experimental from '@site/src/components/Notes/_experimental.mdx'; A slice is a dynamically-sized view into a sequence of elements. They can be resized at runtime, but because they don't own the data, they cannot be returned from a circuit. You can treat slices as arrays without a constrained size. ```rust -use std::slice; - -fn main() -> pub Field { +fn main() -> pub u32 { let mut slice: [Field] = &[0; 2]; let mut new_slice = slice.push_back(6); From 881609595cf1070e08c7e04bee338da3478518d6 Mon Sep 17 00:00:00 2001 From: Tom French Date: Mon, 17 Jun 2024 18:16:30 +0100 Subject: [PATCH 26/26] chore: revert changes to formatter --- tooling/nargo_fmt/src/rewrite/imports.rs | 5 ++++- tooling/nargo_fmt/tests/expected/singleton_import.nr | 2 +- tooling/nargo_fmt/tests/input/singleton_import.nr | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tooling/nargo_fmt/src/rewrite/imports.rs b/tooling/nargo_fmt/src/rewrite/imports.rs index 7e4bc7c1dda..564ef3fa370 100644 --- a/tooling/nargo_fmt/src/rewrite/imports.rs +++ b/tooling/nargo_fmt/src/rewrite/imports.rs @@ -12,6 +12,7 @@ use crate::{ pub(crate) enum UseSegment { Ident(String, Option), List(Vec), + Dep, Crate, } @@ -47,6 +48,7 @@ impl UseSegment { format!("{{{list_str}}}") } } + UseSegment::Dep => "dep".into(), UseSegment::Crate => "crate".into(), } } @@ -63,7 +65,8 @@ impl UseTree { match use_tree.prefix.kind { ast::PathKind::Crate => result.path.push(UseSegment::Crate), - ast::PathKind::Plain | ast::PathKind::Dep => {} + ast::PathKind::Dep => result.path.push(UseSegment::Dep), + ast::PathKind::Plain => {} }; result.path.extend( diff --git a/tooling/nargo_fmt/tests/expected/singleton_import.nr b/tooling/nargo_fmt/tests/expected/singleton_import.nr index 6df6580589c..bb1bad500d9 100644 --- a/tooling/nargo_fmt/tests/expected/singleton_import.nr +++ b/tooling/nargo_fmt/tests/expected/singleton_import.nr @@ -1,2 +1,2 @@ -use std; +use dep::std; use some_crate; diff --git a/tooling/nargo_fmt/tests/input/singleton_import.nr b/tooling/nargo_fmt/tests/input/singleton_import.nr index 6df6580589c..bb1bad500d9 100644 --- a/tooling/nargo_fmt/tests/input/singleton_import.nr +++ b/tooling/nargo_fmt/tests/input/singleton_import.nr @@ -1,2 +1,2 @@ -use std; +use dep::std; use some_crate;