From a671bc67e7ed73412ba2ab60df5513a9141087fa Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Fri, 18 Jul 2025 13:13:10 +0000 Subject: [PATCH 1/2] . --- compiler/noirc_evaluator/src/ssa/interpreter/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/noirc_evaluator/src/ssa/interpreter/mod.rs b/compiler/noirc_evaluator/src/ssa/interpreter/mod.rs index b263453d8f3..8c2a05788f2 100644 --- a/compiler/noirc_evaluator/src/ssa/interpreter/mod.rs +++ b/compiler/noirc_evaluator/src/ssa/interpreter/mod.rs @@ -877,7 +877,7 @@ impl<'ssa, W: Write> Interpreter<'ssa, W> { let index = self.lookup_u32(index, "array get index")?; let mut index = index - offset.to_u32(); - let element = if array.elements.borrow().len() == 0 { + let element = if array.elements.borrow().is_empty() { // Accessing an array of 0-len is replaced by asserting // the branch is not-taken during acir-gen and // a zeroed type is used in case of array get From d23ce27b59cd28b5f7c3abd8c9c3c70a1239a08c Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Fri, 18 Jul 2025 13:43:33 +0000 Subject: [PATCH 2/2] chore: enforce clippy --- tooling/nargo_toml/src/lib.rs | 1 + tooling/ssa_fuzzer/fuzzer/Cargo.toml | 3 + .../fuzzer/src/fuzz_lib/fuzz_target_lib.rs | 6 +- .../ssa_fuzzer/fuzzer/src/fuzz_lib/options.rs | 86 +++++++++---------- tooling/ssa_fuzzer/fuzzer/src/fuzz_target.rs | 4 +- .../mutations/functions/commands_mutator.rs | 6 +- .../fuzzer/src/mutations/functions/mod.rs | 8 +- .../instructions/argument_mutator.rs | 4 +- .../instructions/instruction_block_mutator.rs | 8 +- .../instructions/instruction_mutator.rs | 2 +- .../fuzzer/src/mutations/instructions/mod.rs | 10 +-- .../fuzzer/src/mutations/witness_mutator.rs | 4 +- 12 files changed, 73 insertions(+), 69 deletions(-) diff --git a/tooling/nargo_toml/src/lib.rs b/tooling/nargo_toml/src/lib.rs index 06e070290c5..cbfe4d76ef4 100644 --- a/tooling/nargo_toml/src/lib.rs +++ b/tooling/nargo_toml/src/lib.rs @@ -266,6 +266,7 @@ impl PackageConfig { /// Contains all the information about a package, as loaded from a `Nargo.toml`. #[derive(Debug, Deserialize, Clone)] #[serde(untagged)] +#[allow(clippy::large_enum_variant)] pub enum Config { /// Represents a `Nargo.toml` with package fields. Package { diff --git a/tooling/ssa_fuzzer/fuzzer/Cargo.toml b/tooling/ssa_fuzzer/fuzzer/Cargo.toml index 186585826d0..6e74fb2ffe5 100644 --- a/tooling/ssa_fuzzer/fuzzer/Cargo.toml +++ b/tooling/ssa_fuzzer/fuzzer/Cargo.toml @@ -8,6 +8,9 @@ license.workspace = true [package.metadata] cargo-fuzz = true +[lints] +workspace = true + [dependencies] libfuzzer-sys = { version = "0.4.0", features = ["arbitrary-derive"] } noirc_evaluator.workspace = true diff --git a/tooling/ssa_fuzzer/fuzzer/src/fuzz_lib/fuzz_target_lib.rs b/tooling/ssa_fuzzer/fuzzer/src/fuzz_lib/fuzz_target_lib.rs index 87ecab36d38..d87e2545588 100644 --- a/tooling/ssa_fuzzer/fuzzer/src/fuzz_lib/fuzz_target_lib.rs +++ b/tooling/ssa_fuzzer/fuzzer/src/fuzz_lib/fuzz_target_lib.rs @@ -52,7 +52,7 @@ pub(crate) fn fuzz_target(data: FuzzerData, options: FuzzerOptions) -> Option for SsaBlockOptions { @@ -86,14 +86,14 @@ impl From for SsaBlockOptions { /// Options for the fuzzer commands that can be used in the program context #[derive(Clone, Copy, Debug)] -pub struct FuzzerCommandOptions { +pub(crate) struct FuzzerCommandOptions { /// If false, we don't insert jmp_if - pub jmp_if_enabled: bool, + pub(crate) jmp_if_enabled: bool, /// If false, we don't insert jmp command - pub jmp_block_enabled: bool, + pub(crate) jmp_block_enabled: bool, /// If false, we don't switch to the next block - pub switch_to_next_block_enabled: bool, - pub loops_enabled: bool, + pub(crate) switch_to_next_block_enabled: bool, + pub(crate) loops_enabled: bool, } impl Default for FuzzerCommandOptions { @@ -108,15 +108,15 @@ impl Default for FuzzerCommandOptions { } #[derive(Clone)] -pub struct FuzzerOptions { - pub constrain_idempotent_morphing_enabled: bool, - pub constant_execution_enabled: bool, - pub compile_options: CompileOptions, - pub max_ssa_blocks_num: usize, - pub max_instructions_num: usize, - pub max_iterations_num: usize, - pub instruction_options: InstructionOptions, - pub fuzzer_command_options: FuzzerCommandOptions, +pub(crate) struct FuzzerOptions { + pub(crate) constrain_idempotent_morphing_enabled: bool, + pub(crate) constant_execution_enabled: bool, + pub(crate) compile_options: CompileOptions, + pub(crate) max_ssa_blocks_num: usize, + pub(crate) max_instructions_num: usize, + pub(crate) max_iterations_num: usize, + pub(crate) instruction_options: InstructionOptions, + pub(crate) fuzzer_command_options: FuzzerCommandOptions, } impl Default for FuzzerOptions { diff --git a/tooling/ssa_fuzzer/fuzzer/src/fuzz_target.rs b/tooling/ssa_fuzzer/fuzzer/src/fuzz_target.rs index e833f55f30e..75ca69efdc8 100644 --- a/tooling/ssa_fuzzer/fuzzer/src/fuzz_target.rs +++ b/tooling/ssa_fuzzer/fuzzer/src/fuzz_target.rs @@ -22,13 +22,13 @@ libfuzzer_sys::fuzz_target!(|data: &[u8]| -> Corpus { "FULL" => compile_options.show_ssa = true, "FINAL" => { compile_options.show_ssa_pass = - vec!["After Dead Instruction Elimination - ACIR".to_string()] + vec!["After Dead Instruction Elimination - ACIR".to_string()]; } "FIRST_AND_FINAL" => { compile_options.show_ssa_pass = vec![ "After Removing Unreachable Functions (1)".to_string(), "After Dead Instruction Elimination - ACIR".to_string(), - ] + ]; } _ => (), } diff --git a/tooling/ssa_fuzzer/fuzzer/src/mutations/functions/commands_mutator.rs b/tooling/ssa_fuzzer/fuzzer/src/mutations/functions/commands_mutator.rs index d4fb5f57ff2..5a8d80635cb 100644 --- a/tooling/ssa_fuzzer/fuzzer/src/mutations/functions/commands_mutator.rs +++ b/tooling/ssa_fuzzer/fuzzer/src/mutations/functions/commands_mutator.rs @@ -69,13 +69,13 @@ pub(crate) fn mutate_vec_fuzzer_command( match BASIC_FUZZER_COMMAND_MUTATION_CONFIGURATION.select(rng) { FuzzerCommandMutationOptions::Random => RandomMutation::mutate(rng, vec_fuzzer_command), FuzzerCommandMutationOptions::RemoveCommand => { - RemoveCommandMutation::mutate(rng, vec_fuzzer_command) + RemoveCommandMutation::mutate(rng, vec_fuzzer_command); } FuzzerCommandMutationOptions::AddCommand => { - AddCommandMutation::mutate(rng, vec_fuzzer_command) + AddCommandMutation::mutate(rng, vec_fuzzer_command); } FuzzerCommandMutationOptions::ReplaceCommand => { - ReplaceCommandMutation::mutate(rng, vec_fuzzer_command) + ReplaceCommandMutation::mutate(rng, vec_fuzzer_command); } } } diff --git a/tooling/ssa_fuzzer/fuzzer/src/mutations/functions/mod.rs b/tooling/ssa_fuzzer/fuzzer/src/mutations/functions/mod.rs index 1ac7a551b69..cb57c9b380f 100644 --- a/tooling/ssa_fuzzer/fuzzer/src/mutations/functions/mod.rs +++ b/tooling/ssa_fuzzer/fuzzer/src/mutations/functions/mod.rs @@ -74,16 +74,16 @@ impl MutateFunctionVec for FunctionInsertionMutation { pub(crate) fn mutate(vec_fuzzer_command: &mut Vec, rng: &mut StdRng) { match BASIC_FUNCTION_VEC_MUTATION_CONFIGURATION.select(rng) { FunctionVecMutationOptions::CopyFunction => { - CopyFunctionMutation::mutate(rng, vec_fuzzer_command) + CopyFunctionMutation::mutate(rng, vec_fuzzer_command); } FunctionVecMutationOptions::Remove => { - RemoveFunctionMutation::mutate(rng, vec_fuzzer_command) + RemoveFunctionMutation::mutate(rng, vec_fuzzer_command); } FunctionVecMutationOptions::Insertion => { - FunctionInsertionMutation::mutate(rng, vec_fuzzer_command) + FunctionInsertionMutation::mutate(rng, vec_fuzzer_command); } FunctionVecMutationOptions::InsertEmpty => { - InsertEmptyFunctionMutation::mutate(rng, vec_fuzzer_command) + InsertEmptyFunctionMutation::mutate(rng, vec_fuzzer_command); } FunctionVecMutationOptions::MutateFunction => { MutateFunction::mutate(rng, vec_fuzzer_command); diff --git a/tooling/ssa_fuzzer/fuzzer/src/mutations/instructions/argument_mutator.rs b/tooling/ssa_fuzzer/fuzzer/src/mutations/instructions/argument_mutator.rs index 70f384fc6e5..6f2ebb25d92 100644 --- a/tooling/ssa_fuzzer/fuzzer/src/mutations/instructions/argument_mutator.rs +++ b/tooling/ssa_fuzzer/fuzzer/src/mutations/instructions/argument_mutator.rs @@ -58,10 +58,10 @@ pub(crate) fn argument_mutator(argument: &mut Argument, rng: &mut StdRng) { match BASIC_ARGUMENT_MUTATION_CONFIGURATION.select(rng) { ArgumentMutationOptions::Random => RandomMutation::mutate(rng, argument), ArgumentMutationOptions::IncrementIndex => { - IncrementArgumentIndexMutation::mutate(rng, argument) + IncrementArgumentIndexMutation::mutate(rng, argument); } ArgumentMutationOptions::DecrementIndex => { - DecrementArgumentIndexMutation::mutate(rng, argument) + DecrementArgumentIndexMutation::mutate(rng, argument); } ArgumentMutationOptions::ChangeType => ChangeTypeMutation::mutate(rng, argument), } diff --git a/tooling/ssa_fuzzer/fuzzer/src/mutations/instructions/instruction_block_mutator.rs b/tooling/ssa_fuzzer/fuzzer/src/mutations/instructions/instruction_block_mutator.rs index b2c59fdb6e6..6a7dc80d8ad 100644 --- a/tooling/ssa_fuzzer/fuzzer/src/mutations/instructions/instruction_block_mutator.rs +++ b/tooling/ssa_fuzzer/fuzzer/src/mutations/instructions/instruction_block_mutator.rs @@ -88,16 +88,16 @@ pub(crate) fn instruction_block_mutator( match BASIC_INSTRUCTION_BLOCK_MUTATION_CONFIGURATION.select(rng) { InstructionBlockMutationOptions::Random => RandomMutation::mutate(rng, instruction_block), InstructionBlockMutationOptions::InstructionDeletion => { - InstructionBlockDeletionMutation::mutate(rng, instruction_block) + InstructionBlockDeletionMutation::mutate(rng, instruction_block); } InstructionBlockMutationOptions::InstructionInsertion => { - InstructionBlockInsertionMutation::mutate(rng, instruction_block) + InstructionBlockInsertionMutation::mutate(rng, instruction_block); } InstructionBlockMutationOptions::InstructionMutation => { - InstructionBlockInstructionMutation::mutate(rng, instruction_block) + InstructionBlockInstructionMutation::mutate(rng, instruction_block); } InstructionBlockMutationOptions::InstructionSwap => { - InstructionBlockInstructionSwapMutation::mutate(rng, instruction_block) + InstructionBlockInstructionSwapMutation::mutate(rng, instruction_block); } } } diff --git a/tooling/ssa_fuzzer/fuzzer/src/mutations/instructions/instruction_mutator.rs b/tooling/ssa_fuzzer/fuzzer/src/mutations/instructions/instruction_mutator.rs index 7fa0883d400..706fd4c556d 100644 --- a/tooling/ssa_fuzzer/fuzzer/src/mutations/instructions/instruction_mutator.rs +++ b/tooling/ssa_fuzzer/fuzzer/src/mutations/instructions/instruction_mutator.rs @@ -113,7 +113,7 @@ pub(crate) fn instruction_mutator(instruction: &mut Instruction, rng: &mut StdRn match BASIC_INSTRUCTION_MUTATION_CONFIGURATION.select(rng) { InstructionMutationOptions::Random => RandomMutation::mutate(rng, instruction), InstructionMutationOptions::ArgumentMutation => { - InstructionArgumentsMutation::mutate(rng, instruction) + InstructionArgumentsMutation::mutate(rng, instruction); } } } diff --git a/tooling/ssa_fuzzer/fuzzer/src/mutations/instructions/mod.rs b/tooling/ssa_fuzzer/fuzzer/src/mutations/instructions/mod.rs index b71ba47ef25..041ade7b8eb 100644 --- a/tooling/ssa_fuzzer/fuzzer/src/mutations/instructions/mod.rs +++ b/tooling/ssa_fuzzer/fuzzer/src/mutations/instructions/mod.rs @@ -86,19 +86,19 @@ impl MutateVecInstructionBlock for InstructionBlockInstructionSwapMutation { pub(crate) fn mutate(vec_instruction_block: &mut Vec, rng: &mut StdRng) { match BASIC_VECTOR_OF_INSTRUCTION_BLOCKS_MUTATION_CONFIGURATION.select(rng) { VectorOfInstructionBlocksMutationOptions::Random => { - RandomMutation::mutate(rng, vec_instruction_block) + RandomMutation::mutate(rng, vec_instruction_block); } VectorOfInstructionBlocksMutationOptions::InstructionBlockDeletion => { - InstructionBlockDeletionMutation::mutate(rng, vec_instruction_block) + InstructionBlockDeletionMutation::mutate(rng, vec_instruction_block); } VectorOfInstructionBlocksMutationOptions::InstructionBlockInsertion => { - InstructionBlockInsertionMutation::mutate(rng, vec_instruction_block) + InstructionBlockInsertionMutation::mutate(rng, vec_instruction_block); } VectorOfInstructionBlocksMutationOptions::InstructionBlockMutation => { - InstructionBlockInstructionMutation::mutate(rng, vec_instruction_block) + InstructionBlockInstructionMutation::mutate(rng, vec_instruction_block); } VectorOfInstructionBlocksMutationOptions::InstructionBlockSwap => { - InstructionBlockInstructionSwapMutation::mutate(rng, vec_instruction_block) + InstructionBlockInstructionSwapMutation::mutate(rng, vec_instruction_block); } } } diff --git a/tooling/ssa_fuzzer/fuzzer/src/mutations/witness_mutator.rs b/tooling/ssa_fuzzer/fuzzer/src/mutations/witness_mutator.rs index 6d0558af68f..b77014e71b8 100644 --- a/tooling/ssa_fuzzer/fuzzer/src/mutations/witness_mutator.rs +++ b/tooling/ssa_fuzzer/fuzzer/src/mutations/witness_mutator.rs @@ -147,10 +147,10 @@ pub(crate) fn mutate(witness_value: &mut WitnessValue, rng: &mut StdRng) { WitnessMutationOptions::MaxValue => MaxValueMutation::mutate(rng, witness_value), WitnessMutationOptions::MinValue => MinValueMutation::mutate(rng, witness_value), WitnessMutationOptions::SmallAddSub => { - WitnessSmallAddSubMutation::mutate(rng, witness_value) + WitnessSmallAddSubMutation::mutate(rng, witness_value); } WitnessMutationOptions::PowerOfTwoAddSub => { - WitnessAddSubPowerOfTwoMutation::mutate(rng, witness_value) + WitnessAddSubPowerOfTwoMutation::mutate(rng, witness_value); } } }