Skip to content

Commit

Permalink
chore!: bump rust edition to 2024 (#7533)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench authored Feb 26, 2025
1 parent ef2302b commit 826b18a
Show file tree
Hide file tree
Showing 327 changed files with 893 additions and 1,120 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ resolver = "2"
version = "1.0.0-beta.3"
# x-release-please-end
authors = ["The Noir Team <[email protected]>"]
edition = "2021"
edition = "2024"
rust-version = "1.85.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/noir-lang/noir/"
Expand Down
4 changes: 2 additions & 2 deletions acvm-repo/acir/benches/serialization.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
use std::{collections::BTreeSet, time::Duration};

use acir::{
FieldElement,
circuit::{Circuit, ExpressionWidth, Opcode, Program, PublicInputs},
native_types::{Expression, Witness},
FieldElement,
};

use pprof::criterion::{Output, PProfProfiler};
Expand Down
4 changes: 2 additions & 2 deletions acvm-repo/acir/src/circuit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{io::prelude::*, num::ParseIntError, str::FromStr};

use base64::Engine;
use flate2::Compression;
use serde::{de::Error as DeserializationError, Deserialize, Deserializer, Serialize, Serializer};
use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Error as DeserializationError};

use std::collections::BTreeSet;

Expand Down Expand Up @@ -375,8 +375,8 @@ mod tests {
use std::collections::BTreeSet;

use super::{
opcodes::{BlackBoxFuncCall, FunctionInput},
Circuit, Compression, Opcode, PublicInputs,
opcodes::{BlackBoxFuncCall, FunctionInput},
};
use crate::{
circuit::{ExpressionWidth, Program},
Expand Down
4 changes: 2 additions & 2 deletions acvm-repo/acir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ mod reflection {

use crate::{
circuit::{
brillig::{BrilligInputs, BrilligOutputs},
opcodes::{BlackBoxFuncCall, BlockType, ConstantOrWitnessEnum, FunctionInput},
AssertionPayload, Circuit, ExpressionOrMemory, ExpressionWidth, Opcode, OpcodeLocation,
Program,
brillig::{BrilligInputs, BrilligOutputs},
opcodes::{BlackBoxFuncCall, BlockType, ConstantOrWitnessEnum, FunctionInput},
},
native_types::{Witness, WitnessMap, WitnessStack},
};
Expand Down
6 changes: 1 addition & 5 deletions acvm-repo/acir/src/native_types/expression/ordering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,7 @@ impl<F: Ord> Expression<F> {

fn cmp_max(m1: Option<Witness>, m2: Option<Witness>) -> Ordering {
if let Some(m1) = m1 {
if let Some(m2) = m2 {
m1.cmp(&m2)
} else {
Ordering::Greater
}
if let Some(m2) = m2 { m1.cmp(&m2) } else { Ordering::Greater }
} else if m2.is_some() {
Ordering::Less
} else {
Expand Down
4 changes: 2 additions & 2 deletions acvm-repo/acir/src/native_types/witness_map.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::{
collections::{btree_map, BTreeMap},
collections::{BTreeMap, btree_map},
io::Read,
ops::Index,
};

use flate2::Compression;
use flate2::bufread::GzDecoder;
use flate2::bufread::GzEncoder;
use flate2::Compression;
use serde::{Deserialize, Serialize};
use thiserror::Error;

Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acir/src/native_types/witness_stack.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::io::Read;

use flate2::Compression;
use flate2::bufread::GzDecoder;
use flate2::bufread::GzEncoder;
use flate2::Compression;
use serde::{Deserialize, Serialize};
use thiserror::Error;

Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acir/tests/test_program_serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use std::collections::BTreeSet;

use acir::{
circuit::{
Circuit, Opcode, Program, PublicInputs,
brillig::{BrilligBytecode, BrilligFunctionId, BrilligInputs, BrilligOutputs},
opcodes::{AcirFunctionId, BlackBoxFuncCall, BlockId, FunctionInput, MemOp},
Circuit, Opcode, Program, PublicInputs,
},
native_types::{Expression, Witness},
};
Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acir_field/benches/field_element.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use acir_field::{AcirField, FieldElement};
use criterion::{criterion_group, criterion_main, Criterion};
use criterion::{Criterion, criterion_group, criterion_main};
use std::hint::black_box;

fn criterion_benchmark(c: &mut Criterion) {
Expand Down
12 changes: 2 additions & 10 deletions acvm-repo/acir_field/src/field_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,7 @@ impl<F: PrimeField> From<u32> for FieldElement<F> {

impl<F: PrimeField> From<bool> for FieldElement<F> {
fn from(boolean: bool) -> FieldElement<F> {
if boolean {
FieldElement::one()
} else {
FieldElement::zero()
}
if boolean { FieldElement::one() } else { FieldElement::zero() }
}
}

Expand Down Expand Up @@ -183,11 +179,7 @@ impl<F: PrimeField> AcirField for FieldElement<F> {
/// For example, a max bit size of 254 would give a max byte size of 32.
fn max_num_bytes() -> u32 {
let num_bytes = Self::max_num_bits() / 8;
if Self::max_num_bits() % 8 == 0 {
num_bytes
} else {
num_bytes + 1
}
if Self::max_num_bits() % 8 == 0 { num_bytes } else { num_bytes + 1 }
}

fn modulus() -> BigUint {
Expand Down
4 changes: 2 additions & 2 deletions acvm-repo/acvm/src/compiler/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::collections::HashMap;

use acir::{
circuit::{AssertionPayload, Circuit, ExpressionWidth, OpcodeLocation},
AcirField,
circuit::{AssertionPayload, Circuit, ExpressionWidth, OpcodeLocation},
};

// The various passes that we can use over ACIR
Expand All @@ -14,7 +14,7 @@ pub use optimizers::optimize;
use optimizers::optimize_internal;
pub use simulator::CircuitSimulator;
use transformers::transform_internal;
pub use transformers::{transform, MIN_EXPRESSION_WIDTH};
pub use transformers::{MIN_EXPRESSION_WIDTH, transform};

/// This module moves and decomposes acir opcodes. The transformation map allows consumers of this module to map
/// metadata they had about the opcodes to the new opcode structure generated after the transformation.
Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acvm/src/compiler/optimizers/general.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use acir::{
native_types::{Expression, Witness},
AcirField,
native_types::{Expression, Witness},
};
use indexmap::IndexMap;

Expand Down
10 changes: 5 additions & 5 deletions acvm-repo/acvm/src/compiler/optimizers/merge_expressions.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::collections::{BTreeMap, BTreeSet, HashMap};

use acir::{
AcirField,
circuit::{
Circuit, Opcode,
brillig::{BrilligInputs, BrilligOutputs},
opcodes::BlockId,
Circuit, Opcode,
},
native_types::{Expression, Witness},
AcirField,
};

use crate::compiler::CircuitSimulator;
Expand Down Expand Up @@ -258,16 +258,16 @@ impl<F: AcirField> MergeExpressionsOptimizer<F> {

#[cfg(test)]
mod tests {
use crate::compiler::{optimizers::MergeExpressionsOptimizer, CircuitSimulator};
use crate::compiler::{CircuitSimulator, optimizers::MergeExpressionsOptimizer};
use acir::{
FieldElement,
acir_field::AcirField,
circuit::{
Circuit, ExpressionWidth, Opcode, PublicInputs,
brillig::{BrilligFunctionId, BrilligOutputs},
opcodes::{BlackBoxFuncCall, FunctionInput},
Circuit, ExpressionWidth, Opcode, PublicInputs,
},
native_types::{Expression, Witness},
FieldElement,
};
use std::collections::BTreeSet;

Expand Down
4 changes: 2 additions & 2 deletions acvm-repo/acvm/src/compiler/optimizers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use acir::{
circuit::{Circuit, Opcode},
AcirField,
circuit::{Circuit, Opcode},
};

// mod constant_backpropagation;
Expand All @@ -17,7 +17,7 @@ use tracing::info;
// use self::constant_backpropagation::ConstantBackpropagationOptimizer;
use self::unused_memory::UnusedMemoryOptimizer;

use super::{transform_assert_messages, AcirTransformationMap};
use super::{AcirTransformationMap, transform_assert_messages};

/// Applies [`ProofSystemCompiler`][crate::ProofSystemCompiler] independent optimizations to a [`Circuit`].
pub fn optimize<F: AcirField>(acir: Circuit<F>) -> (Circuit<F>, AcirTransformationMap) {
Expand Down
8 changes: 4 additions & 4 deletions acvm-repo/acvm/src/compiler/optimizers/redundant_range.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use acir::{
AcirField,
circuit::{
opcodes::{BlackBoxFuncCall, ConstantOrWitnessEnum},
Circuit, Opcode,
opcodes::{BlackBoxFuncCall, ConstantOrWitnessEnum},
},
native_types::Witness,
AcirField,
};
use std::collections::{BTreeMap, HashSet};

Expand Down Expand Up @@ -163,12 +163,12 @@ mod tests {

use crate::compiler::optimizers::redundant_range::RangeOptimizer;
use acir::{
FieldElement,
circuit::{
opcodes::{BlackBoxFuncCall, FunctionInput},
Circuit, ExpressionWidth, Opcode, PublicInputs,
opcodes::{BlackBoxFuncCall, FunctionInput},
},
native_types::{Expression, Witness},
FieldElement,
};

fn test_circuit(ranges: Vec<(Witness, u32)>) -> Circuit<FieldElement> {
Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acvm/src/compiler/optimizers/unused_memory.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use acir::circuit::{brillig::BrilligInputs, opcodes::BlockId, Circuit, Opcode};
use acir::circuit::{Circuit, Opcode, brillig::BrilligInputs, opcodes::BlockId};
use std::collections::HashSet;

/// `UnusedMemoryOptimizer` will remove initializations of memory blocks which are unused.
Expand Down
6 changes: 3 additions & 3 deletions acvm-repo/acvm/src/compiler/simulator.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use acir::{
AcirField,
circuit::{
Circuit, Opcode,
brillig::{BrilligInputs, BrilligOutputs},
opcodes::{BlockId, FunctionInput},
Circuit, Opcode,
},
native_types::{Expression, Witness},
AcirField,
};
use std::collections::{BTreeSet, HashMap, HashSet};

Expand Down Expand Up @@ -215,10 +215,10 @@ mod tests {

use crate::compiler::CircuitSimulator;
use acir::{
FieldElement,
acir_field::AcirField,
circuit::{Circuit, ExpressionWidth, Opcode, PublicInputs},
native_types::{Expression, Witness},
FieldElement,
};

fn test_circuit(
Expand Down
4 changes: 2 additions & 2 deletions acvm-repo/acvm/src/compiler/transformers/csat.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::{cmp::Ordering, collections::HashSet};

use acir::{
native_types::{Expression, Witness},
AcirField,
native_types::{Expression, Witness},
};
use indexmap::IndexMap;

Expand Down Expand Up @@ -201,7 +201,7 @@ impl CSatTransformer {

// Now we have used up 2 spaces in our assert-zero opcode. The width now dictates, how many more we can add
let mut remaining_space = self.width - 2 - 1; // We minus 1 because we need an extra space to contain the intermediate variable
// Keep adding terms until we have no more left, or we reach the width
// Keep adding terms until we have no more left, or we reach the width
let mut remaining_linear_terms =
Vec::with_capacity(opcode.linear_combinations.len());
while remaining_space > 0 {
Expand Down
8 changes: 4 additions & 4 deletions acvm-repo/acvm/src/compiler/transformers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use acir::{
AcirField,
circuit::{
self,
self, Circuit, ExpressionWidth, Opcode,
brillig::{BrilligInputs, BrilligOutputs},
opcodes::{BlackBoxFuncCall, FunctionInput, MemOp},
Circuit, ExpressionWidth, Opcode,
},
native_types::{Expression, Witness},
AcirField,
};
use indexmap::IndexMap;

Expand All @@ -17,8 +16,9 @@ pub use csat::MIN_EXPRESSION_WIDTH;
use tracing::info;

use super::{
AcirTransformationMap,
optimizers::{MergeExpressionsOptimizer, RangeOptimizer},
transform_assert_messages, AcirTransformationMap,
transform_assert_messages,
};

/// We need multiple passes to stabilize the output.
Expand Down
4 changes: 2 additions & 2 deletions acvm-repo/acvm/src/pwg/arithmetic.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use acir::{
native_types::{Expression, Witness, WitnessMap},
AcirField,
native_types::{Expression, Witness, WitnessMap},
};

use super::{insert_value, ErrorLocation, OpcodeNotSolvable, OpcodeResolutionError};
use super::{ErrorLocation, OpcodeNotSolvable, OpcodeResolutionError, insert_value};

/// An Expression solver will take a Circuit's assert-zero opcodes with witness assignments
/// and create the other witness variables
Expand Down
4 changes: 2 additions & 2 deletions acvm-repo/acvm/src/pwg/blackbox/aes128.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use acir::{
AcirField,
circuit::opcodes::FunctionInput,
native_types::{Witness, WitnessMap},
AcirField,
};
use acvm_blackbox_solver::aes128_encrypt;

use crate::{pwg::insert_value, OpcodeResolutionError};
use crate::{OpcodeResolutionError, pwg::insert_value};

use super::utils::{to_u8_array, to_u8_vec};

Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acvm/src/pwg/blackbox/bigint.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::pwg::input_to_value;
use acir::{
AcirField, BlackBoxFunc,
circuit::opcodes::FunctionInput,
native_types::{Witness, WitnessMap},
AcirField, BlackBoxFunc,
};
use acvm_blackbox_solver::BigIntSolver;

Expand Down
4 changes: 2 additions & 2 deletions acvm-repo/acvm/src/pwg/blackbox/embedded_curve_ops.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use acir::{
AcirField,
circuit::opcodes::FunctionInput,
native_types::{Witness, WitnessMap},
AcirField,
};
use acvm_blackbox_solver::BlackBoxFunctionSolver;

use crate::pwg::{input_to_value, insert_value, OpcodeResolutionError};
use crate::pwg::{OpcodeResolutionError, input_to_value, insert_value};

pub(super) fn multi_scalar_mul<F: AcirField>(
backend: &impl BlackBoxFunctionSolver<F>,
Expand Down
6 changes: 3 additions & 3 deletions acvm-repo/acvm/src/pwg/blackbox/hash.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use acir::{
AcirField,
circuit::opcodes::FunctionInput,
native_types::{Witness, WitnessMap},
AcirField,
};
use acvm_blackbox_solver::{sha256_compression, BlackBoxFunctionSolver, BlackBoxResolutionError};
use acvm_blackbox_solver::{BlackBoxFunctionSolver, BlackBoxResolutionError, sha256_compression};

use crate::pwg::{input_to_value, insert_value};
use crate::OpcodeResolutionError;
use crate::pwg::{input_to_value, insert_value};

/// Attempts to solve a 256 bit hash function opcode.
/// If successful, `initial_witness` will be mutated to contain the new witness assignment.
Expand Down
4 changes: 2 additions & 2 deletions acvm-repo/acvm/src/pwg/blackbox/logic.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::pwg::{input_to_value, insert_value};
use crate::OpcodeResolutionError;
use crate::pwg::{input_to_value, insert_value};
use acir::{
AcirField,
circuit::opcodes::FunctionInput,
native_types::{Witness, WitnessMap},
AcirField,
};
use acvm_blackbox_solver::{bit_and, bit_xor};

Expand Down
Loading

1 comment on commit 826b18a

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Test Suite Duration'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: 826b18a Previous: ef2302b Ratio
noir-lang_noir_json_parser_ 10 s 8 s 1.25

This comment was automatically generated by workflow using github-action-benchmark.

CC: @TomAFrench

Please sign in to comment.