From bd95e9d976e66ba0df83886d5bedf4f52e1b41aa Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Thu, 28 Aug 2025 23:20:54 +0000 Subject: [PATCH 1/7] chore: fix warnings --- acvm-repo/acvm_js/src/foreign_call/outputs.rs | 2 +- compiler/fm/src/file_map.rs | 2 +- compiler/noirc_driver/src/lib.rs | 2 +- .../noirc_evaluator/src/acir/acir_context/mod.rs | 2 +- compiler/noirc_evaluator/src/brillig/mod.rs | 4 ++-- .../noirc_evaluator/src/ssa/function_builder/mod.rs | 8 ++++---- compiler/noirc_evaluator/src/ssa/ir/dfg.rs | 12 ++++++------ .../noirc_evaluator/src/ssa/ir/function_inserter.rs | 4 ++-- compiler/noirc_evaluator/src/ssa/ir/printer.rs | 2 +- compiler/noirc_evaluator/src/ssa/ir/value.rs | 2 +- compiler/noirc_evaluator/src/ssa/mod.rs | 2 +- .../noirc_evaluator/src/ssa/opt/constant_folding.rs | 8 ++++---- compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs | 4 ++-- .../noirc_evaluator/src/ssa/opt/mem2reg/block.rs | 2 +- .../noirc_evaluator/src/ssa/opt/remove_bit_shifts.rs | 4 ++-- .../src/ssa/opt/simple_optimization.rs | 4 ++-- compiler/noirc_frontend/src/ast/expression.rs | 2 +- .../noirc_frontend/src/hir/comptime/interpreter.rs | 4 ++-- compiler/noirc_frontend/src/hir/comptime/value.rs | 2 +- compiler/noirc_frontend/src/hir_def/types.rs | 10 +++++----- compiler/noirc_frontend/src/monomorphization/ast.rs | 4 ++-- compiler/noirc_frontend/src/monomorphization/mod.rs | 6 +++--- tooling/ast_fuzzer/src/program/scope.rs | 2 +- tooling/debugger/src/context.rs | 4 ++-- tooling/debugger/src/foreign_calls.rs | 12 ++++++------ tooling/greybox_fuzzer/src/corpus.rs | 4 ++-- tooling/greybox_fuzzer/src/mutation/mod.rs | 8 +++++--- tooling/nargo_cli/src/cli/fuzz_cmd.rs | 4 ++-- tooling/nargo_cli/src/cli/test_cmd/formatters.rs | 8 ++++---- tooling/nargo_cli/tests/stdlib-tests.rs | 4 ++-- tooling/nargo_toml/src/lib.rs | 11 ++++++----- tooling/noirc_artifacts/src/debug_vars.rs | 4 ++-- 32 files changed, 78 insertions(+), 75 deletions(-) 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 Option { + pub fn get_file(&'_ self, file_id: FileId) -> Option> { self.files.get(file_id.0).map(File).ok() } diff --git a/compiler/noirc_driver/src/lib.rs b/compiler/noirc_driver/src/lib.rs index d90d73dfe63..c629f3369c8 100644 --- a/compiler/noirc_driver/src/lib.rs +++ b/compiler/noirc_driver/src/lib.rs @@ -270,7 +270,7 @@ pub fn parse_expression_width(input: &str) -> Result FrontendOptions { + pub(crate) fn frontend_options(&'_ self) -> FrontendOptions<'_> { FrontendOptions { debug_comptime_in_file: self.debug_comptime_in_file.as_deref(), pedantic_solving: self.pedantic_solving, diff --git a/compiler/noirc_evaluator/src/acir/acir_context/mod.rs b/compiler/noirc_evaluator/src/acir/acir_context/mod.rs index a4eaf6bfd91..cdf3c421e0d 100644 --- a/compiler/noirc_evaluator/src/acir/acir_context/mod.rs +++ b/compiler/noirc_evaluator/src/acir/acir_context/mod.rs @@ -1703,7 +1703,7 @@ impl AcirVarData { impl AcirVarData { /// Converts all enum variants to an Expression. - pub(crate) fn to_expression(&self) -> Cow> { + pub(crate) fn to_expression(&'_ self) -> Cow<'_, Expression> { match self { AcirVarData::Witness(witness) => Cow::Owned(Expression::from(*witness)), AcirVarData::Expr(expr) => Cow::Borrowed(expr), diff --git a/compiler/noirc_evaluator/src/brillig/mod.rs b/compiler/noirc_evaluator/src/brillig/mod.rs index b99217b6d50..0456286e082 100644 --- a/compiler/noirc_evaluator/src/brillig/mod.rs +++ b/compiler/noirc_evaluator/src/brillig/mod.rs @@ -76,10 +76,10 @@ impl Brillig { /// Finds a brillig artifact by its label pub(crate) fn find_by_label( - &self, + &'_ self, function_label: Label, options: &BrilligOptions, - ) -> Option>> { + ) -> Option>> { match function_label.label_type { LabelType::Function(function_id, _) => { self.ssa_function_to_brillig.get(&function_id).map(Cow::Borrowed) diff --git a/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs b/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs index 4ddd5106817..43dde8a5ad0 100644 --- a/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs +++ b/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs @@ -212,10 +212,10 @@ impl FunctionBuilder { /// Inserts a new instruction at the end of the current block and returns its results pub fn insert_instruction( - &mut self, + &'_ mut self, instruction: Instruction, ctrl_typevars: Option>, - ) -> InsertInstructionResult { + ) -> InsertInstructionResult<'_> { let block = self.current_block(); if self.simplify { @@ -341,11 +341,11 @@ impl FunctionBuilder { /// Insert a call instruction at the end of the current block and return /// the results of the call. pub fn insert_call( - &mut self, + &'_ mut self, func: ValueId, arguments: Vec, result_types: Vec, - ) -> Cow<[ValueId]> { + ) -> Cow<'_, [ValueId]> { self.insert_instruction(Instruction::Call { func, arguments }, Some(result_types)).results() } diff --git a/compiler/noirc_evaluator/src/ssa/ir/dfg.rs b/compiler/noirc_evaluator/src/ssa/ir/dfg.rs index 6ba1629b5f6..5bce541fa06 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/dfg.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/dfg.rs @@ -245,12 +245,12 @@ impl DataFlowGraph { } pub(crate) fn insert_instruction_and_results_without_simplification( - &mut self, + &'_ mut self, instruction: Instruction, block: BasicBlockId, ctrl_typevars: Option>, call_stack: CallStackId, - ) -> InsertInstructionResult { + ) -> InsertInstructionResult<'_> { if !self.is_handled_by_runtime(&instruction) { // Panicking to raise attention. If we're not supposed to simplify it immediately, // pushing the instruction would just cause a potential panic later on. @@ -269,12 +269,12 @@ impl DataFlowGraph { /// Simplifies a new instruction and inserts it at the end of the given block and returns its results. /// If the instruction is not handled by the current runtime, `InstructionRemoved` is returned. pub(crate) fn insert_instruction_and_results( - &mut self, + &'_ mut self, instruction: Instruction, block: BasicBlockId, ctrl_typevars: Option>, call_stack: CallStackId, - ) -> InsertInstructionResult { + ) -> InsertInstructionResult<'_> { self.insert_instruction_and_results_if_simplified( instruction, block, @@ -286,13 +286,13 @@ impl DataFlowGraph { /// Simplifies a potentially existing instruction and inserts it only if it changed. pub(crate) fn insert_instruction_and_results_if_simplified( - &mut self, + &'_ mut self, instruction: Instruction, block: BasicBlockId, ctrl_typevars: Option>, call_stack: CallStackId, existing_id: Option, - ) -> InsertInstructionResult { + ) -> InsertInstructionResult<'_> { if !self.is_handled_by_runtime(&instruction) { // BUG: With panicking it fails to build the `token_contract`; see: // https://github.com/AztecProtocol/aztec-packages/pull/11294#issuecomment-2624379102 diff --git a/compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs b/compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs index c96db249283..dff85dd9dbf 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs @@ -100,12 +100,12 @@ impl<'f> FunctionInserter<'f> { } pub(crate) fn push_instruction_value( - &mut self, + &'_ mut self, instruction: Instruction, id: InstructionId, block: BasicBlockId, call_stack: CallStackId, - ) -> InsertInstructionResult { + ) -> InsertInstructionResult<'_> { let results = self.function.dfg.instruction_results(id).to_vec(); let ctrl_typevars = instruction diff --git a/compiler/noirc_evaluator/src/ssa/ir/printer.rs b/compiler/noirc_evaluator/src/ssa/ir/printer.rs index 706cc1c3aa2..588607d0ce1 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/printer.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/printer.rs @@ -28,7 +28,7 @@ pub struct Printer<'local> { } impl Ssa { - pub fn print_without_locations(&self) -> Printer { + pub fn print_without_locations(&'_ self) -> Printer<'_> { Printer { ssa: self, fm: None } } diff --git a/compiler/noirc_evaluator/src/ssa/ir/value.rs b/compiler/noirc_evaluator/src/ssa/ir/value.rs index bc8fc3c4168..e148170337c 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/value.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/value.rs @@ -61,7 +61,7 @@ pub enum Value { impl Value { /// Retrieves the type of this Value - pub(crate) fn get_type(&self) -> Cow { + pub(crate) fn get_type(&'_ self) -> Cow<'_, Type> { match self { Value::Instruction { typ, .. } | Value::Param { typ, .. } => Cow::Borrowed(typ), Value::NumericConstant { typ, .. } => Cow::Owned(Type::Numeric(*typ)), diff --git a/compiler/noirc_evaluator/src/ssa/mod.rs b/compiler/noirc_evaluator/src/ssa/mod.rs index 06622125644..b6e77009ba2 100644 --- a/compiler/noirc_evaluator/src/ssa/mod.rs +++ b/compiler/noirc_evaluator/src/ssa/mod.rs @@ -102,7 +102,7 @@ pub struct SsaEvaluatorOptions { pub struct ArtifactsAndWarnings(pub Artifacts, pub Vec); /// The default SSA optimization pipeline. -pub fn primary_passes(options: &SsaEvaluatorOptions) -> Vec { +pub fn primary_passes(options: &'_ SsaEvaluatorOptions) -> Vec> { vec![ SsaPass::new(Ssa::expand_signed_checks, "expand signed checks"), SsaPass::new(Ssa::remove_unreachable_functions, "Removing Unreachable Functions"), diff --git a/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs b/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs index 9f10f362391..5a06d4a0451 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs @@ -552,14 +552,14 @@ impl Context { /// Get a cached result if it can be used in this context. fn get_cached( - &self, + &'_ self, dfg: &DataFlowGraph, dom: &mut DominatorTree, id: InstructionId, instruction: &Instruction, side_effects_enabled_var: ValueId, block: BasicBlockId, - ) -> Option { + ) -> Option> { let results_for_instruction = self.cached_instruction_results.get(instruction)?; let predicate = self.use_constraint_info && instruction.requires_acir_gen_predicate(dfg); let predicate = predicate.then_some(side_effects_enabled_var); @@ -731,11 +731,11 @@ impl ResultCache { /// cycles causing issues (e.g. two instructions being replaced with the results of each other /// such that neither instruction exists anymore.) fn get( - &self, + &'_ self, block: BasicBlockId, dom: &mut DominatorTree, has_side_effects: bool, - ) -> Option { + ) -> Option> { self.result.as_ref().and_then(|(origin_block, results)| { if dom.dominates(*origin_block, block) { Some(CacheResult::Cached(results)) diff --git a/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs b/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs index 1e4064d64b2..e1ff9304bd0 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs @@ -732,11 +732,11 @@ impl<'f> Context<'f> { /// Unlike push_instruction, this function will not map any ValueIds. /// within the given instruction, nor will it modify self.values in any way. fn insert_instruction_with_typevars( - &mut self, + &'_ mut self, instruction: Instruction, ctrl_typevars: Option>, call_stack: CallStackId, - ) -> InsertInstructionResult { + ) -> InsertInstructionResult<'_> { let block = self.target_block; self.inserter.function.dfg.insert_instruction_and_results( instruction, diff --git a/compiler/noirc_evaluator/src/ssa/opt/mem2reg/block.rs b/compiler/noirc_evaluator/src/ssa/opt/mem2reg/block.rs index d4ef509f73e..e194e8accf2 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/mem2reg/block.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/mem2reg/block.rs @@ -226,7 +226,7 @@ impl Block { aliases } - pub(super) fn get_aliases_for_value(&self, value: ValueId) -> Cow { + pub(super) fn get_aliases_for_value(&'_ self, value: ValueId) -> Cow<'_, AliasSet> { if let Some(expression) = self.expressions.get(&value) { if let Some(aliases) = self.aliases.get(expression) { return Cow::Borrowed(aliases); diff --git a/compiler/noirc_evaluator/src/ssa/opt/remove_bit_shifts.rs b/compiler/noirc_evaluator/src/ssa/opt/remove_bit_shifts.rs index 2dc3d99d8f8..d443503150e 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/remove_bit_shifts.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/remove_bit_shifts.rs @@ -339,11 +339,11 @@ impl Context<'_, '_, '_> { /// Insert a call instruction at the end of the current block and return /// the results of the call. pub(crate) fn insert_call( - &mut self, + &'_ mut self, func: ValueId, arguments: Vec, result_types: Vec, - ) -> Cow<[ValueId]> { + ) -> Cow<'_, [ValueId]> { self.context .insert_instruction(Instruction::Call { func, arguments }, Some(result_types)) .results() diff --git a/compiler/noirc_evaluator/src/ssa/opt/simple_optimization.rs b/compiler/noirc_evaluator/src/ssa/opt/simple_optimization.rs index de779d93ab5..df0185619bf 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/simple_optimization.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/simple_optimization.rs @@ -137,10 +137,10 @@ impl SimpleOptimizationContext<'_, '_> { /// Inserts an instruction in the current block right away. pub(crate) fn insert_instruction( - &mut self, + &'_ mut self, instruction: Instruction, ctrl_typevars: Option>, - ) -> InsertInstructionResult { + ) -> InsertInstructionResult<'_> { self.dfg.insert_instruction_and_results( instruction, self.block_id, diff --git a/compiler/noirc_frontend/src/ast/expression.rs b/compiler/noirc_frontend/src/ast/expression.rs index cd1151f9b62..5e5636cfd79 100644 --- a/compiler/noirc_frontend/src/ast/expression.rs +++ b/compiler/noirc_frontend/src/ast/expression.rs @@ -899,7 +899,7 @@ impl Display for FunctionDefinition { } impl FunctionReturnType { - pub fn get_type(&self) -> Cow { + pub fn get_type(&'_ self) -> Cow<'_, UnresolvedType> { match self { FunctionReturnType::Default(location) => { Cow::Owned(UnresolvedType { typ: UnresolvedTypeData::Unit, location: *location }) 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/value.rs b/compiler/noirc_frontend/src/hir/comptime/value.rs index 283af9dbf90..c6bf7ff4e44 100644 --- a/compiler/noirc_frontend/src/hir/comptime/value.rs +++ b/compiler/noirc_frontend/src/hir/comptime/value.rs @@ -127,7 +127,7 @@ impl Value { Value::Expr(Box::new(ExprValue::Pattern(pattern))) } - pub(crate) fn get_type(&self) -> Cow { + pub(crate) fn get_type(&'_ self) -> Cow<'_, Type> { Cow::Owned(match self { Value::Unit => Type::Unit, Value::Bool(_) => Type::Bool, diff --git a/compiler/noirc_frontend/src/hir_def/types.rs b/compiler/noirc_frontend/src/hir_def/types.rs index 5e598e4d700..8768dae1b7f 100644 --- a/compiler/noirc_frontend/src/hir_def/types.rs +++ b/compiler/noirc_frontend/src/hir_def/types.rs @@ -837,11 +837,11 @@ impl Shared { Shared(Rc::new(RefCell::new(thing))) } - pub fn borrow(&self) -> std::cell::Ref { + pub fn borrow(&'_ self) -> std::cell::Ref<'_, T> { self.0.borrow() } - pub fn borrow_mut(&self) -> std::cell::RefMut { + pub fn borrow_mut(&'_ self) -> std::cell::RefMut<'_, T> { self.0.borrow_mut() } @@ -941,7 +941,7 @@ impl TypeVariable { } /// Borrows this TypeVariable to (e.g.) manually match on the inner TypeBinding. - pub fn borrow(&self) -> std::cell::Ref { + pub fn borrow(&'_ self) -> std::cell::Ref<'_, TypeBinding> { self.1.borrow() } @@ -1576,7 +1576,7 @@ impl Type { /// Return the generics and type within this `Type::Forall`. /// Panics if `self` is not `Type::Forall` - pub fn unwrap_forall(&self) -> (Cow, &Type) { + pub fn unwrap_forall(&'_ self) -> (Cow<'_, GenericTypeVars>, &'_ Type) { match self { Type::Forall(generics, typ) => (Cow::Borrowed(generics), typ.as_ref()), other => (Cow::Owned(GenericTypeVars::new()), other), @@ -2436,7 +2436,7 @@ impl Type { /// Follow bindings if this is a type variable or generic to the first non-type-variable /// type. Unlike `follow_bindings`, this won't recursively follow any bindings on any /// fields or arguments of this type. - pub fn follow_bindings_shallow(&self) -> Cow { + pub fn follow_bindings_shallow(&'_ self) -> Cow<'_, Type> { match self { Type::TypeVariable(var) | Type::NamedGeneric(NamedGeneric { type_var: var, .. }) => { if let TypeBinding::Bound(typ) = &*var.borrow() { diff --git a/compiler/noirc_frontend/src/monomorphization/ast.rs b/compiler/noirc_frontend/src/monomorphization/ast.rs index 20ffc16b9f9..dbd8302ab1f 100644 --- a/compiler/noirc_frontend/src/monomorphization/ast.rs +++ b/compiler/noirc_frontend/src/monomorphization/ast.rs @@ -62,8 +62,8 @@ impl Expression { } /// The return type of an expression, if it has an obvious one. - pub fn return_type(&self) -> Option> { - fn borrowed(typ: &Type) -> Option> { + pub fn return_type(&'_ self) -> Option> { + fn borrowed(typ: &'_ Type) -> Option> { Some(Cow::Borrowed(typ)) } let owned = |typ: Type| Some(Cow::Owned(typ)); diff --git a/compiler/noirc_frontend/src/monomorphization/mod.rs b/compiler/noirc_frontend/src/monomorphization/mod.rs index ef186f82de3..4b04bc0ba7e 100644 --- a/compiler/noirc_frontend/src/monomorphization/mod.rs +++ b/compiler/noirc_frontend/src/monomorphization/mod.rs @@ -1621,13 +1621,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, }); diff --git a/tooling/ast_fuzzer/src/program/scope.rs b/tooling/ast_fuzzer/src/program/scope.rs index 3c8c2cbb84c..ead36a98cfb 100644 --- a/tooling/ast_fuzzer/src/program/scope.rs +++ b/tooling/ast_fuzzer/src/program/scope.rs @@ -174,7 +174,7 @@ impl Stack { } /// Iterate over the layers, starting the base layer. - pub fn iter_mut(&mut self) -> std::slice::IterMut { + pub fn iter_mut(&'_ mut self) -> std::slice::IterMut<'_, T> { self.0.iter_mut() } } diff --git a/tooling/debugger/src/context.rs b/tooling/debugger/src/context.rs index ac881acebf7..8a59ee68e06 100644 --- a/tooling/debugger/src/context.rs +++ b/tooling/debugger/src/context.rs @@ -898,11 +898,11 @@ impl<'a, B: BlackBoxFunctionSolver> DebugContext<'a, B> { } } - pub(super) fn get_variables(&self) -> Vec> { + pub(super) fn get_variables(&'_ self) -> Vec> { self.foreign_call_executor.get_variables() } - pub(super) fn current_stack_frame(&self) -> Option> { + pub(super) fn current_stack_frame(&'_ self) -> Option> { self.foreign_call_executor.current_stack_frame() } diff --git a/tooling/debugger/src/foreign_calls.rs b/tooling/debugger/src/foreign_calls.rs index b91e8cffd17..715a2188cf3 100644 --- a/tooling/debugger/src/foreign_calls.rs +++ b/tooling/debugger/src/foreign_calls.rs @@ -40,8 +40,8 @@ impl DebugForeignCall { } pub trait DebugForeignCallExecutor: ForeignCallExecutor { - fn get_variables(&self) -> Vec>; - fn current_stack_frame(&self) -> Option>; + fn get_variables(&'_ self) -> Vec>; + fn current_stack_frame(&'_ self) -> Option>; fn restart(&mut self, artifact: &DebugArtifact); } @@ -102,11 +102,11 @@ impl DefaultDebugForeignCallExecutor { } impl DebugForeignCallExecutor for DefaultDebugForeignCallExecutor { - fn get_variables(&self) -> Vec> { + fn get_variables(&'_ self) -> Vec> { self.debug_vars.get_variables() } - fn current_stack_frame(&self) -> Option> { + fn current_stack_frame(&'_ self) -> Option> { self.debug_vars.current_stack_frame() } @@ -209,11 +209,11 @@ where H: DebugForeignCallExecutor, I: ForeignCallExecutor, { - fn get_variables(&self) -> Vec> { + fn get_variables(&'_ self) -> Vec> { self.handler().get_variables() } - fn current_stack_frame(&self) -> Option> { + fn current_stack_frame(&'_ self) -> Option> { self.handler().current_stack_frame() } fn restart(&mut self, artifact: &DebugArtifact) { diff --git a/tooling/greybox_fuzzer/src/corpus.rs b/tooling/greybox_fuzzer/src/corpus.rs index e0ec4166e05..037372e632b 100644 --- a/tooling/greybox_fuzzer/src/corpus.rs +++ b/tooling/greybox_fuzzer/src/corpus.rs @@ -341,7 +341,7 @@ impl Corpus { } /// Returns all testcases that have ever been added to the corpus, including cached ones - pub fn get_full_stored_corpus(&mut self) -> Vec { + pub fn get_full_stored_corpus(&'_ mut self) -> Vec> { let stored_corpus: Vec<_> = self.corpus_file_manager.get_full_corpus().into_iter().map(TestCase::from).collect(); let id_testcase_pair: Vec<_> = @@ -413,7 +413,7 @@ impl Corpus { } /// Returns a vector of all currently active testcases - pub fn get_current_discovered_testcases(&self) -> Vec { + pub fn get_current_discovered_testcases(&'_ self) -> Vec> { self.discovered_testcases.iter().map(|(&id, value)| TestCase::with_id(id, value)).collect() } } 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/noirc_artifacts/src/debug_vars.rs b/tooling/noirc_artifacts/src/debug_vars.rs index 9e7ab906dd8..cfdea6379cb 100644 --- a/tooling/noirc_artifacts/src/debug_vars.rs +++ b/tooling/noirc_artifacts/src/debug_vars.rs @@ -26,11 +26,11 @@ impl DebugVars { self.functions.extend(info.functions.clone()); } - pub fn get_variables(&self) -> Vec> { + pub fn get_variables(&'_ self) -> Vec> { self.frames.iter().map(|(fn_id, frame)| self.build_stack_frame(fn_id, frame)).collect() } - pub fn current_stack_frame(&self) -> Option> { + pub fn current_stack_frame(&'_ self) -> Option> { self.frames.last().map(|(fn_id, frame)| self.build_stack_frame(fn_id, frame)) } From 1df2a26b7b6b847acc56a95cc02c53b3ed2a10c1 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Thu, 28 Aug 2025 23:23:50 +0000 Subject: [PATCH 2/7] chore: fix future incompatibility warning --- Cargo.lock | 28 +++++++++++++--------------- tooling/ssa_fuzzer/fuzzer/Cargo.toml | 2 +- 2 files changed, 14 insertions(+), 16 deletions(-) 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/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" From c2be1405b77bbdc2667ab531ce6974e39c0c84ef Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Fri, 29 Aug 2025 10:31:34 +0000 Subject: [PATCH 3/7] chore: allow `mismatched_lifetime_syntaxes` --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) 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" From a70d823c596b182b7fd29de812f569d4798eb451 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Fri, 29 Aug 2025 10:34:55 +0000 Subject: [PATCH 4/7] chore: revert lifetime changes --- compiler/fm/src/file_map.rs | 2 +- compiler/noirc_driver/src/lib.rs | 2 +- .../noirc_evaluator/src/acir/acir_context/mod.rs | 2 +- compiler/noirc_evaluator/src/brillig/mod.rs | 4 ++-- .../noirc_evaluator/src/ssa/function_builder/mod.rs | 8 ++++---- compiler/noirc_evaluator/src/ssa/ir/dfg.rs | 12 ++++++------ .../noirc_evaluator/src/ssa/ir/function_inserter.rs | 4 ++-- compiler/noirc_evaluator/src/ssa/ir/printer.rs | 2 +- compiler/noirc_evaluator/src/ssa/ir/value.rs | 2 +- compiler/noirc_evaluator/src/ssa/mod.rs | 2 +- .../noirc_evaluator/src/ssa/opt/constant_folding.rs | 8 ++++---- compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs | 4 ++-- .../noirc_evaluator/src/ssa/opt/mem2reg/block.rs | 2 +- .../noirc_evaluator/src/ssa/opt/remove_bit_shifts.rs | 4 ++-- .../src/ssa/opt/simple_optimization.rs | 4 ++-- compiler/noirc_frontend/src/ast/expression.rs | 2 +- compiler/noirc_frontend/src/hir/comptime/value.rs | 2 +- compiler/noirc_frontend/src/hir_def/types.rs | 10 +++++----- compiler/noirc_frontend/src/monomorphization/ast.rs | 4 ++-- tooling/ast_fuzzer/src/program/scope.rs | 2 +- tooling/debugger/src/context.rs | 4 ++-- tooling/debugger/src/foreign_calls.rs | 12 ++++++------ tooling/greybox_fuzzer/src/corpus.rs | 4 ++-- tooling/noirc_artifacts/src/debug_vars.rs | 4 ++-- 24 files changed, 53 insertions(+), 53 deletions(-) diff --git a/compiler/fm/src/file_map.rs b/compiler/fm/src/file_map.rs index b2728781092..f078ecb8545 100644 --- a/compiler/fm/src/file_map.rs +++ b/compiler/fm/src/file_map.rs @@ -73,7 +73,7 @@ impl FileMap { file_id } - pub fn get_file(&'_ self, file_id: FileId) -> Option> { + pub fn get_file(&self, file_id: FileId) -> Option { self.files.get(file_id.0).map(File).ok() } diff --git a/compiler/noirc_driver/src/lib.rs b/compiler/noirc_driver/src/lib.rs index c629f3369c8..d90d73dfe63 100644 --- a/compiler/noirc_driver/src/lib.rs +++ b/compiler/noirc_driver/src/lib.rs @@ -270,7 +270,7 @@ pub fn parse_expression_width(input: &str) -> Result FrontendOptions<'_> { + pub(crate) fn frontend_options(&self) -> FrontendOptions { FrontendOptions { debug_comptime_in_file: self.debug_comptime_in_file.as_deref(), pedantic_solving: self.pedantic_solving, diff --git a/compiler/noirc_evaluator/src/acir/acir_context/mod.rs b/compiler/noirc_evaluator/src/acir/acir_context/mod.rs index cdf3c421e0d..a4eaf6bfd91 100644 --- a/compiler/noirc_evaluator/src/acir/acir_context/mod.rs +++ b/compiler/noirc_evaluator/src/acir/acir_context/mod.rs @@ -1703,7 +1703,7 @@ impl AcirVarData { impl AcirVarData { /// Converts all enum variants to an Expression. - pub(crate) fn to_expression(&'_ self) -> Cow<'_, Expression> { + pub(crate) fn to_expression(&self) -> Cow> { match self { AcirVarData::Witness(witness) => Cow::Owned(Expression::from(*witness)), AcirVarData::Expr(expr) => Cow::Borrowed(expr), diff --git a/compiler/noirc_evaluator/src/brillig/mod.rs b/compiler/noirc_evaluator/src/brillig/mod.rs index 0456286e082..b99217b6d50 100644 --- a/compiler/noirc_evaluator/src/brillig/mod.rs +++ b/compiler/noirc_evaluator/src/brillig/mod.rs @@ -76,10 +76,10 @@ impl Brillig { /// Finds a brillig artifact by its label pub(crate) fn find_by_label( - &'_ self, + &self, function_label: Label, options: &BrilligOptions, - ) -> Option>> { + ) -> Option>> { match function_label.label_type { LabelType::Function(function_id, _) => { self.ssa_function_to_brillig.get(&function_id).map(Cow::Borrowed) diff --git a/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs b/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs index 43dde8a5ad0..4ddd5106817 100644 --- a/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs +++ b/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs @@ -212,10 +212,10 @@ impl FunctionBuilder { /// Inserts a new instruction at the end of the current block and returns its results pub fn insert_instruction( - &'_ mut self, + &mut self, instruction: Instruction, ctrl_typevars: Option>, - ) -> InsertInstructionResult<'_> { + ) -> InsertInstructionResult { let block = self.current_block(); if self.simplify { @@ -341,11 +341,11 @@ impl FunctionBuilder { /// Insert a call instruction at the end of the current block and return /// the results of the call. pub fn insert_call( - &'_ mut self, + &mut self, func: ValueId, arguments: Vec, result_types: Vec, - ) -> Cow<'_, [ValueId]> { + ) -> Cow<[ValueId]> { self.insert_instruction(Instruction::Call { func, arguments }, Some(result_types)).results() } diff --git a/compiler/noirc_evaluator/src/ssa/ir/dfg.rs b/compiler/noirc_evaluator/src/ssa/ir/dfg.rs index 5bce541fa06..6ba1629b5f6 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/dfg.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/dfg.rs @@ -245,12 +245,12 @@ impl DataFlowGraph { } pub(crate) fn insert_instruction_and_results_without_simplification( - &'_ mut self, + &mut self, instruction: Instruction, block: BasicBlockId, ctrl_typevars: Option>, call_stack: CallStackId, - ) -> InsertInstructionResult<'_> { + ) -> InsertInstructionResult { if !self.is_handled_by_runtime(&instruction) { // Panicking to raise attention. If we're not supposed to simplify it immediately, // pushing the instruction would just cause a potential panic later on. @@ -269,12 +269,12 @@ impl DataFlowGraph { /// Simplifies a new instruction and inserts it at the end of the given block and returns its results. /// If the instruction is not handled by the current runtime, `InstructionRemoved` is returned. pub(crate) fn insert_instruction_and_results( - &'_ mut self, + &mut self, instruction: Instruction, block: BasicBlockId, ctrl_typevars: Option>, call_stack: CallStackId, - ) -> InsertInstructionResult<'_> { + ) -> InsertInstructionResult { self.insert_instruction_and_results_if_simplified( instruction, block, @@ -286,13 +286,13 @@ impl DataFlowGraph { /// Simplifies a potentially existing instruction and inserts it only if it changed. pub(crate) fn insert_instruction_and_results_if_simplified( - &'_ mut self, + &mut self, instruction: Instruction, block: BasicBlockId, ctrl_typevars: Option>, call_stack: CallStackId, existing_id: Option, - ) -> InsertInstructionResult<'_> { + ) -> InsertInstructionResult { if !self.is_handled_by_runtime(&instruction) { // BUG: With panicking it fails to build the `token_contract`; see: // https://github.com/AztecProtocol/aztec-packages/pull/11294#issuecomment-2624379102 diff --git a/compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs b/compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs index dff85dd9dbf..c96db249283 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs @@ -100,12 +100,12 @@ impl<'f> FunctionInserter<'f> { } pub(crate) fn push_instruction_value( - &'_ mut self, + &mut self, instruction: Instruction, id: InstructionId, block: BasicBlockId, call_stack: CallStackId, - ) -> InsertInstructionResult<'_> { + ) -> InsertInstructionResult { let results = self.function.dfg.instruction_results(id).to_vec(); let ctrl_typevars = instruction diff --git a/compiler/noirc_evaluator/src/ssa/ir/printer.rs b/compiler/noirc_evaluator/src/ssa/ir/printer.rs index 588607d0ce1..706cc1c3aa2 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/printer.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/printer.rs @@ -28,7 +28,7 @@ pub struct Printer<'local> { } impl Ssa { - pub fn print_without_locations(&'_ self) -> Printer<'_> { + pub fn print_without_locations(&self) -> Printer { Printer { ssa: self, fm: None } } diff --git a/compiler/noirc_evaluator/src/ssa/ir/value.rs b/compiler/noirc_evaluator/src/ssa/ir/value.rs index e148170337c..bc8fc3c4168 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/value.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/value.rs @@ -61,7 +61,7 @@ pub enum Value { impl Value { /// Retrieves the type of this Value - pub(crate) fn get_type(&'_ self) -> Cow<'_, Type> { + pub(crate) fn get_type(&self) -> Cow { match self { Value::Instruction { typ, .. } | Value::Param { typ, .. } => Cow::Borrowed(typ), Value::NumericConstant { typ, .. } => Cow::Owned(Type::Numeric(*typ)), diff --git a/compiler/noirc_evaluator/src/ssa/mod.rs b/compiler/noirc_evaluator/src/ssa/mod.rs index b6e77009ba2..06622125644 100644 --- a/compiler/noirc_evaluator/src/ssa/mod.rs +++ b/compiler/noirc_evaluator/src/ssa/mod.rs @@ -102,7 +102,7 @@ pub struct SsaEvaluatorOptions { pub struct ArtifactsAndWarnings(pub Artifacts, pub Vec); /// The default SSA optimization pipeline. -pub fn primary_passes(options: &'_ SsaEvaluatorOptions) -> Vec> { +pub fn primary_passes(options: &SsaEvaluatorOptions) -> Vec { vec![ SsaPass::new(Ssa::expand_signed_checks, "expand signed checks"), SsaPass::new(Ssa::remove_unreachable_functions, "Removing Unreachable Functions"), diff --git a/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs b/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs index 5a06d4a0451..9f10f362391 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs @@ -552,14 +552,14 @@ impl Context { /// Get a cached result if it can be used in this context. fn get_cached( - &'_ self, + &self, dfg: &DataFlowGraph, dom: &mut DominatorTree, id: InstructionId, instruction: &Instruction, side_effects_enabled_var: ValueId, block: BasicBlockId, - ) -> Option> { + ) -> Option { let results_for_instruction = self.cached_instruction_results.get(instruction)?; let predicate = self.use_constraint_info && instruction.requires_acir_gen_predicate(dfg); let predicate = predicate.then_some(side_effects_enabled_var); @@ -731,11 +731,11 @@ impl ResultCache { /// cycles causing issues (e.g. two instructions being replaced with the results of each other /// such that neither instruction exists anymore.) fn get( - &'_ self, + &self, block: BasicBlockId, dom: &mut DominatorTree, has_side_effects: bool, - ) -> Option> { + ) -> Option { self.result.as_ref().and_then(|(origin_block, results)| { if dom.dominates(*origin_block, block) { Some(CacheResult::Cached(results)) diff --git a/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs b/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs index e1ff9304bd0..1e4064d64b2 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs @@ -732,11 +732,11 @@ impl<'f> Context<'f> { /// Unlike push_instruction, this function will not map any ValueIds. /// within the given instruction, nor will it modify self.values in any way. fn insert_instruction_with_typevars( - &'_ mut self, + &mut self, instruction: Instruction, ctrl_typevars: Option>, call_stack: CallStackId, - ) -> InsertInstructionResult<'_> { + ) -> InsertInstructionResult { let block = self.target_block; self.inserter.function.dfg.insert_instruction_and_results( instruction, diff --git a/compiler/noirc_evaluator/src/ssa/opt/mem2reg/block.rs b/compiler/noirc_evaluator/src/ssa/opt/mem2reg/block.rs index e194e8accf2..d4ef509f73e 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/mem2reg/block.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/mem2reg/block.rs @@ -226,7 +226,7 @@ impl Block { aliases } - pub(super) fn get_aliases_for_value(&'_ self, value: ValueId) -> Cow<'_, AliasSet> { + pub(super) fn get_aliases_for_value(&self, value: ValueId) -> Cow { if let Some(expression) = self.expressions.get(&value) { if let Some(aliases) = self.aliases.get(expression) { return Cow::Borrowed(aliases); diff --git a/compiler/noirc_evaluator/src/ssa/opt/remove_bit_shifts.rs b/compiler/noirc_evaluator/src/ssa/opt/remove_bit_shifts.rs index d443503150e..2dc3d99d8f8 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/remove_bit_shifts.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/remove_bit_shifts.rs @@ -339,11 +339,11 @@ impl Context<'_, '_, '_> { /// Insert a call instruction at the end of the current block and return /// the results of the call. pub(crate) fn insert_call( - &'_ mut self, + &mut self, func: ValueId, arguments: Vec, result_types: Vec, - ) -> Cow<'_, [ValueId]> { + ) -> Cow<[ValueId]> { self.context .insert_instruction(Instruction::Call { func, arguments }, Some(result_types)) .results() diff --git a/compiler/noirc_evaluator/src/ssa/opt/simple_optimization.rs b/compiler/noirc_evaluator/src/ssa/opt/simple_optimization.rs index df0185619bf..de779d93ab5 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/simple_optimization.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/simple_optimization.rs @@ -137,10 +137,10 @@ impl SimpleOptimizationContext<'_, '_> { /// Inserts an instruction in the current block right away. pub(crate) fn insert_instruction( - &'_ mut self, + &mut self, instruction: Instruction, ctrl_typevars: Option>, - ) -> InsertInstructionResult<'_> { + ) -> InsertInstructionResult { self.dfg.insert_instruction_and_results( instruction, self.block_id, diff --git a/compiler/noirc_frontend/src/ast/expression.rs b/compiler/noirc_frontend/src/ast/expression.rs index 5e5636cfd79..cd1151f9b62 100644 --- a/compiler/noirc_frontend/src/ast/expression.rs +++ b/compiler/noirc_frontend/src/ast/expression.rs @@ -899,7 +899,7 @@ impl Display for FunctionDefinition { } impl FunctionReturnType { - pub fn get_type(&'_ self) -> Cow<'_, UnresolvedType> { + pub fn get_type(&self) -> Cow { match self { FunctionReturnType::Default(location) => { Cow::Owned(UnresolvedType { typ: UnresolvedTypeData::Unit, location: *location }) diff --git a/compiler/noirc_frontend/src/hir/comptime/value.rs b/compiler/noirc_frontend/src/hir/comptime/value.rs index c6bf7ff4e44..283af9dbf90 100644 --- a/compiler/noirc_frontend/src/hir/comptime/value.rs +++ b/compiler/noirc_frontend/src/hir/comptime/value.rs @@ -127,7 +127,7 @@ impl Value { Value::Expr(Box::new(ExprValue::Pattern(pattern))) } - pub(crate) fn get_type(&'_ self) -> Cow<'_, Type> { + pub(crate) fn get_type(&self) -> Cow { Cow::Owned(match self { Value::Unit => Type::Unit, Value::Bool(_) => Type::Bool, diff --git a/compiler/noirc_frontend/src/hir_def/types.rs b/compiler/noirc_frontend/src/hir_def/types.rs index 8768dae1b7f..5e598e4d700 100644 --- a/compiler/noirc_frontend/src/hir_def/types.rs +++ b/compiler/noirc_frontend/src/hir_def/types.rs @@ -837,11 +837,11 @@ impl Shared { Shared(Rc::new(RefCell::new(thing))) } - pub fn borrow(&'_ self) -> std::cell::Ref<'_, T> { + pub fn borrow(&self) -> std::cell::Ref { self.0.borrow() } - pub fn borrow_mut(&'_ self) -> std::cell::RefMut<'_, T> { + pub fn borrow_mut(&self) -> std::cell::RefMut { self.0.borrow_mut() } @@ -941,7 +941,7 @@ impl TypeVariable { } /// Borrows this TypeVariable to (e.g.) manually match on the inner TypeBinding. - pub fn borrow(&'_ self) -> std::cell::Ref<'_, TypeBinding> { + pub fn borrow(&self) -> std::cell::Ref { self.1.borrow() } @@ -1576,7 +1576,7 @@ impl Type { /// Return the generics and type within this `Type::Forall`. /// Panics if `self` is not `Type::Forall` - pub fn unwrap_forall(&'_ self) -> (Cow<'_, GenericTypeVars>, &'_ Type) { + pub fn unwrap_forall(&self) -> (Cow, &Type) { match self { Type::Forall(generics, typ) => (Cow::Borrowed(generics), typ.as_ref()), other => (Cow::Owned(GenericTypeVars::new()), other), @@ -2436,7 +2436,7 @@ impl Type { /// Follow bindings if this is a type variable or generic to the first non-type-variable /// type. Unlike `follow_bindings`, this won't recursively follow any bindings on any /// fields or arguments of this type. - pub fn follow_bindings_shallow(&'_ self) -> Cow<'_, Type> { + pub fn follow_bindings_shallow(&self) -> Cow { match self { Type::TypeVariable(var) | Type::NamedGeneric(NamedGeneric { type_var: var, .. }) => { if let TypeBinding::Bound(typ) = &*var.borrow() { diff --git a/compiler/noirc_frontend/src/monomorphization/ast.rs b/compiler/noirc_frontend/src/monomorphization/ast.rs index dbd8302ab1f..20ffc16b9f9 100644 --- a/compiler/noirc_frontend/src/monomorphization/ast.rs +++ b/compiler/noirc_frontend/src/monomorphization/ast.rs @@ -62,8 +62,8 @@ impl Expression { } /// The return type of an expression, if it has an obvious one. - pub fn return_type(&'_ self) -> Option> { - fn borrowed(typ: &'_ Type) -> Option> { + pub fn return_type(&self) -> Option> { + fn borrowed(typ: &Type) -> Option> { Some(Cow::Borrowed(typ)) } let owned = |typ: Type| Some(Cow::Owned(typ)); diff --git a/tooling/ast_fuzzer/src/program/scope.rs b/tooling/ast_fuzzer/src/program/scope.rs index ead36a98cfb..3c8c2cbb84c 100644 --- a/tooling/ast_fuzzer/src/program/scope.rs +++ b/tooling/ast_fuzzer/src/program/scope.rs @@ -174,7 +174,7 @@ impl Stack { } /// Iterate over the layers, starting the base layer. - pub fn iter_mut(&'_ mut self) -> std::slice::IterMut<'_, T> { + pub fn iter_mut(&mut self) -> std::slice::IterMut { self.0.iter_mut() } } diff --git a/tooling/debugger/src/context.rs b/tooling/debugger/src/context.rs index 8a59ee68e06..ac881acebf7 100644 --- a/tooling/debugger/src/context.rs +++ b/tooling/debugger/src/context.rs @@ -898,11 +898,11 @@ impl<'a, B: BlackBoxFunctionSolver> DebugContext<'a, B> { } } - pub(super) fn get_variables(&'_ self) -> Vec> { + pub(super) fn get_variables(&self) -> Vec> { self.foreign_call_executor.get_variables() } - pub(super) fn current_stack_frame(&'_ self) -> Option> { + pub(super) fn current_stack_frame(&self) -> Option> { self.foreign_call_executor.current_stack_frame() } diff --git a/tooling/debugger/src/foreign_calls.rs b/tooling/debugger/src/foreign_calls.rs index 715a2188cf3..b91e8cffd17 100644 --- a/tooling/debugger/src/foreign_calls.rs +++ b/tooling/debugger/src/foreign_calls.rs @@ -40,8 +40,8 @@ impl DebugForeignCall { } pub trait DebugForeignCallExecutor: ForeignCallExecutor { - fn get_variables(&'_ self) -> Vec>; - fn current_stack_frame(&'_ self) -> Option>; + fn get_variables(&self) -> Vec>; + fn current_stack_frame(&self) -> Option>; fn restart(&mut self, artifact: &DebugArtifact); } @@ -102,11 +102,11 @@ impl DefaultDebugForeignCallExecutor { } impl DebugForeignCallExecutor for DefaultDebugForeignCallExecutor { - fn get_variables(&'_ self) -> Vec> { + fn get_variables(&self) -> Vec> { self.debug_vars.get_variables() } - fn current_stack_frame(&'_ self) -> Option> { + fn current_stack_frame(&self) -> Option> { self.debug_vars.current_stack_frame() } @@ -209,11 +209,11 @@ where H: DebugForeignCallExecutor, I: ForeignCallExecutor, { - fn get_variables(&'_ self) -> Vec> { + fn get_variables(&self) -> Vec> { self.handler().get_variables() } - fn current_stack_frame(&'_ self) -> Option> { + fn current_stack_frame(&self) -> Option> { self.handler().current_stack_frame() } fn restart(&mut self, artifact: &DebugArtifact) { diff --git a/tooling/greybox_fuzzer/src/corpus.rs b/tooling/greybox_fuzzer/src/corpus.rs index 037372e632b..e0ec4166e05 100644 --- a/tooling/greybox_fuzzer/src/corpus.rs +++ b/tooling/greybox_fuzzer/src/corpus.rs @@ -341,7 +341,7 @@ impl Corpus { } /// Returns all testcases that have ever been added to the corpus, including cached ones - pub fn get_full_stored_corpus(&'_ mut self) -> Vec> { + pub fn get_full_stored_corpus(&mut self) -> Vec { let stored_corpus: Vec<_> = self.corpus_file_manager.get_full_corpus().into_iter().map(TestCase::from).collect(); let id_testcase_pair: Vec<_> = @@ -413,7 +413,7 @@ impl Corpus { } /// Returns a vector of all currently active testcases - pub fn get_current_discovered_testcases(&'_ self) -> Vec> { + pub fn get_current_discovered_testcases(&self) -> Vec { self.discovered_testcases.iter().map(|(&id, value)| TestCase::with_id(id, value)).collect() } } diff --git a/tooling/noirc_artifacts/src/debug_vars.rs b/tooling/noirc_artifacts/src/debug_vars.rs index cfdea6379cb..9e7ab906dd8 100644 --- a/tooling/noirc_artifacts/src/debug_vars.rs +++ b/tooling/noirc_artifacts/src/debug_vars.rs @@ -26,11 +26,11 @@ impl DebugVars { self.functions.extend(info.functions.clone()); } - pub fn get_variables(&'_ self) -> Vec> { + pub fn get_variables(&self) -> Vec> { self.frames.iter().map(|(fn_id, frame)| self.build_stack_frame(fn_id, frame)).collect() } - pub fn current_stack_frame(&'_ self) -> Option> { + pub fn current_stack_frame(&self) -> Option> { self.frames.last().map(|(fn_id, frame)| self.build_stack_frame(fn_id, frame)) } From 4df6200f39ff429b4196d3851c234915351f59dc Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Fri, 29 Aug 2025 10:40:00 +0000 Subject: [PATCH 5/7] . --- compiler/noirc_frontend/Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/noirc_frontend/Cargo.toml b/compiler/noirc_frontend/Cargo.toml index b6a9aa8d69b..b8dc70122fa 100644 --- a/compiler/noirc_frontend/Cargo.toml +++ b/compiler/noirc_frontend/Cargo.toml @@ -6,6 +6,9 @@ edition.workspace = true rust-version.workspace = true license.workspace = true +[lints] +workspace = true + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] From 4a720f3d5883d518b1379ab81d7de7016f1bdb76 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Fri, 29 Aug 2025 10:51:00 +0000 Subject: [PATCH 6/7] chore: more warnings --- compiler/noirc_frontend/src/ast/mod.rs | 6 +- compiler/noirc_frontend/src/ast/statement.rs | 2 +- compiler/noirc_frontend/src/debug/mod.rs | 10 +-- .../noirc_frontend/src/elaborator/enums.rs | 4 +- .../src/elaborator/expressions.rs | 4 +- .../noirc_frontend/src/elaborator/types.rs | 16 ++-- .../noirc_frontend/src/hir/comptime/errors.rs | 2 +- .../src/hir/comptime/interpreter/builtin.rs | 22 +++--- .../interpreter/builtin/builtin_helpers.rs | 2 +- .../src/hir/comptime/interpreter/infix.rs | 2 + .../noirc_frontend/src/hir/comptime/value.rs | 2 +- .../src/hir/def_collector/dc_crate.rs | 7 +- compiler/noirc_frontend/src/hir/mod.rs | 4 +- .../src/hir_def/types/arithmetic.rs | 5 +- .../src/hir_def/types/unification.rs | 6 +- compiler/noirc_frontend/src/lexer/lexer.rs | 2 +- compiler/noirc_frontend/src/lexer/token.rs | 28 +++---- .../src/monomorphization/ast.rs | 10 +-- .../src/monomorphization/mod.rs | 79 ++++++++----------- .../src/monomorphization/printer.rs | 18 ++--- compiler/noirc_frontend/src/node_interner.rs | 28 +++---- compiler/noirc_frontend/src/ownership/mod.rs | 2 +- compiler/noirc_frontend/src/signed_field.rs | 4 +- compiler/noirc_frontend/src/test_utils.rs | 2 +- 24 files changed, 127 insertions(+), 140 deletions(-) diff --git a/compiler/noirc_frontend/src/ast/mod.rs b/compiler/noirc_frontend/src/ast/mod.rs index 21cc8307151..20b8f4f65b2 100644 --- a/compiler/noirc_frontend/src/ast/mod.rs +++ b/compiler/noirc_frontend/src/ast/mod.rs @@ -151,7 +151,7 @@ pub enum UnresolvedTypeData { /// An "as Trait" path leading to an associated type. /// E.g. `::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..ece3c429b61 100644 --- a/compiler/noirc_frontend/src/elaborator/enums.rs +++ b/compiler/noirc_frontend/src/elaborator/enums.rs @@ -183,13 +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), + Value::Enum(variant_index, Vec::new(), typ), ); Self::get_module_mut(self.def_maps, type_id.module_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..2800ed0a4f3 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,14 @@ 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); + |mutable| Reference(Box::new(element_type.clone()), mutable); let immutable = make_expected(false); let mutable = make_expected(true); @@ -1686,7 +1686,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 +2228,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/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 4b04bc0ba7e..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 @@ -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()); From 3927957bf303715c55ecf92b60bf14d0b3e31a90 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Fri, 29 Aug 2025 10:57:57 +0000 Subject: [PATCH 7/7] . --- compiler/noirc_frontend/src/elaborator/enums.rs | 5 ++--- compiler/noirc_frontend/src/elaborator/types.rs | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/compiler/noirc_frontend/src/elaborator/enums.rs b/compiler/noirc_frontend/src/elaborator/enums.rs index ece3c429b61..409c2582839 100644 --- a/compiler/noirc_frontend/src/elaborator/enums.rs +++ b/compiler/noirc_frontend/src/elaborator/enums.rs @@ -188,9 +188,8 @@ impl Elaborator<'_> { 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( - 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/types.rs b/compiler/noirc_frontend/src/elaborator/types.rs index 2800ed0a4f3..5139e8e35d4 100644 --- a/compiler/noirc_frontend/src/elaborator/types.rs +++ b/compiler/noirc_frontend/src/elaborator/types.rs @@ -1599,8 +1599,7 @@ impl Elaborator<'_> { } UnaryOp::Dereference { implicitly_added: _ } => { let element_type = self.interner.next_type_variable(); - let make_expected = - |mutable| 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);