diff --git a/Cargo.lock b/Cargo.lock index 41e0b71727d..f0d9e3a86c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -300,6 +300,12 @@ dependencies = [ "arbitrary", ] +[[package]] +name = "arc-swap" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" + [[package]] name = "ark-bls12-381" version = "0.5.0" @@ -2346,7 +2352,7 @@ dependencies = [ "hyper", "libc", "pin-project-lite", - "socket2 0.5.10", + "socket2", "tokio", "tower-service", "tracing", @@ -4740,16 +4746,18 @@ dependencies = [ [[package]] name = "redis" -version = "0.23.3" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f49cdc0bb3f412bf8e7d1bd90fe1d9eb10bc5c399ba90973c14662a27b3f8ba" +checksum = "e902a69d09078829137b4a5d9d082e0490393537badd7c91a3d69d14639e115f" dependencies = [ + "arc-swap", "combine", "itoa", + "num-bigint", "percent-encoding", "ryu", "sha1_smol", - "socket2 0.4.10", + "socket2", "url", ] @@ -5519,16 +5527,6 @@ dependencies = [ "serde", ] -[[package]] -name = "socket2" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "socket2" version = "0.5.10" @@ -5965,7 +5963,7 @@ dependencies = [ "libc", "mio 1.0.4", "pin-project-lite", - "socket2 0.5.10", + "socket2", "tokio-macros", "windows-sys 0.52.0", ] diff --git a/Cargo.toml b/Cargo.toml index cffee8c08ed..24411fc4d9a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,6 +75,7 @@ unused_qualifications = "warn" unreachable_pub = "warn" unsafe_code = "deny" unused_must_use = "warn" +mismatched_lifetime_syntaxes = "allow" [workspace.lints.clippy] semicolon_if_nothing_returned = "warn" diff --git a/acvm-repo/acvm_js/src/foreign_call/outputs.rs b/acvm-repo/acvm_js/src/foreign_call/outputs.rs index 75b9c3aa311..fb6ca59d291 100644 --- a/acvm-repo/acvm_js/src/foreign_call/outputs.rs +++ b/acvm-repo/acvm_js/src/foreign_call/outputs.rs @@ -19,7 +19,7 @@ fn decode_foreign_call_output(output: JsValue) -> Result::Bar` - AsTraitPath(Box), + AsTraitPath(Box), /// An already resolved type. These can only be parsed if they were present in the token stream /// as a result of being spliced into a macro's token stream input. @@ -295,10 +295,10 @@ impl std::fmt::Display for UnresolvedTypeData { let args = vecmap(args, ToString::to_string).join(", "); match &env.as_ref().typ { - UnresolvedTypeData::Unit => { + Unit => { write!(f, "fn({args}) -> {ret}") } - UnresolvedTypeData::Tuple(env_types) => { + Tuple(env_types) => { let env_types = vecmap(env_types, |arg| arg.typ.to_string()).join(", "); write!(f, "fn[{env_types}]({args}) -> {ret}") } diff --git a/compiler/noirc_frontend/src/ast/statement.rs b/compiler/noirc_frontend/src/ast/statement.rs index eb0180e017b..6b120ada5b9 100644 --- a/compiler/noirc_frontend/src/ast/statement.rs +++ b/compiler/noirc_frontend/src/ast/statement.rs @@ -299,7 +299,7 @@ pub struct ModuleDeclaration { pub has_semicolon: bool, } -impl std::fmt::Display for ModuleDeclaration { +impl Display for ModuleDeclaration { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "mod {}", self.ident) } diff --git a/compiler/noirc_frontend/src/debug/mod.rs b/compiler/noirc_frontend/src/debug/mod.rs index dc2e1fc1f41..c2b7527207f 100644 --- a/compiler/noirc_frontend/src/debug/mod.rs +++ b/compiler/noirc_frontend/src/debug/mod.rs @@ -187,7 +187,7 @@ impl DebugInstrumenter { let last_stmt = if has_ret_expr { ast::Statement { kind: ast::StatementKind::Expression(ast::Expression { - kind: ast::ExpressionKind::Variable(ast::Path::plain( + kind: ast::ExpressionKind::Variable(Path::plain( vec![PathSegment::from(ident("__debug_expr", location))], location, )), @@ -649,7 +649,7 @@ fn build_assign_var_stmt(var_id: SourceVarId, expr: ast::Expression) -> ast::Sta let location = expr.location; let kind = ast::ExpressionKind::Call(Box::new(ast::CallExpression { func: Box::new(ast::Expression { - kind: ast::ExpressionKind::Variable(ast::Path::plain( + kind: ast::ExpressionKind::Variable(Path::plain( vec![PathSegment::from(ident("__debug_var_assign", location))], location, )), @@ -664,7 +664,7 @@ fn build_assign_var_stmt(var_id: SourceVarId, expr: ast::Expression) -> ast::Sta fn build_drop_var_stmt(var_id: SourceVarId, location: Location) -> ast::Statement { let kind = ast::ExpressionKind::Call(Box::new(ast::CallExpression { func: Box::new(ast::Expression { - kind: ast::ExpressionKind::Variable(ast::Path::plain( + kind: ast::ExpressionKind::Variable(Path::plain( vec![PathSegment::from(ident("__debug_var_drop", location))], location, )), @@ -688,7 +688,7 @@ fn build_assign_member_stmt( let location = expr.location; let kind = ast::ExpressionKind::Call(Box::new(ast::CallExpression { func: Box::new(ast::Expression { - kind: ast::ExpressionKind::Variable(ast::Path::plain( + kind: ast::ExpressionKind::Variable(Path::plain( vec![PathSegment::from(ident(&format!["__debug_member_assign_{arity}"], location))], location, )), @@ -708,7 +708,7 @@ fn build_assign_member_stmt( fn build_debug_call_stmt(fname: &str, fn_id: DebugFnId, location: Location) -> ast::Statement { let kind = ast::ExpressionKind::Call(Box::new(ast::CallExpression { func: Box::new(ast::Expression { - kind: ast::ExpressionKind::Variable(ast::Path::plain( + kind: ast::ExpressionKind::Variable(Path::plain( vec![PathSegment::from(ident(&format!["__debug_fn_{fname}"], location))], location, )), diff --git a/compiler/noirc_frontend/src/elaborator/enums.rs b/compiler/noirc_frontend/src/elaborator/enums.rs index dc342b236c1..409c2582839 100644 --- a/compiler/noirc_frontend/src/elaborator/enums.rs +++ b/compiler/noirc_frontend/src/elaborator/enums.rs @@ -183,14 +183,13 @@ impl Elaborator<'_> { let no_parameters = Parameters(Vec::new()); let global_body = self.make_enum_variant_constructor(datatype, variant_index, &no_parameters, location); - let let_statement = crate::hir_def::stmt::HirStatement::Expression(global_body); + let let_statement = HirStatement::Expression(global_body); let statement_id = self.interner.get_global(global_id).let_statement; self.interner.replace_statement(statement_id, let_statement); - self.interner.get_global_mut(global_id).value = GlobalValue::Resolved( - crate::hir::comptime::Value::Enum(variant_index, Vec::new(), typ), - ); + self.interner.get_global_mut(global_id).value = + GlobalValue::Resolved(Value::Enum(variant_index, Vec::new(), typ)); Self::get_module_mut(self.def_maps, type_id.module_id()) .declare_global(name.clone(), enum_.visibility, global_id) diff --git a/compiler/noirc_frontend/src/elaborator/expressions.rs b/compiler/noirc_frontend/src/elaborator/expressions.rs index 89af482a168..a4fcfa04a13 100644 --- a/compiler/noirc_frontend/src/elaborator/expressions.rs +++ b/compiler/noirc_frontend/src/elaborator/expressions.rs @@ -769,7 +769,7 @@ impl Elaborator<'_> { // Given that we already produced an error, let's make this an `assert(true)` so // we don't get further errors. let message = None; - let kind = ExpressionKind::Literal(crate::ast::Literal::Bool(true)); + let kind = ExpressionKind::Literal(Literal::Bool(true)); let expr = Expression { kind, location }; (message, expr) } else { @@ -1232,7 +1232,7 @@ impl Elaborator<'_> { match_expr: MatchExpression, location: Location, ) -> (HirExpression, Type) { - self.use_unstable_feature(super::UnstableFeature::Enums, location); + self.use_unstable_feature(UnstableFeature::Enums, location); let expr_location = match_expr.expression.location; let (expression, typ) = self.elaborate_expression(match_expr.expression); diff --git a/compiler/noirc_frontend/src/elaborator/types.rs b/compiler/noirc_frontend/src/elaborator/types.rs index 984d8a0ea20..5139e8e35d4 100644 --- a/compiler/noirc_frontend/src/elaborator/types.rs +++ b/compiler/noirc_frontend/src/elaborator/types.rs @@ -1539,7 +1539,7 @@ impl Elaborator<'_> { use Type::*; match op { - crate::ast::UnaryOp::Minus | crate::ast::UnaryOp::Not => { + UnaryOp::Minus | UnaryOp::Not => { match rhs_type { // An error type will always return an error Error => Ok((Error, false)), @@ -1557,7 +1557,7 @@ impl Elaborator<'_> { // The `!` prefix operator is not valid for Field, so if this is a numeric // type we constrain it to just (non-Field) integer types. - if matches!(op, crate::ast::UnaryOp::Not) && rhs_type.is_numeric_value() { + if matches!(op, UnaryOp::Not) && rhs_type.is_numeric_value() { let integer_type = Type::polymorphic_integer(self.interner); self.unify(rhs_type, &integer_type, || { TypeCheckError::InvalidUnaryOp { @@ -1593,14 +1593,13 @@ impl Elaborator<'_> { _ => Ok((rhs_type.clone(), true)), } } - crate::ast::UnaryOp::Reference { mutable } => { - let typ = Type::Reference(Box::new(rhs_type.follow_bindings()), *mutable); + UnaryOp::Reference { mutable } => { + let typ = Reference(Box::new(rhs_type.follow_bindings()), *mutable); Ok((typ, false)) } - crate::ast::UnaryOp::Dereference { implicitly_added: _ } => { + UnaryOp::Dereference { implicitly_added: _ } => { let element_type = self.interner.next_type_variable(); - let make_expected = - |mutable| Type::Reference(Box::new(element_type.clone()), mutable); + let make_expected = |mutable| Reference(Box::new(element_type.clone()), mutable); let immutable = make_expected(false); let mutable = make_expected(true); @@ -1686,7 +1685,7 @@ impl Elaborator<'_> { let dereference_lhs = |this: &mut Self, lhs_type, element| { let old_lhs = *access_lhs; *access_lhs = this.interner.push_expr(HirExpression::Prefix(HirPrefixExpression::new( - crate::ast::UnaryOp::Dereference { implicitly_added: true }, + UnaryOp::Dereference { implicitly_added: true }, old_lhs, ))); this.interner.push_expr_type(old_lhs, lhs_type); @@ -2228,7 +2227,7 @@ impl Elaborator<'_> { } } - fn function_info(&self, function_body_id: ExprId) -> (noirc_errors::Location, bool) { + fn function_info(&self, function_body_id: ExprId) -> (Location, bool) { let (expr_location, empty_function) = if let HirExpression::Block(block) = self.interner.expression(&function_body_id) { let last_stmt = block.statements().last(); diff --git a/compiler/noirc_frontend/src/hir/comptime/errors.rs b/compiler/noirc_frontend/src/hir/comptime/errors.rs index 9e5913f1872..a2a17d106d8 100644 --- a/compiler/noirc_frontend/src/hir/comptime/errors.rs +++ b/compiler/noirc_frontend/src/hir/comptime/errors.rs @@ -272,7 +272,7 @@ pub enum InterpreterError { } #[allow(unused)] -pub(super) type IResult = std::result::Result; +pub(super) type IResult = Result; impl From for CompilationError { fn from(error: InterpreterError) -> Self { diff --git a/compiler/noirc_frontend/src/hir/comptime/interpreter.rs b/compiler/noirc_frontend/src/hir/comptime/interpreter.rs index a8905d2b7e7..0059ae9e084 100644 --- a/compiler/noirc_frontend/src/hir/comptime/interpreter.rs +++ b/compiler/noirc_frontend/src/hir/comptime/interpreter.rs @@ -1569,7 +1569,7 @@ fn evaluate_integer(typ: Type, value: SignedField, location: Location) -> IResul Ok(Value::U128(value)) } (Signedness::Signed, IntegerBitSize::One) => { - return Err(InterpreterError::TypeUnsupported { typ, location }); + Err(InterpreterError::TypeUnsupported { typ, location }) } (Signedness::Signed, IntegerBitSize::Eight) => { let value = value @@ -1596,7 +1596,7 @@ fn evaluate_integer(typ: Type, value: SignedField, location: Location) -> IResul Ok(Value::I64(value)) } (Signedness::Signed, IntegerBitSize::HundredTwentyEight) => { - return Err(InterpreterError::TypeUnsupported { typ, location }); + Err(InterpreterError::TypeUnsupported { typ, location }) } } } else if let Type::TypeVariable(variable) = &typ { diff --git a/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs b/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs index 9cea1435b33..624def5b332 100644 --- a/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs +++ b/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs @@ -263,7 +263,7 @@ impl Interpreter<'_, '_> { fn failing_constraint( message: impl Into, location: Location, - call_stack: &im::Vector, + call_stack: &Vector, ) -> IResult { Err(InterpreterError::FailingConstraint { message: Some(message.into()), @@ -338,7 +338,7 @@ fn static_assert( interner: &NodeInterner, arguments: Vec<(Value, Location)>, location: Location, - call_stack: &im::Vector, + call_stack: &Vector, ) -> IResult { let (predicate, message) = check_two_arguments(arguments, location)?; let predicate = get_bool(predicate)?; @@ -359,7 +359,7 @@ fn str_as_bytes( let string = check_one_argument(arguments, location)?; let string = get_str(interner, string)?; - let bytes: im::Vector = string.bytes().map(Value::U8).collect(); + let bytes: Vector = string.bytes().map(Value::U8).collect(); let byte_array_type = byte_array_type(bytes.len()); Ok(Value::Array(bytes, byte_array_type)) } @@ -547,7 +547,7 @@ fn type_def_fields( interner: &mut NodeInterner, arguments: Vec<(Value, Location)>, location: Location, - call_stack: &im::Vector, + call_stack: &Vector, ) -> IResult { let (typ, generic_args) = check_two_arguments(arguments, location)?; let struct_id = get_type_id(typ)?; @@ -572,7 +572,7 @@ fn type_def_fields( return Err(InterpreterError::FailingConstraint { message, location, call_stack }); } - let mut fields = im::Vector::new(); + let mut fields = Vector::new(); if let Some(struct_fields) = struct_def.get_fields(&generic_args) { for (field_name, field_type, visibility) in struct_fields { @@ -606,7 +606,7 @@ fn type_def_fields_as_written( let struct_def = interner.get_type(struct_id); let struct_def = struct_def.borrow(); - let mut fields = im::Vector::new(); + let mut fields = Vector::new(); if let Some(struct_fields) = struct_def.get_fields_as_written() { for field in struct_fields { @@ -727,7 +727,7 @@ fn slice_remove( interner: &mut NodeInterner, arguments: Vec<(Value, Location)>, location: Location, - call_stack: &im::Vector, + call_stack: &Vector, ) -> IResult { let (slice, index) = check_two_arguments(arguments, location)?; @@ -766,7 +766,7 @@ fn slice_pop_front( interner: &mut NodeInterner, arguments: Vec<(Value, Location)>, location: Location, - call_stack: &im::Vector, + call_stack: &Vector, ) -> IResult { let argument = check_one_argument(arguments, location)?; @@ -783,7 +783,7 @@ fn slice_pop_back( interner: &mut NodeInterner, arguments: Vec<(Value, Location)>, location: Location, - call_stack: &im::Vector, + call_stack: &Vector, ) -> IResult { let argument = check_one_argument(arguments, location)?; @@ -1471,7 +1471,7 @@ fn zeroed(return_type: Type, location: Location) -> Value { Value::Zeroed(Type::Array(length_type, elem)) } } - Type::Slice(_) => Value::Slice(im::Vector::new(), return_type), + Type::Slice(_) => Value::Slice(Vector::new(), return_type), Type::Integer(sign, bits) => match (sign, bits) { (Signedness::Unsigned, IntegerBitSize::One) => Value::U8(0), (Signedness::Unsigned, IntegerBitSize::Eight) => Value::U8(0), @@ -2098,7 +2098,7 @@ fn expr_as_member_access( Shared::new(quote_ident(&member_access.rhs, location)), ])) } - ExprValue::LValue(crate::ast::LValue::MemberAccess { object, field_name, location: _ }) => { + ExprValue::LValue(LValue::MemberAccess { object, field_name, location: _ }) => { Some(Value::Tuple(vec![ Shared::new(Value::lvalue(*object)), Shared::new(quote_ident(&field_name, location)), diff --git a/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin/builtin_helpers.rs b/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin/builtin_helpers.rs index 369348e355b..0fdb3719f35 100644 --- a/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin/builtin_helpers.rs +++ b/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin/builtin_helpers.rs @@ -425,7 +425,7 @@ fn gather_hir_pattern_tokens( tokens.push(Token::Ident(name)); } HirPattern::Mutable(pattern, _) => { - tokens.push(Token::Keyword(crate::token::Keyword::Mut)); + tokens.push(Token::Keyword(Keyword::Mut)); gather_hir_pattern_tokens(interner, pattern, tokens); } HirPattern::Tuple(patterns, _) => { diff --git a/compiler/noirc_frontend/src/hir/comptime/interpreter/infix.rs b/compiler/noirc_frontend/src/hir/comptime/interpreter/infix.rs index 9e3280131a6..3977445f79e 100644 --- a/compiler/noirc_frontend/src/hir/comptime/interpreter/infix.rs +++ b/compiler/noirc_frontend/src/hir/comptime/interpreter/infix.rs @@ -182,9 +182,11 @@ pub(super) fn evaluate_infix( BinaryOpKind::Xor => match_bitwise! { (lhs_value as lhs "^" rhs_value as rhs) => lhs ^ rhs }, + #[allow(trivial_numeric_casts)] BinaryOpKind::ShiftRight => match_integer! { (lhs_value as lhs ">>" rhs_value as rhs) => lhs.checked_shr(rhs as u32) }, + #[allow(trivial_numeric_casts)] BinaryOpKind::ShiftLeft => match_integer! { (lhs_value as lhs "<<" rhs_value as rhs) => lhs.checked_shl(rhs as u32) }, diff --git a/compiler/noirc_frontend/src/hir/comptime/value.rs b/compiler/noirc_frontend/src/hir/comptime/value.rs index 283af9dbf90..46d8374492a 100644 --- a/compiler/noirc_frontend/src/hir/comptime/value.rs +++ b/compiler/noirc_frontend/src/hir/comptime/value.rs @@ -84,7 +84,7 @@ pub enum Value { UnresolvedType(UnresolvedTypeData), } -pub type StructFields = HashMap, Shared>; +pub(super) type StructFields = HashMap, Shared>; #[derive(Debug, Clone, PartialEq, Eq)] pub struct Closure { 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 5ed00a45e29..61f68718b8d 100644 --- a/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs +++ b/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs @@ -559,12 +559,7 @@ fn inject_prelude( if !crate_id.is_stdlib() { let segments: Vec<_> = "std::prelude" .split("::") - .map(|segment| { - crate::ast::PathSegment::from(crate::ast::Ident::new( - segment.into(), - Location::dummy(), - )) - }) + .map(|segment| PathSegment::from(Ident::new(segment.into(), Location::dummy()))) .collect(); let path = Path::plain(segments.clone(), Location::dummy()); diff --git a/compiler/noirc_frontend/src/hir/mod.rs b/compiler/noirc_frontend/src/hir/mod.rs index 36674ef2478..edb7200bee9 100644 --- a/compiler/noirc_frontend/src/hir/mod.rs +++ b/compiler/noirc_frontend/src/hir/mod.rs @@ -28,7 +28,7 @@ use std::rc::Rc; use self::def_map::TestFunction; -pub type ParsedFiles = HashMap)>; +pub type ParsedFiles = HashMap)>; /// Helper object which groups together several useful context objects used /// during name resolution. Once name resolution is finished, only the @@ -47,7 +47,7 @@ pub struct Context<'file_manager, 'parsed_files> { /// A map of each file that already has been visited from a prior `mod foo;` declaration. /// This is used to issue an error if a second `mod foo;` is declared to the same file. - pub visited_files: BTreeMap, + pub visited_files: BTreeMap, // A map of all parsed files. // Same as the file manager, we take ownership of the parsed files in the WASM context. diff --git a/compiler/noirc_frontend/src/hir_def/types/arithmetic.rs b/compiler/noirc_frontend/src/hir_def/types/arithmetic.rs index 128de82d05a..83f104b6206 100644 --- a/compiler/noirc_frontend/src/hir_def/types/arithmetic.rs +++ b/compiler/noirc_frontend/src/hir_def/types/arithmetic.rs @@ -451,7 +451,6 @@ mod proptests { use proptest::collection; use proptest::prelude::*; use proptest::result::maybe_ok; - use proptest::strategy; use crate::ast::IntegerBitSize; use crate::hir_def::types::{BinaryTypeOperator, Kind, Type, TypeVariable, TypeVariableId}; @@ -487,13 +486,13 @@ mod proptests { fn arbitrary_unsigned_type_with_generator() -> BoxedStrategy<(Type, BoxedStrategy)> { prop_oneof![ - strategy::Just((Type::FieldElement, arbitrary_field_element().boxed())), + Just((Type::FieldElement, arbitrary_field_element().boxed())), any::().prop_map(|bit_size| { let typ = Type::Integer(Signedness::Unsigned, bit_size); let maximum_size = typ.integral_maximum_size().unwrap().to_u128(); (typ, arbitrary_u128_field_element(maximum_size).boxed()) }), - strategy::Just((Type::Bool, arbitrary_u128_field_element(1).boxed())), + Just((Type::Bool, arbitrary_u128_field_element(1).boxed())), ] .boxed() } diff --git a/compiler/noirc_frontend/src/hir_def/types/unification.rs b/compiler/noirc_frontend/src/hir_def/types/unification.rs index 3cc3dbaf404..74200e66a50 100644 --- a/compiler/noirc_frontend/src/hir_def/types/unification.rs +++ b/compiler/noirc_frontend/src/hir_def/types/unification.rs @@ -110,12 +110,12 @@ impl Type { let rhs = other.follow_bindings_shallow(); let lhs = match lhs.as_ref() { - Type::InfixExpr(..) => Cow::Owned(self.substitute(bindings).canonicalize()), + InfixExpr(..) => Cow::Owned(self.substitute(bindings).canonicalize()), other => Cow::Borrowed(other), }; let rhs = match rhs.as_ref() { - Type::InfixExpr(..) => Cow::Owned(other.substitute(bindings).canonicalize()), + InfixExpr(..) => Cow::Owned(other.substitute(bindings).canonicalize()), other => Cow::Borrowed(other), }; @@ -131,7 +131,7 @@ impl Type { TypeBinding::Bound(typ) => { if typ.is_numeric_value() { other.try_unify_to_type_variable(var, flags, bindings, |bindings| { - let only_integer = matches!(typ, Type::Integer(..)); + let only_integer = matches!(typ, Integer(..)); other.try_bind_to_polymorphic_int(var, bindings, only_integer) }) } else { diff --git a/compiler/noirc_frontend/src/lexer/lexer.rs b/compiler/noirc_frontend/src/lexer/lexer.rs index 124a2d495a6..12425ba96b1 100644 --- a/compiler/noirc_frontend/src/lexer/lexer.rs +++ b/compiler/noirc_frontend/src/lexer/lexer.rs @@ -1476,7 +1476,7 @@ mod tests { // // let source = std::str::from_utf8(..).unwrap().to_string(); let s: Cow<'_, str> = match std::str::from_utf8(&base64_decoded) { - Ok(s) => std::borrow::Cow::Borrowed(s), + Ok(s) => Cow::Borrowed(s), Err(_err) => { // recover as much of the string as possible // when str::from_utf8 fails diff --git a/compiler/noirc_frontend/src/lexer/token.rs b/compiler/noirc_frontend/src/lexer/token.rs index 42afc300a31..f87467c7752 100644 --- a/compiler/noirc_frontend/src/lexer/token.rs +++ b/compiler/noirc_frontend/src/lexer/token.rs @@ -447,7 +447,7 @@ impl LocatedToken { } } -impl std::fmt::Display for LocatedToken { +impl Display for LocatedToken { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.token().fmt(f) } @@ -497,13 +497,13 @@ impl SpannedToken { } } -impl std::fmt::Display for SpannedToken { +impl Display for SpannedToken { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.token().fmt(f) } } -impl fmt::Display for Token { +impl Display for Token { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Token::Ident(ref s) => write!(f, "{s}"), @@ -600,7 +600,7 @@ impl fmt::Display for Token { } } -impl fmt::Display for IntegerTypeSuffix { +impl Display for IntegerTypeSuffix { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { IntegerTypeSuffix::I8 => write!(f, "i8"), @@ -640,7 +640,7 @@ pub enum TokenKind { InnerDocComment, } -impl fmt::Display for TokenKind { +impl Display for TokenKind { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { TokenKind::Token(tok) => write!(f, "{tok}"), @@ -741,7 +741,7 @@ pub enum IntType { Signed(u32), // i64 = Signed(64) } -impl fmt::Display for IntType { +impl Display for IntType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { IntType::Unsigned(num) => write!(f, "u{num}"), @@ -794,7 +794,7 @@ pub enum TestScope { None, } -impl fmt::Display for TestScope { +impl Display for TestScope { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { TestScope::None => write!(f, ""), @@ -826,7 +826,7 @@ pub enum FuzzingScope { None, } -impl fmt::Display for FuzzingScope { +impl Display for FuzzingScope { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { FuzzingScope::None => write!(f, ""), @@ -966,7 +966,7 @@ pub enum Attribute { Secondary(SecondaryAttribute), } -impl fmt::Display for Attribute { +impl Display for Attribute { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { Attribute::Function(attribute) => write!(f, "{attribute}"), @@ -1059,13 +1059,13 @@ impl FunctionAttributeKind { } } -impl fmt::Display for FunctionAttribute { +impl Display for FunctionAttribute { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.kind.fmt(f) } } -impl fmt::Display for FunctionAttributeKind { +impl Display for FunctionAttributeKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { FunctionAttributeKind::Test(scope) => write!(f, "#[test{scope}]"), @@ -1150,13 +1150,13 @@ impl SecondaryAttributeKind { } } -impl fmt::Display for SecondaryAttribute { +impl Display for SecondaryAttribute { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.kind.fmt(f) } } -impl fmt::Display for SecondaryAttributeKind { +impl Display for SecondaryAttributeKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "#[{}]", self.contents()) } @@ -1240,7 +1240,7 @@ pub enum Keyword { While, } -impl fmt::Display for Keyword { +impl Display for Keyword { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Keyword::As => write!(f, "as"), diff --git a/compiler/noirc_frontend/src/monomorphization/ast.rs b/compiler/noirc_frontend/src/monomorphization/ast.rs index 20ffc16b9f9..7aaafadd557 100644 --- a/compiler/noirc_frontend/src/monomorphization/ast.rs +++ b/compiler/noirc_frontend/src/monomorphization/ast.rs @@ -464,7 +464,7 @@ impl InlineType { } } -impl std::fmt::Display for InlineType { +impl Display for InlineType { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { InlineType::Inline => write!(f, "inline"), @@ -614,13 +614,13 @@ impl std::ops::IndexMut for Program { } } -impl std::fmt::Display for Program { +impl Display for Program { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { super::printer::AstPrinter::default().print_program(self, f) } } -impl std::fmt::Display for Function { +impl Display for Function { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { super::printer::AstPrinter::default().print_function( self, @@ -630,13 +630,13 @@ impl std::fmt::Display for Function { } } -impl std::fmt::Display for Expression { +impl Display for Expression { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { super::printer::AstPrinter::default().print_expr(self, f) } } -impl std::fmt::Display for Type { +impl Display for Type { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Type::Field => write!(f, "Field"), diff --git a/compiler/noirc_frontend/src/monomorphization/mod.rs b/compiler/noirc_frontend/src/monomorphization/mod.rs index ef186f82de3..8d531ecf257 100644 --- a/compiler/noirc_frontend/src/monomorphization/mod.rs +++ b/compiler/noirc_frontend/src/monomorphization/mod.rs @@ -23,7 +23,6 @@ use crate::{ expr::*, function::{FunctionSignature, Parameters}, stmt::{HirAssignStatement, HirLValue, HirLetStatement, HirPattern, HirStatement}, - types, }, node_interner::{self, DefinitionKind, NodeInterner, StmtId, TraitImplKind}, }; @@ -125,7 +124,7 @@ type Functions = HashMap< HashMap, FuncId>>, >; -type HirType = crate::Type; +type HirType = Type; /// Starting from the given `main` function, monomorphize the entire program, /// replacing all references to type variables and NamedGenerics with concrete @@ -241,10 +240,10 @@ impl<'interner> Monomorphizer<'interner> { LocalId(id) } - fn next_function_id(&mut self) -> ast::FuncId { + fn next_function_id(&mut self) -> FuncId { let id = self.next_function_id; self.next_function_id += 1; - ast::FuncId(id) + FuncId(id) } fn next_global_id(&mut self) -> GlobalId { @@ -266,7 +265,7 @@ impl<'interner> Monomorphizer<'interner> { fn lookup_function( &mut self, id: node_interner::FuncId, - expr_id: node_interner::ExprId, + expr_id: ExprId, typ: &HirType, turbofish_generics: &[HirType], trait_method: Option, @@ -408,7 +407,7 @@ impl<'interner> Monomorphizer<'interner> { let parameters = self.parameters(&meta.parameters)?; let body = self.expr(body_expr_id)?; - let function = ast::Function { + let function = Function { id, name, parameters, @@ -424,7 +423,7 @@ impl<'interner> Monomorphizer<'interner> { Ok(()) } - fn push_function(&mut self, id: FuncId, function: ast::Function) { + fn push_function(&mut self, id: FuncId, function: Function) { let existing = self.finished_functions.insert(id, function); assert!(existing.is_none()); } @@ -435,8 +434,7 @@ impl<'interner> Monomorphizer<'interner> { fn parameters( &mut self, params: &Parameters, - ) -> Result, MonomorphizationError> - { + ) -> Result, MonomorphizationError> { let mut new_params = Vec::with_capacity(params.len()); for (parameter, typ, visibility) in ¶ms.0 { self.parameter(parameter, typ, visibility, &mut new_params)?; @@ -449,7 +447,7 @@ impl<'interner> Monomorphizer<'interner> { param: &HirPattern, typ: &HirType, visibility: &Visibility, - new_params: &mut Vec<(ast::LocalId, bool, String, ast::Type, Visibility)>, + new_params: &mut Vec<(LocalId, bool, String, ast::Type, Visibility)>, ) -> Result<(), MonomorphizationError> { match param { HirPattern::Identifier(ident) => { @@ -490,10 +488,7 @@ impl<'interner> Monomorphizer<'interner> { Ok(()) } - pub(crate) fn expr( - &mut self, - expr: node_interner::ExprId, - ) -> Result { + pub(crate) fn expr(&mut self, expr: ExprId) -> Result { use ast::Expression::Literal; use ast::Literal::*; @@ -664,7 +659,7 @@ impl<'interner> Monomorphizer<'interner> { Ok(expr) } - fn contains_reference(typ: &types::Type) -> bool { + fn contains_reference(typ: &Type) -> bool { match typ { Type::FieldElement | Type::Bool @@ -719,8 +714,8 @@ impl<'interner> Monomorphizer<'interner> { fn standard_array( &mut self, - array: node_interner::ExprId, - array_elements: Vec, + array: ExprId, + array_elements: Vec, is_slice: bool, ) -> Result { let location = self.interner.expr_location(&array); @@ -735,8 +730,8 @@ impl<'interner> Monomorphizer<'interner> { fn repeated_array( &mut self, - array: node_interner::ExprId, - repeated_element: node_interner::ExprId, + array: ExprId, + repeated_element: ExprId, length: HirType, is_slice: bool, ) -> Result { @@ -758,7 +753,7 @@ impl<'interner> Monomorphizer<'interner> { fn index( &mut self, - id: node_interner::ExprId, + id: ExprId, index: HirIndexExpression, ) -> Result { let location = self.interner.expr_location(&id); @@ -832,7 +827,7 @@ impl<'interner> Monomorphizer<'interner> { fn constructor( &mut self, constructor: HirConstructorExpression, - id: node_interner::ExprId, + id: ExprId, ) -> Result { let location = self.interner.expr_location(&id); @@ -902,7 +897,7 @@ impl<'interner> Monomorphizer<'interner> { fn enum_constructor( &mut self, constructor: HirEnumConstructorExpression, - id: node_interner::ExprId, + id: ExprId, ) -> Result { let location = self.interner.expr_location(&id); let typ = self.interner.id_type(id); @@ -1060,7 +1055,7 @@ impl<'interner> Monomorphizer<'interner> { fn ident( &mut self, ident: HirIdent, - expr_id: node_interner::ExprId, + expr_id: ExprId, generics: Option>, // If set and this is a function value, only monomorphize the function for the // constrainedness given by `self.in_unconstrained_function` rather than returning a tuple @@ -1621,13 +1616,13 @@ impl<'interner> Monomorphizer<'interner> { }); } let to_value = to.evaluate_to_signed_field(&to.kind(), location); - if to_value.is_ok() { + if let Ok(to_value) = to_value { let skip_simplifications = false; let from_value = from.evaluate_to_signed_field_helper(&to.kind(), location, skip_simplifications); - if from_value.is_err() || from_value.unwrap() != to_value.clone().unwrap() { + if from_value.is_err() || from_value.unwrap() != to_value { return Err(MonomorphizationError::CheckedCastFailed { - actual: HirType::Constant(to_value.unwrap(), to.kind()), + actual: HirType::Constant(to_value, to.kind()), expected: from.clone(), location, }); @@ -1665,7 +1660,7 @@ impl<'interner> Monomorphizer<'interner> { fn resolve_trait_item_expr( &mut self, - expr_id: node_interner::ExprId, + expr_id: ExprId, function_type: HirType, trait_item_id: TraitItemId, use_current_runtime: bool, @@ -1691,7 +1686,7 @@ impl<'interner> Monomorphizer<'interner> { fn resolve_trait_method_expr( &mut self, func_id: node_interner::FuncId, - expr_id: node_interner::ExprId, + expr_id: ExprId, function_type: HirType, trait_item_id: TraitItemId, ) -> Result { @@ -1759,7 +1754,7 @@ impl<'interner> Monomorphizer<'interner> { fn function_call( &mut self, call: HirCallExpression, - id: node_interner::ExprId, + id: ExprId, ) -> Result { let original_func = Box::new(self.extract_function(call.func)?); @@ -1876,8 +1871,8 @@ impl<'interner> Monomorphizer<'interner> { fn try_evaluate_call( &mut self, func: &ast::Expression, - expr_id: &node_interner::ExprId, - arguments: &[node_interner::ExprId], + expr_id: &ExprId, + arguments: &[ExprId], argument_values: &[ast::Expression], result_type: &ast::Type, ) -> Result, MonomorphizationError> { @@ -1925,8 +1920,8 @@ impl<'interner> Monomorphizer<'interner> { fn checked_transmute( &mut self, - expr_id: node_interner::ExprId, - arguments: &[node_interner::ExprId], + expr_id: ExprId, + arguments: &[ExprId], argument_values: &[ast::Expression], ) -> Result { let location = self.interner.expr_location(&expr_id); @@ -1967,7 +1962,7 @@ impl<'interner> Monomorphizer<'interner> { fn queue_function( &mut self, id: node_interner::FuncId, - expr_id: node_interner::ExprId, + expr_id: ExprId, function_type: HirType, turbofish_generics: Vec, trait_method: Option, @@ -2053,7 +2048,7 @@ impl<'interner> Monomorphizer<'interner> { fn lambda( &mut self, lambda: HirLambda, - expr: node_interner::ExprId, + expr: ExprId, ) -> Result { // Function values are represented as a tuple of (constrained version, unconstrained version) self.monomorphize_constrained_and_unconstrained(false, |this: &mut Self| { @@ -2069,7 +2064,7 @@ impl<'interner> Monomorphizer<'interner> { fn lambda_no_capture( &mut self, lambda: HirLambda, - expr: node_interner::ExprId, + expr: ExprId, ) -> Result { let location = self.interner.expr_location(&expr); let ret_type = Self::convert_type(&lambda.return_type, location)?; @@ -2085,7 +2080,7 @@ impl<'interner> Monomorphizer<'interner> { let body = self.expr(lambda.body)?; let id = self.next_function_id(); - let function = ast::Function { + let function = Function { id, name: lambda_name.to_owned(), parameters, @@ -2119,7 +2114,7 @@ impl<'interner> Monomorphizer<'interner> { fn lambda_with_setup( &mut self, lambda: HirLambda, - expr: node_interner::ExprId, + expr: ExprId, ) -> Result<(ast::Expression, ast::Expression), MonomorphizationError> { // returns (, ) // which can be used directly in callsites or transformed @@ -2173,7 +2168,7 @@ impl<'interner> Monomorphizer<'interner> { })?); let expr_type = self.interner.id_type(expr); - let env_typ = if let types::Type::Function(_, _, function_env_type, _) = expr_type { + let env_typ = if let Type::Function(_, _, function_env_type, _) = expr_type { Self::convert_type(&function_env_type, location)? } else { unreachable!("expected a Function type for a Lambda node") @@ -2223,7 +2218,7 @@ impl<'interner> Monomorphizer<'interner> { vec![(env_local_id, true, env_name.to_string(), env_typ.clone(), Visibility::Private)]; parameters.append(&mut converted_parameters); - let function = ast::Function { + let function = Function { id, name, parameters, @@ -2333,11 +2328,7 @@ impl<'interner> Monomorphizer<'interner> { /// Implements std::unsafe_func::zeroed by returning an appropriate zeroed /// ast literal or collection node for the given type. Note that for functions /// there is no obvious zeroed value so this should be considered unsafe to use. - fn zeroed_value_of_type( - &mut self, - typ: &ast::Type, - location: noirc_errors::Location, - ) -> ast::Expression { + fn zeroed_value_of_type(&mut self, typ: &ast::Type, location: Location) -> ast::Expression { match typ { ast::Type::Field | ast::Type::Integer(..) => { let typ = typ.clone(); @@ -2408,7 +2399,7 @@ impl<'interner> Monomorphizer<'interner> { ret_type: &ast::Type, env_type: &ast::Type, unconstrained: bool, - location: noirc_errors::Location, + location: Location, ) -> ast::Expression { let lambda_name = "zeroed_lambda"; @@ -2422,7 +2413,7 @@ impl<'interner> Monomorphizer<'interner> { let return_type = ret_type.clone(); let name = lambda_name.to_owned(); - let function = ast::Function { + let function = Function { id, name, parameters, diff --git a/compiler/noirc_frontend/src/monomorphization/printer.rs b/compiler/noirc_frontend/src/monomorphization/printer.rs index b498b2bffe9..992b8381020 100644 --- a/compiler/noirc_frontend/src/monomorphization/printer.rs +++ b/compiler/noirc_frontend/src/monomorphization/printer.rs @@ -248,43 +248,43 @@ impl AstPrinter { pub fn print_literal( &mut self, - literal: &super::ast::Literal, + literal: &Literal, f: &mut Formatter, ) -> Result<(), std::fmt::Error> { match literal { - super::ast::Literal::Array(array) => { + Literal::Array(array) => { write!(f, "[")?; self.print_comma_separated(&array.contents, f)?; write!(f, "]") } - super::ast::Literal::Slice(array) => { + Literal::Slice(array) => { write!(f, "&[")?; self.print_comma_separated(&array.contents, f)?; write!(f, "]") } - super::ast::Literal::Integer(x, typ, _) => { + Literal::Integer(x, typ, _) => { if self.show_type_of_int_literal && *typ != Type::Field { write!(f, "{x}_{typ}") } else { x.fmt(f) } } - super::ast::Literal::Bool(x) => x.fmt(f), - super::ast::Literal::Str(s) => { + Literal::Bool(x) => x.fmt(f), + Literal::Str(s) => { if s.contains("\"") { write!(f, "r#\"{s}\"#") } else { write!(f, "\"{s}\"") } } - super::ast::Literal::FmtStr(fragments, _, _) => { + Literal::FmtStr(fragments, _, _) => { write!(f, "f\"")?; for fragment in fragments { fragment.fmt(f)?; } write!(f, "\"") } - super::ast::Literal::Unit => { + Literal::Unit => { write!(f, "()") } } @@ -647,7 +647,7 @@ impl AstPrinter { LValue::Clone(lvalue) => { self.print_lvalue(lvalue, f)?; if self.show_clone_and_drop { - write!(f, ".clone()")? + write!(f, ".clone()")?; } Ok(()) } diff --git a/compiler/noirc_frontend/src/node_interner.rs b/compiler/noirc_frontend/src/node_interner.rs index c3bac23881b..83418f00710 100644 --- a/compiler/noirc_frontend/src/node_interner.rs +++ b/compiler/noirc_frontend/src/node_interner.rs @@ -218,19 +218,19 @@ pub struct NodeInterner { /// into `quoted` expressions, we preserve the original type by assigning it a unique id /// and creating a `Token::QuotedType(id)` from this id. We cannot create a token holding /// the actual type since types do not implement Send or Sync. - quoted_types: noirc_arena::Arena, + quoted_types: Arena, // Interned `ExpressionKind`s during comptime code. - interned_expression_kinds: noirc_arena::Arena, + interned_expression_kinds: Arena, // Interned `StatementKind`s during comptime code. - interned_statement_kinds: noirc_arena::Arena, + interned_statement_kinds: Arena, // Interned `UnresolvedTypeData`s during comptime code. - interned_unresolved_type_data: noirc_arena::Arena, + interned_unresolved_type_data: Arena, // Interned `Pattern`s during comptime code. - interned_patterns: noirc_arena::Arena, + interned_patterns: Arena, /// Determines whether to run in LSP mode. In LSP mode references are tracked. pub(crate) lsp_mode: bool, @@ -641,19 +641,19 @@ pub enum GlobalValue { } #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct QuotedTypeId(noirc_arena::Index); +pub struct QuotedTypeId(Index); #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct InternedExpressionKind(noirc_arena::Index); +pub struct InternedExpressionKind(Index); #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct InternedStatementKind(noirc_arena::Index); +pub struct InternedStatementKind(Index); #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct InternedUnresolvedTypeData(noirc_arena::Index); +pub struct InternedUnresolvedTypeData(Index); #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct InternedPattern(noirc_arena::Index); +pub struct InternedPattern(Index); /// Captures a reexport that happens inside a module. For example: /// @@ -683,7 +683,7 @@ impl Default for NodeInterner { function_modules: HashMap::default(), module_attributes: HashMap::default(), func_id_to_trait: HashMap::default(), - dependency_graph: petgraph::graph::DiGraph::new(), + dependency_graph: DiGraph::new(), dependency_graph_indices: HashMap::default(), id_to_location: HashMap::default(), definitions: vec![], @@ -716,7 +716,7 @@ impl Default for NodeInterner { interned_patterns: Default::default(), lsp_mode: false, location_indices: LocationIndices::default(), - reference_graph: petgraph::graph::DiGraph::new(), + reference_graph: DiGraph::new(), reference_graph_indices: HashMap::default(), auto_import_names: HashMap::default(), comptime_scopes: vec![HashMap::default()], @@ -1150,10 +1150,10 @@ impl NodeInterner { self.func_meta.get(func_id) } - pub fn function_ident(&self, func_id: &FuncId) -> crate::ast::Ident { + pub fn function_ident(&self, func_id: &FuncId) -> Ident { let name = self.function_name(func_id).to_owned(); let location = self.function_meta(func_id).name.location; - crate::ast::Ident::new(name, location) + Ident::new(name, location) } pub fn function_name(&self, func_id: &FuncId) -> &str { diff --git a/compiler/noirc_frontend/src/ownership/mod.rs b/compiler/noirc_frontend/src/ownership/mod.rs index e1083b132bc..332a63ac224 100644 --- a/compiler/noirc_frontend/src/ownership/mod.rs +++ b/compiler/noirc_frontend/src/ownership/mod.rs @@ -267,7 +267,7 @@ impl Context { } fn handle_index(&mut self, index_expr: &mut Expression) { - let crate::monomorphization::ast::Expression::Index(index) = index_expr else { + let Expression::Index(index) = index_expr else { panic!("handle_index should only be called with Index nodes"); }; diff --git a/compiler/noirc_frontend/src/signed_field.rs b/compiler/noirc_frontend/src/signed_field.rs index 3bae695a8df..be0f955f589 100644 --- a/compiler/noirc_frontend/src/signed_field.rs +++ b/compiler/noirc_frontend/src/signed_field.rs @@ -68,7 +68,7 @@ impl SignedField { return None; } - assert!(std::mem::size_of::() <= std::mem::size_of::()); + assert!(size_of::() <= size_of::()); let u128_value = self.field.try_into_u128()?; u128_value.try_into().ok() } @@ -283,7 +283,7 @@ macro_rules! impl_unsigned_abs_for { ($typ:ty) => { impl AbsU128 for $typ { fn abs_u128(self) -> u128 { - self.unsigned_abs() as u128 + self.unsigned_abs().into() } } }; diff --git a/compiler/noirc_frontend/src/test_utils.rs b/compiler/noirc_frontend/src/test_utils.rs index edfbdd2a435..92fd1d85947 100644 --- a/compiler/noirc_frontend/src/test_utils.rs +++ b/compiler/noirc_frontend/src/test_utils.rs @@ -97,7 +97,7 @@ pub(crate) fn get_program_with_options( allow_parser_errors: bool, options: FrontendOptions, ) -> (ParsedModule, Context<'static, 'static>, Vec) { - let root = std::path::Path::new("/"); + let root = Path::new("/"); let mut fm = FileManager::new(root); let root_file_id = fm.add_file_with_source(Path::new("test_file"), src.to_string()).unwrap(); let mut context = Context::new(fm, Default::default()); diff --git a/tooling/greybox_fuzzer/src/mutation/mod.rs b/tooling/greybox_fuzzer/src/mutation/mod.rs index 52efead7295..14463d49448 100644 --- a/tooling/greybox_fuzzer/src/mutation/mod.rs +++ b/tooling/greybox_fuzzer/src/mutation/mod.rs @@ -670,9 +670,11 @@ impl InputMutator { ) -> InputMap { let mut starting_input_value = previous_input_map.clone(); - if additional_input_map.is_some() && prng.gen_range(0..4).is_zero() { - starting_input_value = - self.splice_two_maps(&previous_input_map, &additional_input_map.unwrap(), prng); + if let Some(additional_input_map) = additional_input_map { + if prng.gen_range(0..4).is_zero() { + starting_input_value = + self.splice_two_maps(&previous_input_map, &additional_input_map, prng); + } } for _ in 0..(1 << prng.gen_range(MUTATION_LOG_MIN..=MUTATION_LOG_MAX)) { starting_input_value = self.mutate_input_map_single(&starting_input_value, prng); diff --git a/tooling/nargo_cli/src/cli/fuzz_cmd.rs b/tooling/nargo_cli/src/cli/fuzz_cmd.rs index 816a4918cd3..799d217c0c9 100644 --- a/tooling/nargo_cli/src/cli/fuzz_cmd.rs +++ b/tooling/nargo_cli/src/cli/fuzz_cmd.rs @@ -479,7 +479,7 @@ fn display_fuzzing_report_and_store( if let Some(diag) = error_diagnostic { noirc_errors::reporter::report_all( file_manager.as_file_map(), - &[diag.clone()], + std::slice::from_ref(diag), compile_options.deny_warnings, compile_options.silence_warnings, ); @@ -488,7 +488,7 @@ fn display_fuzzing_report_and_store( FuzzingRunStatus::CompileError(err) => { noirc_errors::reporter::report_all( file_manager.as_file_map(), - &[err.clone()], + std::slice::from_ref(err), compile_options.deny_warnings, compile_options.silence_warnings, ); diff --git a/tooling/nargo_cli/src/cli/test_cmd/formatters.rs b/tooling/nargo_cli/src/cli/test_cmd/formatters.rs index 0edf61202e6..0e09f41b780 100644 --- a/tooling/nargo_cli/src/cli/test_cmd/formatters.rs +++ b/tooling/nargo_cli/src/cli/test_cmd/formatters.rs @@ -132,7 +132,7 @@ impl Formatter for PrettyFormatter { if let Some(diag) = error_diagnostic { noirc_errors::reporter::report_all( file_manager.as_file_map(), - &[diag.clone()], + std::slice::from_ref(diag), deny_warnings, silence_warnings, ); @@ -148,7 +148,7 @@ impl Formatter for PrettyFormatter { TestStatus::CompileError(file_diagnostic) => { noirc_errors::reporter::report_all( file_manager.as_file_map(), - &[file_diagnostic.clone()], + std::slice::from_ref(file_diagnostic), deny_warnings, silence_warnings, ); @@ -322,7 +322,7 @@ impl Formatter for TerseFormatter { if let Some(diag) = error_diagnostic { noirc_errors::reporter::report_all( file_manager.as_file_map(), - &[diag.clone()], + std::slice::from_ref(diag), deny_warnings, silence_warnings, ); @@ -331,7 +331,7 @@ impl Formatter for TerseFormatter { TestStatus::CompileError(file_diagnostic) => { noirc_errors::reporter::report_all( file_manager.as_file_map(), - &[file_diagnostic.clone()], + std::slice::from_ref(file_diagnostic), deny_warnings, silence_warnings, ); diff --git a/tooling/nargo_cli/tests/stdlib-tests.rs b/tooling/nargo_cli/tests/stdlib-tests.rs index 8c25e0b25fc..eabecc7b273 100644 --- a/tooling/nargo_cli/tests/stdlib-tests.rs +++ b/tooling/nargo_cli/tests/stdlib-tests.rs @@ -152,7 +152,7 @@ fn display_test_report( if let Some(diag) = error_diagnostic { noirc_errors::reporter::report_all( file_manager.as_file_map(), - &[diag.clone()], + std::slice::from_ref(diag), compile_options.deny_warnings, compile_options.silence_warnings, ); @@ -167,7 +167,7 @@ fn display_test_report( TestStatus::CompileError(err) => { noirc_errors::reporter::report_all( file_manager.as_file_map(), - &[err.clone()], + std::slice::from_ref(err), compile_options.deny_warnings, compile_options.silence_warnings, ); diff --git a/tooling/nargo_toml/src/lib.rs b/tooling/nargo_toml/src/lib.rs index cbfe4d76ef4..24d25cd81e7 100644 --- a/tooling/nargo_toml/src/lib.rs +++ b/tooling/nargo_toml/src/lib.rs @@ -690,11 +690,12 @@ mod tests { ); // Go into the last created directory - if indent > current_indent && last_item.is_some() { - let last_item = last_item.unwrap(); - assert!(is_dir(&last_item), "last item was not a dir: {last_item}"); - current_dir.push(last_item); - current_indent += 1; + if let Some(last_item) = last_item { + if indent > current_indent { + assert!(is_dir(&last_item), "last item was not a dir: {last_item}"); + current_dir.push(last_item); + current_indent += 1; + } } // Go back into an ancestor directory while indent < current_indent { diff --git a/tooling/ssa_fuzzer/fuzzer/Cargo.toml b/tooling/ssa_fuzzer/fuzzer/Cargo.toml index 4557f81d4e9..0229f75ebfb 100644 --- a/tooling/ssa_fuzzer/fuzzer/Cargo.toml +++ b/tooling/ssa_fuzzer/fuzzer/Cargo.toml @@ -25,7 +25,7 @@ serde.workspace = true serde_json.workspace = true base64.workspace = true sha1 = "0.10.6" -redis = "0.23" +redis = "0.26" lazy_static = "1.4" strum_macros = "0.24" strum = "0.24"