diff --git a/Cargo.lock b/Cargo.lock index 179b37ac389..9dc0f6e0e25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,7 +14,6 @@ dependencies = [ "color-eyre", "criterion", "flate2", - "fxhash", "insta", "noir_protobuf", "noirc_errors", @@ -30,6 +29,7 @@ dependencies = [ "regex", "rmp-serde", "rmpv", + "rustc-hash", "serde", "serde-big-array", "serde-generate", @@ -71,11 +71,11 @@ dependencies = [ "bn254_blackbox_solver", "brillig_vm", "criterion", - "fxhash", "indexmap 2.11.0", "num-bigint", "pprof", "proptest", + "rustc-hash", "serde", "thiserror 1.0.69", "tracing", @@ -1990,15 +1990,6 @@ dependencies = [ "thread_local", ] -[[package]] -name = "fxhash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" -dependencies = [ - "byteorder", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -3222,7 +3213,6 @@ dependencies = [ "dirs", "fm", "fs2", - "fxhash", "iai", "insta", "iter-extended", @@ -3252,6 +3242,7 @@ dependencies = [ "proptest", "rayon", "regex", + "rustc-hash", "serde", "serde_json", "sha2", @@ -3514,7 +3505,6 @@ dependencies = [ "convert_case", "fm", "fuzzy-matcher", - "fxhash", "iter-extended", "nargo", "nargo_expand", @@ -3525,6 +3515,7 @@ dependencies = [ "noirc_frontend", "num-bigint", "rayon", + "rustc-hash", "serde", "serde_json", "strum", @@ -3544,7 +3535,6 @@ dependencies = [ "color-eyre", "const_format", "fm", - "fxhash", "im", "inferno", "nargo", @@ -3554,6 +3544,7 @@ dependencies = [ "noirc_driver", "noirc_errors", "noirc_evaluator", + "rustc-hash", "serde", "serde_json", "tempfile", @@ -3705,13 +3696,13 @@ dependencies = [ "build-data", "clap", "fm", - "fxhash", "iter-extended", "noirc_abi", "noirc_errors", "noirc_evaluator", "noirc_frontend", "rust-embed", + "rustc-hash", "serde", "tracing", ] @@ -3726,8 +3717,8 @@ dependencies = [ "codespan-reporting", "flate2", "fm", - "fxhash", "noirc_printable_type", + "rustc-hash", "serde", "serde_json", "tracing", @@ -3742,7 +3733,6 @@ dependencies = [ "cfg-if", "chrono", "fm", - "fxhash", "im", "indexmap 2.11.0", "insta", @@ -3756,6 +3746,7 @@ dependencies = [ "petgraph 0.8.2", "proptest", "rayon", + "rustc-hash", "serde", "serde_json", "serde_with", @@ -3777,7 +3768,6 @@ dependencies = [ "bn254_blackbox_solver", "cfg-if", "fm", - "fxhash", "im", "insta", "iter-extended", diff --git a/Cargo.toml b/Cargo.toml index b312ff2fdf3..75fdd1697fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -184,7 +184,7 @@ thiserror = "1.0.21" toml = "0.7.2" url = "2.5.4" base64 = "^0.22.1" -fxhash = "0.2.1" +rustc-hash = "2.1.1" build-data = "^0.3.3" bincode = { version = "^2.0.1", features = ["serde"] } hex = "0.4.2" diff --git a/acvm-repo/acir/Cargo.toml b/acvm-repo/acir/Cargo.toml index 7094d67a693..59b72e4dc8c 100644 --- a/acvm-repo/acir/Cargo.toml +++ b/acvm-repo/acir/Cargo.toml @@ -44,7 +44,7 @@ protoc-bin-vendored.workspace = true serde_json = "1.0" serde-reflection = "0.3.6" serde-generate = "0.25.1" -fxhash.workspace = true +rustc-hash.workspace = true criterion.workspace = true pprof.workspace = true num-bigint.workspace = true diff --git a/acvm-repo/acir/src/lib.rs b/acvm-repo/acir/src/lib.rs index 9f714f408d3..22a4dd60785 100644 --- a/acvm-repo/acir/src/lib.rs +++ b/acvm-repo/acir/src/lib.rs @@ -36,6 +36,7 @@ mod reflection { use std::{ collections::BTreeMap, fs::File, + hash::BuildHasher, io::Write, path::{Path, PathBuf}, }; @@ -145,7 +146,7 @@ mod reflection { let old_hash = if path.is_file() { let old_source = std::fs::read(path).expect("failed to read existing code"); let old_source = String::from_utf8(old_source).expect("old source not UTF-8"); - Some(fxhash::hash64(&old_source)) + Some(rustc_hash::FxBuildHasher.hash_one(&old_source)) } else { None }; @@ -168,7 +169,7 @@ mod reflection { if !should_overwrite() { if let Some(old_hash) = old_hash { - let new_hash = fxhash::hash64(&source); + let new_hash = rustc_hash::FxBuildHasher.hash_one(&source); assert_eq!(new_hash, old_hash, "Serialization format has changed",); } } diff --git a/acvm-repo/acvm/Cargo.toml b/acvm-repo/acvm/Cargo.toml index 5f59a273309..e45f8ed9bb3 100644 --- a/acvm-repo/acvm/Cargo.toml +++ b/acvm-repo/acvm/Cargo.toml @@ -17,7 +17,7 @@ workspace = true thiserror.workspace = true tracing.workspace = true serde.workspace = true -fxhash.workspace = true +rustc-hash.workspace = true acir.workspace = true brillig_vm.workspace = true acvm_blackbox_solver.workspace = true diff --git a/acvm-repo/acvm/src/compiler/transformers/mod.rs b/acvm-repo/acvm/src/compiler/transformers/mod.rs index 66602dc94a0..8eaae7bb232 100644 --- a/acvm-repo/acvm/src/compiler/transformers/mod.rs +++ b/acvm-repo/acvm/src/compiler/transformers/mod.rs @@ -15,6 +15,7 @@ mod csat; pub(crate) use csat::CSatTransformer; pub use csat::MIN_EXPRESSION_WIDTH; +use std::hash::BuildHasher; use tracing::info; use super::{ @@ -65,7 +66,7 @@ pub(super) fn transform_internal( } // Allow multiple passes until we have stable output. - let mut prev_opcodes_hash = fxhash::hash64(&acir.opcodes); + let mut prev_opcodes_hash = rustc_hash::FxBuildHasher.hash_one(&acir.opcodes); // For most test programs it would be enough to loop here, but some of them // don't stabilize unless we also repeat the backend agnostic optimizations. @@ -81,7 +82,7 @@ pub(super) fn transform_internal( acir = new_acir; acir_opcode_positions = new_acir_opcode_positions; - let new_opcodes_hash = fxhash::hash64(&acir.opcodes); + let new_opcodes_hash = rustc_hash::FxBuildHasher.hash_one(&acir.opcodes); if new_opcodes_hash == prev_opcodes_hash { break; diff --git a/compiler/noirc_driver/Cargo.toml b/compiler/noirc_driver/Cargo.toml index 6a902ec20b8..dab0a3e207b 100644 --- a/compiler/noirc_driver/Cargo.toml +++ b/compiler/noirc_driver/Cargo.toml @@ -24,7 +24,7 @@ acvm.workspace = true iter-extended.workspace = true fm.workspace = true serde.workspace = true -fxhash.workspace = true +rustc-hash.workspace = true rust-embed.workspace = true tracing.workspace = true diff --git a/compiler/noirc_driver/src/lib.rs b/compiler/noirc_driver/src/lib.rs index e8a7622c99c..17a91ddfea1 100644 --- a/compiler/noirc_driver/src/lib.rs +++ b/compiler/noirc_driver/src/lib.rs @@ -1,6 +1,8 @@ #![forbid(unsafe_code)] #![warn(unused_crate_dependencies, unused_extern_crates)] +use std::hash::BuildHasher; + use abi_gen::{abi_type_from_hir_type, value_from_hir_expression}; use acvm::acir::circuit::ExpressionWidth; use acvm::compiler::MIN_EXPRESSION_WIDTH; @@ -798,7 +800,7 @@ pub fn compile_no_check( || options.minimal_ssa; // Hash the AST program, which is going to be used to fingerprint the compilation artifact. - let hash = fxhash::hash64(&program); + let hash = rustc_hash::FxBuildHasher.hash_one(&program); if let Some(cached_program) = cached_program { if !force_compile && cached_program.hash == hash { diff --git a/compiler/noirc_errors/Cargo.toml b/compiler/noirc_errors/Cargo.toml index e91d85ddafa..aa2868d4ed8 100644 --- a/compiler/noirc_errors/Cargo.toml +++ b/compiler/noirc_errors/Cargo.toml @@ -16,7 +16,7 @@ acvm.workspace = true codespan-reporting.workspace = true codespan.workspace = true fm.workspace = true -fxhash.workspace = true +rustc-hash.workspace = true noirc_printable_type.workspace = true serde.workspace = true tracing.workspace = true diff --git a/compiler/noirc_errors/src/call_stack.rs b/compiler/noirc_errors/src/call_stack.rs index ae52fc1c65f..c982cae6686 100644 --- a/compiler/noirc_errors/src/call_stack.rs +++ b/compiler/noirc_errors/src/call_stack.rs @@ -1,5 +1,6 @@ -use fxhash::FxHashMap; +use rustc_hash::FxHashMap; use serde::{Deserialize, Serialize}; +use std::hash::BuildHasher; use crate::Location; @@ -103,14 +104,14 @@ impl CallStackHelper { /// Adds a location to the call stack pub fn add_child(&mut self, call_stack: CallStackId, location: Location) -> CallStackId { - let key = fxhash::hash64(&location); + let key = rustc_hash::FxBuildHasher.hash_one(location); if let Some(result) = self.locations[call_stack.index()].children_hash.get(&key) { if self.locations[result.index()].value == location { return *result; } } let new_location = LocationNode::new(Some(call_stack), location); - let key = fxhash::hash64(&new_location.value); + let key = rustc_hash::FxBuildHasher.hash_one(new_location.value); self.locations.push(new_location); let new_location_id = CallStackId::new(self.locations.len() - 1); diff --git a/compiler/noirc_evaluator/Cargo.toml b/compiler/noirc_evaluator/Cargo.toml index aa084a77b6b..08f1570e599 100644 --- a/compiler/noirc_evaluator/Cargo.toml +++ b/compiler/noirc_evaluator/Cargo.toml @@ -16,7 +16,7 @@ noirc_frontend.workspace = true noirc_errors.workspace = true acvm.workspace = true bn254_blackbox_solver.workspace = true -fxhash.workspace = true +rustc-hash.workspace = true iter-extended.workspace = true thiserror.workspace = true noirc_printable_type.workspace = true diff --git a/compiler/noirc_evaluator/src/acir/acir_context/mod.rs b/compiler/noirc_evaluator/src/acir/acir_context/mod.rs index a4eaf6bfd91..97f65bd941a 100644 --- a/compiler/noirc_evaluator/src/acir/acir_context/mod.rs +++ b/compiler/noirc_evaluator/src/acir/acir_context/mod.rs @@ -19,11 +19,11 @@ use acvm::{ native_types::{Expression, Witness}, }, }; -use fxhash::FxHashMap as HashMap; use iter_extended::{try_vecmap, vecmap}; use noirc_errors::call_stack::{CallStack, CallStackHelper}; use num_bigint::BigUint; use num_integer::Integer; +use rustc_hash::FxHashMap as HashMap; use std::{borrow::Cow, cmp::Ordering}; use crate::ssa::ir::{instruction::Endian, types::NumericType}; diff --git a/compiler/noirc_evaluator/src/acir/mod.rs b/compiler/noirc_evaluator/src/acir/mod.rs index 912055031c1..4ba4d3d2bb6 100644 --- a/compiler/noirc_evaluator/src/acir/mod.rs +++ b/compiler/noirc_evaluator/src/acir/mod.rs @@ -6,8 +6,8 @@ //! ACIR generation is performed by calling the [Ssa::into_acir] method, providing any necessary brillig bytecode. //! The compiled program will be returned as an [`Artifacts`] type. -use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; use noirc_errors::call_stack::CallStack; +use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; use std::collections::BTreeMap; use types::{AcirDynamicArray, AcirValue}; diff --git a/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs b/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs index 3d7fd375d50..02cbe9a92a4 100644 --- a/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs +++ b/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs @@ -21,10 +21,10 @@ use crate::ssa::ir::{ }; use acvm::acir::brillig::{MemoryAddress, ValueOrArray}; use acvm::{FieldElement, acir::AcirField}; -use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; use iter_extended::vecmap; use noirc_errors::call_stack::{CallStackHelper, CallStackId}; use num_bigint::BigUint; +use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; use std::collections::BTreeSet; use std::sync::Arc; diff --git a/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block_variables.rs b/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block_variables.rs index 1cc72821026..ca3966e7269 100644 --- a/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block_variables.rs +++ b/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block_variables.rs @@ -11,7 +11,7 @@ //! - Cached for reuse to avoid redundant register allocation. //! - Deallocated explicitly when no longer needed (as determined by SSA liveness). use acvm::FieldElement; -use fxhash::FxHashSet as HashSet; +use rustc_hash::FxHashSet as HashSet; use crate::{ brillig::brillig_ir::{ diff --git a/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_fn.rs b/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_fn.rs index f4b0869fd76..49b51fca97d 100644 --- a/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_fn.rs +++ b/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_fn.rs @@ -14,7 +14,7 @@ use crate::{ value::ValueId, }, }; -use fxhash::FxHashMap as HashMap; +use rustc_hash::FxHashMap as HashMap; use super::{constant_allocation::ConstantAllocation, variable_liveness::VariableLiveness}; diff --git a/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_globals.rs b/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_globals.rs index 759baab49ac..cc5eef7dcb2 100644 --- a/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_globals.rs +++ b/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_globals.rs @@ -2,7 +2,7 @@ use std::collections::{BTreeMap, BTreeSet}; use acvm::FieldElement; -use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; +use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; use super::brillig_block::BrilligBlock; use super::{BrilligVariable, Function, FunctionContext, ValueId}; diff --git a/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_slice_ops.rs b/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_slice_ops.rs index 81cb7694322..a8747812504 100644 --- a/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_slice_ops.rs +++ b/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_slice_ops.rs @@ -172,8 +172,8 @@ mod tests { use std::vec; use acvm::FieldElement; - use fxhash::FxHashMap as HashMap; use noirc_frontend::monomorphization::ast::InlineType; + use rustc_hash::FxHashMap as HashMap; use crate::brillig::ValueId; use crate::brillig::brillig_gen::brillig_block::BrilligBlock; diff --git a/compiler/noirc_evaluator/src/brillig/brillig_gen/variable_liveness.rs b/compiler/noirc_evaluator/src/brillig/brillig_gen/variable_liveness.rs index a8f1a01b9eb..aadf294271e 100644 --- a/compiler/noirc_evaluator/src/brillig/brillig_gen/variable_liveness.rs +++ b/compiler/noirc_evaluator/src/brillig/brillig_gen/variable_liveness.rs @@ -12,7 +12,7 @@ use crate::ssa::ir::{ value::{Value, ValueId}, }; -use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; +use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; use super::constant_allocation::ConstantAllocation; @@ -330,8 +330,8 @@ impl VariableLiveness { #[cfg(test)] mod test { - use fxhash::FxHashSet; use noirc_frontend::monomorphization::ast::InlineType; + use rustc_hash::FxHashSet; use crate::brillig::brillig_gen::constant_allocation::ConstantAllocation; use crate::brillig::brillig_gen::variable_liveness::VariableLiveness; diff --git a/compiler/noirc_evaluator/src/brillig/brillig_ir/codegen_stack.rs b/compiler/noirc_evaluator/src/brillig/brillig_ir/codegen_stack.rs index 7a644e8ea98..f70128195ca 100644 --- a/compiler/noirc_evaluator/src/brillig/brillig_ir/codegen_stack.rs +++ b/compiler/noirc_evaluator/src/brillig/brillig_ir/codegen_stack.rs @@ -1,5 +1,5 @@ use acvm::{AcirField, acir::brillig::MemoryAddress}; -use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; +use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; use super::{BrilligContext, debug_show::DebugToString, registers::RegisterAllocator}; @@ -129,7 +129,7 @@ mod tests { FieldElement, acir::brillig::{MemoryAddress, Opcode}, }; - use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; + use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; use crate::{ brillig::{ diff --git a/compiler/noirc_evaluator/src/brillig/mod.rs b/compiler/noirc_evaluator/src/brillig/mod.rs index a5e9c64a1b4..f68d879abc5 100644 --- a/compiler/noirc_evaluator/src/brillig/mod.rs +++ b/compiler/noirc_evaluator/src/brillig/mod.rs @@ -30,7 +30,7 @@ use crate::ssa::{ }, ssa_gen::Ssa, }; -use fxhash::FxHashMap as HashMap; +use rustc_hash::FxHashMap as HashMap; use std::{borrow::Cow, collections::BTreeSet}; pub use self::brillig_ir::procedures::ProcedureId; diff --git a/compiler/noirc_evaluator/src/ssa/function_builder/data_bus.rs b/compiler/noirc_evaluator/src/ssa/function_builder/data_bus.rs index 1ec45b37bc6..db5065cd74d 100644 --- a/compiler/noirc_evaluator/src/ssa/function_builder/data_bus.rs +++ b/compiler/noirc_evaluator/src/ssa/function_builder/data_bus.rs @@ -7,9 +7,9 @@ use crate::ssa::ir::{ value::{ValueId, ValueMapping}, }; use acvm::FieldElement; -use fxhash::FxHashMap as HashMap; use noirc_frontend::hir_def::function::FunctionSignature; use noirc_frontend::shared::Visibility; +use rustc_hash::FxHashMap as HashMap; use serde::{Deserialize, Serialize}; use super::FunctionBuilder; diff --git a/compiler/noirc_evaluator/src/ssa/interpreter/mod.rs b/compiler/noirc_evaluator/src/ssa/interpreter/mod.rs index 2857d6ccf80..e81e409f561 100644 --- a/compiler/noirc_evaluator/src/ssa/interpreter/mod.rs +++ b/compiler/noirc_evaluator/src/ssa/interpreter/mod.rs @@ -15,9 +15,9 @@ use super::{ use crate::ssa::ir::{instruction::binary::truncate_field, printer::display_binary}; use acvm::{AcirField, FieldElement}; use errors::{InternalError, InterpreterError, MAX_UNSIGNED_BIT_SIZE}; -use fxhash::FxHashMap as HashMap; use iter_extended::{try_vecmap, vecmap}; use noirc_frontend::Shared; +use rustc_hash::FxHashMap as HashMap; use value::{ArrayValue, NumericValue, ReferenceValue}; pub mod errors; diff --git a/compiler/noirc_evaluator/src/ssa/ir/call_graph.rs b/compiler/noirc_evaluator/src/ssa/ir/call_graph.rs index 2f8942a354b..c6872fe2c95 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/call_graph.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/call_graph.rs @@ -10,12 +10,12 @@ //! and purity analysis which needs to unify the purities of all functions called within another function. use std::collections::{BTreeMap, BTreeSet}; -use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; use petgraph::{ algo::kosaraju_scc, graph::{DiGraph, NodeIndex as PetGraphIndex}, visit::{Dfs, EdgeRef, Walker}, }; +use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; use crate::ssa::ssa_gen::Ssa; diff --git a/compiler/noirc_evaluator/src/ssa/ir/cfg.rs b/compiler/noirc_evaluator/src/ssa/ir/cfg.rs index e9e1a254e52..add1da99d92 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/cfg.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/cfg.rs @@ -4,7 +4,7 @@ use super::{ basic_block::{BasicBlock, BasicBlockId}, function::Function, }; -use fxhash::FxHashMap as HashMap; +use rustc_hash::FxHashMap as HashMap; use std::collections::HashSet; /// A container for the successors and predecessors of some Block. diff --git a/compiler/noirc_evaluator/src/ssa/ir/dfg.rs b/compiler/noirc_evaluator/src/ssa/ir/dfg.rs index 1a0d640ab27..3a4aa9f65c1 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/dfg.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/dfg.rs @@ -18,9 +18,9 @@ use super::{ }; use acvm::{FieldElement, acir::AcirField}; -use fxhash::FxHashMap as HashMap; use iter_extended::vecmap; use noirc_errors::call_stack::{CallStack, CallStackHelper, CallStackId}; +use rustc_hash::FxHashMap as HashMap; use serde::{Deserialize, Serialize}; use serde_with::DisplayFromStr; use serde_with::serde_as; diff --git a/compiler/noirc_evaluator/src/ssa/ir/dfg/simplify/call.rs b/compiler/noirc_evaluator/src/ssa/ir/dfg/simplify/call.rs index 95aaf4bf578..08dee54f6fd 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/dfg/simplify/call.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/dfg/simplify/call.rs @@ -1,5 +1,5 @@ -use fxhash::FxHashMap as HashMap; use noirc_errors::call_stack::CallStackId; +use rustc_hash::FxHashMap as HashMap; use std::{collections::VecDeque, sync::Arc}; use acvm::{AcirField as _, FieldElement, acir::BlackBoxFunc}; diff --git a/compiler/noirc_evaluator/src/ssa/ir/dom.rs b/compiler/noirc_evaluator/src/ssa/ir/dom.rs index b81938b11a8..afc47e77fce 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/dom.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/dom.rs @@ -9,7 +9,7 @@ use std::cmp::Ordering; use super::{ basic_block::BasicBlockId, cfg::ControlFlowGraph, function::Function, post_order::PostOrder, }; -use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; +use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; /// Dominator tree node. We keep one of these per reachable block. #[derive(Clone, Default)] diff --git a/compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs b/compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs index df92c7bd85f..1af8ce36995 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs @@ -8,7 +8,7 @@ use super::{ instruction::{Instruction, InstructionId}, value::ValueId, }; -use fxhash::FxHashMap as HashMap; +use rustc_hash::FxHashMap as HashMap; /// The FunctionInserter can be used to help modify existing Functions /// and map old values to new values after re-inserting optimized versions diff --git a/compiler/noirc_evaluator/src/ssa/ir/instruction.rs b/compiler/noirc_evaluator/src/ssa/ir/instruction.rs index 21552862c0f..b49001c3e25 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/instruction.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/instruction.rs @@ -1,12 +1,11 @@ use noirc_errors::call_stack::CallStackId; use serde::{Deserialize, Serialize}; -use std::hash::{Hash, Hasher}; +use std::hash::{BuildHasher, Hash}; use acvm::{ AcirField, acir::{BlackBoxFunc, circuit::ErrorSelector}, }; -use fxhash::FxHasher64; use iter_extended::vecmap; use noirc_frontend::hir_def::types::Type as HirType; @@ -871,9 +870,7 @@ pub enum ErrorType { impl ErrorType { pub fn selector(&self) -> ErrorSelector { - let mut hasher = FxHasher64::default(); - self.hash(&mut hasher); - let hash = hasher.finish(); + let hash = rustc_hash::FxBuildHasher.hash_one(self); ErrorSelector::new(hash) } } diff --git a/compiler/noirc_evaluator/src/ssa/ir/value.rs b/compiler/noirc_evaluator/src/ssa/ir/value.rs index bc8fc3c4168..6f8fd3a969a 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/value.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/value.rs @@ -1,4 +1,4 @@ -use fxhash::FxHashMap as HashMap; +use rustc_hash::FxHashMap as HashMap; use std::borrow::Cow; use acvm::FieldElement; diff --git a/compiler/noirc_evaluator/src/ssa/opt/array_set.rs b/compiler/noirc_evaluator/src/ssa/opt/array_set.rs index ddc0c5c7b34..d538bf020e8 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/array_set.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/array_set.rs @@ -25,7 +25,7 @@ use crate::ssa::{ }, ssa_gen::Ssa, }; -use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; +use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; impl Ssa { /// Finds the last instruction that writes to an array and modifies it diff --git a/compiler/noirc_evaluator/src/ssa/opt/basic_conditional.rs b/compiler/noirc_evaluator/src/ssa/opt/basic_conditional.rs index 3d17441f753..016dd16ecb6 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/basic_conditional.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/basic_conditional.rs @@ -1,8 +1,8 @@ use std::collections::HashSet; use acvm::AcirField; -use fxhash::FxHashMap as HashMap; use iter_extended::vecmap; +use rustc_hash::FxHashMap as HashMap; use crate::ssa::{ Ssa, diff --git a/compiler/noirc_evaluator/src/ssa/opt/brillig_entry_points.rs b/compiler/noirc_evaluator/src/ssa/opt/brillig_entry_points.rs index 58d4553945f..4be93cb6961 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/brillig_entry_points.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/brillig_entry_points.rs @@ -64,7 +64,7 @@ use std::collections::{BTreeMap, BTreeSet}; -use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; +use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; use crate::ssa::{ Ssa, diff --git a/compiler/noirc_evaluator/src/ssa/opt/checked_to_unchecked.rs b/compiler/noirc_evaluator/src/ssa/opt/checked_to_unchecked.rs index caf5f5dd804..e527b7c4ea6 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/checked_to_unchecked.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/checked_to_unchecked.rs @@ -4,7 +4,7 @@ //! Signed checked binary operations should have already been converted to unchecked ones with //! an explicit overflow check during [`super::expand_signed_checks`]. use acvm::AcirField as _; -use fxhash::FxHashMap as HashMap; +use rustc_hash::FxHashMap as HashMap; use crate::ssa::{ ir::{ diff --git a/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs b/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs index c770623aaa6..fe32846f29b 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs @@ -37,7 +37,7 @@ use crate::ssa::{ opt::pure::Purity, ssa_gen::Ssa, }; -use fxhash::FxHashMap as HashMap; +use rustc_hash::FxHashMap as HashMap; impl Ssa { /// Performs constant folding on each instruction. diff --git a/compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs b/compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs index 8c505726251..844ed67b07f 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs @@ -51,7 +51,7 @@ use crate::ssa::{ opt::pure::Purity, ssa_gen::Ssa, }; -use fxhash::FxHashMap as HashMap; +use rustc_hash::FxHashMap as HashMap; /// Represents an 'apply' function created by this pass to dispatch higher order functions to. /// Pseudocode of an `apply` function is given below: diff --git a/compiler/noirc_evaluator/src/ssa/opt/die.rs b/compiler/noirc_evaluator/src/ssa/opt/die.rs index bf8c0977113..74c4b29ec93 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/die.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/die.rs @@ -4,9 +4,9 @@ //! DIE also tracks which block parameters are unused. //! Unused parameters are then pruned by the [prune_dead_parameters] pass. use acvm::{AcirField, FieldElement, acir::BlackBoxFunc}; -use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; use noirc_errors::call_stack::CallStackId; use rayon::iter::{IntoParallelRefMutIterator, ParallelIterator}; +use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; use crate::ssa::{ ir::{ diff --git a/compiler/noirc_evaluator/src/ssa/opt/die/prune_dead_parameters.rs b/compiler/noirc_evaluator/src/ssa/opt/die/prune_dead_parameters.rs index 83dfb8e8652..f212c4f68b8 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/die/prune_dead_parameters.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/die/prune_dead_parameters.rs @@ -39,7 +39,7 @@ //! b1(v0: Field): //! return v0 //! ``` -use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; +use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; use crate::ssa::{ ir::{ diff --git a/compiler/noirc_evaluator/src/ssa/opt/evaluate_static_assert_and_assert_constant.rs b/compiler/noirc_evaluator/src/ssa/opt/evaluate_static_assert_and_assert_constant.rs index e57ec6c9c08..6f9269c06aa 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/evaluate_static_assert_and_assert_constant.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/evaluate_static_assert_and_assert_constant.rs @@ -11,9 +11,9 @@ //! since we must go through every instruction to find all references to `assert_constant` //! while loop unrolling only touches blocks with loops in them. use acvm::{FieldElement, acir::brillig::ForeignCallParam}; -use fxhash::FxHashSet as HashSet; use iter_extended::vecmap; use noirc_printable_type::{PrintableValueDisplay, TryFromParamsError}; +use rustc_hash::FxHashSet as HashSet; use crate::{ errors::RuntimeError, diff --git a/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs b/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs index b3554e86784..f55d4d05b54 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs @@ -141,7 +141,7 @@ //! ``` use std::sync::Arc; -use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; +use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; use acvm::{FieldElement, acir::AcirField, acir::BlackBoxFunc}; use indexmap::set::IndexSet; diff --git a/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg/branch_analysis.rs b/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg/branch_analysis.rs index 0a87bd75fcc..afb9281a7b9 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg/branch_analysis.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg/branch_analysis.rs @@ -41,7 +41,7 @@ use std::collections::HashSet; use crate::ssa::ir::{basic_block::BasicBlockId, cfg::ControlFlowGraph, function::Function}; -use fxhash::FxHashMap as HashMap; +use rustc_hash::FxHashMap as HashMap; /// Returns a `HashMap` mapping blocks that start a branch (i.e. blocks terminated with jmpif) to /// their corresponding blocks that end the branch. diff --git a/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg/value_merger.rs b/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg/value_merger.rs index 49bdf152a65..8467ff823e5 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg/value_merger.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/flatten_cfg/value_merger.rs @@ -1,6 +1,6 @@ use acvm::{FieldElement, acir::AcirField}; -use fxhash::FxHashMap as HashMap; use noirc_errors::call_stack::CallStackId; +use rustc_hash::FxHashMap as HashMap; use crate::{ errors::{RtResult, RuntimeError}, diff --git a/compiler/noirc_evaluator/src/ssa/opt/inlining/inline_info.rs b/compiler/noirc_evaluator/src/ssa/opt/inlining/inline_info.rs index 1ff65b30eba..2888f101def 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/inlining/inline_info.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/inlining/inline_info.rs @@ -1,8 +1,8 @@ use std::collections::{BTreeMap, VecDeque}; -use fxhash::FxHashSet as HashSet; use im::HashMap; use petgraph::graph::NodeIndex as PetGraphIndex; +use rustc_hash::FxHashSet as HashSet; use crate::ssa::{ ir::{ diff --git a/compiler/noirc_evaluator/src/ssa/opt/loop_invariant.rs b/compiler/noirc_evaluator/src/ssa/opt/loop_invariant.rs index 826b21c8fb8..f78794ab8ed 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/loop_invariant.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/loop_invariant.rs @@ -103,7 +103,7 @@ use crate::ssa::{ opt::pure::Purity, }; use acvm::{FieldElement, acir::AcirField}; -use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; +use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; use super::unrolling::{Loop, Loops}; diff --git a/compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs b/compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs index d123dfdaecc..990877bc8d3 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs @@ -78,7 +78,7 @@ mod block; use std::collections::{BTreeMap, BTreeSet}; -use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; +use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; use vec_collections::VecSet; use crate::ssa::{ diff --git a/compiler/noirc_evaluator/src/ssa/opt/normalize_value_ids.rs b/compiler/noirc_evaluator/src/ssa/opt/normalize_value_ids.rs index aba4f5d1bec..cbf9c84ccf8 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/normalize_value_ids.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/normalize_value_ids.rs @@ -10,8 +10,8 @@ use crate::ssa::{ }, ssa_gen::Ssa, }; -use fxhash::FxHashMap as HashMap; use iter_extended::vecmap; +use rustc_hash::FxHashMap as HashMap; impl Ssa { /// This is a debugging pass which re-inserts each instruction diff --git a/compiler/noirc_evaluator/src/ssa/opt/pure.rs b/compiler/noirc_evaluator/src/ssa/opt/pure.rs index 198415e5e45..5dbff77a70a 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/pure.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/pure.rs @@ -1,7 +1,7 @@ use std::collections::BTreeMap; use std::sync::Arc; -use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; +use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; use crate::ssa::ir::call_graph::CallGraph; use crate::ssa::{ diff --git a/compiler/noirc_evaluator/src/ssa/opt/rc.rs b/compiler/noirc_evaluator/src/ssa/opt/rc.rs index 88cc854930f..2b241a49126 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/rc.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/rc.rs @@ -1,4 +1,4 @@ -use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; +use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; use crate::ssa::{ ir::{ diff --git a/compiler/noirc_evaluator/src/ssa/opt/remove_if_else.rs b/compiler/noirc_evaluator/src/ssa/opt/remove_if_else.rs index 034c504540d..a306186ce35 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/remove_if_else.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/remove_if_else.rs @@ -92,7 +92,7 @@ use std::collections::hash_map::Entry; -use fxhash::FxHashMap as HashMap; +use rustc_hash::FxHashMap as HashMap; use crate::errors::RtResult; diff --git a/compiler/noirc_evaluator/src/ssa/opt/remove_truncate_after_range_check.rs b/compiler/noirc_evaluator/src/ssa/opt/remove_truncate_after_range_check.rs index 9f78adc1f5b..c2bc01ce74c 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/remove_truncate_after_range_check.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/remove_truncate_after_range_check.rs @@ -1,4 +1,4 @@ -use fxhash::FxHashMap as HashMap; +use rustc_hash::FxHashMap as HashMap; use crate::ssa::{ ir::{function::Function, instruction::Instruction, value::ValueId}, diff --git a/compiler/noirc_evaluator/src/ssa/opt/remove_unreachable_functions.rs b/compiler/noirc_evaluator/src/ssa/opt/remove_unreachable_functions.rs index 4e9a77488f8..d6f74c249f7 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/remove_unreachable_functions.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/remove_unreachable_functions.rs @@ -21,7 +21,7 @@ use std::collections::BTreeSet; -use fxhash::FxHashSet as HashSet; +use rustc_hash::FxHashSet as HashSet; use crate::ssa::{ ir::{ diff --git a/compiler/noirc_evaluator/src/ssa/opt/simple_optimization.rs b/compiler/noirc_evaluator/src/ssa/opt/simple_optimization.rs index adad218af09..e66a4101972 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/simple_optimization.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/simple_optimization.rs @@ -1,3 +1,5 @@ +use std::hash::BuildHasher; + use iter_extended::vecmap; use noirc_errors::call_stack::CallStackId; @@ -69,7 +71,7 @@ impl Function { for instruction_id in &instruction_ids { let instruction_id = *instruction_id; let instruction = &mut self.dfg[instruction_id]; - let orig_instruction_hash = fxhash::hash64(instruction); + let orig_instruction_hash = rustc_hash::FxBuildHasher.hash_one(&instruction); if !values_to_replace.is_empty() { instruction.replace_values(&values_to_replace); } @@ -136,7 +138,7 @@ impl SimpleOptimizationContext<'_, '_> { pub(crate) fn insert_current_instruction(&mut self) { // If the instruction changed, then there is a chance that we can (or have to) // simplify it before we insert it back into the block. - let instruction_hash = fxhash::hash64(self.instruction()); + let instruction_hash = rustc_hash::FxBuildHasher.hash_one(self.instruction()); let simplify = self.orig_instruction_hash != instruction_hash; if simplify { diff --git a/compiler/noirc_evaluator/src/ssa/opt/unrolling.rs b/compiler/noirc_evaluator/src/ssa/opt/unrolling.rs index ef8d81f8512..4d184e344a8 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/unrolling.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/unrolling.rs @@ -64,7 +64,7 @@ use crate::{ ssa_gen::Ssa, }, }; -use fxhash::FxHashMap as HashMap; +use rustc_hash::FxHashMap as HashMap; impl Ssa { /// Loop unrolling can return errors, since ACIR functions need to be fully unrolled. diff --git a/compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs b/compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs index eff550e8034..93d76933e2e 100644 --- a/compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs +++ b/compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs @@ -23,7 +23,7 @@ use crate::ssa::ir::value::ValueId; use super::GlobalsGraph; use super::value::{Tree, Value, Values}; -use fxhash::FxHashMap as HashMap; +use rustc_hash::FxHashMap as HashMap; /// The FunctionContext is the main context object for translating a /// function into SSA form during the SSA-gen pass. diff --git a/compiler/noirc_evaluator/src/ssa/ssa_gen/program.rs b/compiler/noirc_evaluator/src/ssa/ssa_gen/program.rs index c5d923e388d..312378c5157 100644 --- a/compiler/noirc_evaluator/src/ssa/ssa_gen/program.rs +++ b/compiler/noirc_evaluator/src/ssa/ssa_gen/program.rs @@ -1,8 +1,8 @@ use std::collections::BTreeMap; use acvm::acir::circuit::ErrorSelector; -use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; use iter_extended::btree_map; +use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; use serde::{Deserialize, Serialize}; use serde_with::serde_as; diff --git a/compiler/noirc_evaluator/src/ssa/validation/mod.rs b/compiler/noirc_evaluator/src/ssa/validation/mod.rs index ed2ca357510..24861291b22 100644 --- a/compiler/noirc_evaluator/src/ssa/validation/mod.rs +++ b/compiler/noirc_evaluator/src/ssa/validation/mod.rs @@ -16,7 +16,7 @@ use core::panic; use std::sync::Arc; use acvm::{AcirField, FieldElement, acir::BlackBoxFunc}; -use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; +use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; pub(crate) mod dynamic_array_indices; diff --git a/compiler/noirc_frontend/Cargo.toml b/compiler/noirc_frontend/Cargo.toml index acbdd158503..7f2222558dd 100644 --- a/compiler/noirc_frontend/Cargo.toml +++ b/compiler/noirc_frontend/Cargo.toml @@ -26,7 +26,6 @@ serde_json.workspace = true serde.workspace = true num-bigint.workspace = true num-traits.workspace = true -rustc-hash = "2.1.1" small-ord-set = "0.1.3" cfg-if.workspace = true tracing.workspace = true @@ -34,7 +33,7 @@ petgraph.workspace = true rangemap = "1.4.0" strum.workspace = true strum_macros.workspace = true -fxhash.workspace = true +rustc-hash.workspace = true [dev-dependencies] base64.workspace = true diff --git a/compiler/noirc_frontend/src/elaborator/enums.rs b/compiler/noirc_frontend/src/elaborator/enums.rs index 409c2582839..515165f6383 100644 --- a/compiler/noirc_frontend/src/elaborator/enums.rs +++ b/compiler/noirc_frontend/src/elaborator/enums.rs @@ -1,9 +1,9 @@ use std::collections::{BTreeMap, BTreeSet}; -use fxhash::FxHashMap as HashMap; use iter_extended::{btree_map, try_vecmap, vecmap}; use noirc_errors::Location; use rangemap::StepLite; +use rustc_hash::FxHashMap as HashMap; use crate::{ DataType, Kind, Shared, Type, diff --git a/compiler/noirc_frontend/src/elaborator/mod.rs b/compiler/noirc_frontend/src/elaborator/mod.rs index 81f033d92e8..1172f43a7ce 100644 --- a/compiler/noirc_frontend/src/elaborator/mod.rs +++ b/compiler/noirc_frontend/src/elaborator/mod.rs @@ -71,7 +71,6 @@ pub mod types; mod unquote; use function_context::FunctionContext; -use fxhash::FxHashMap as HashMap; use im::HashSet; use iter_extended::vecmap; use noirc_errors::{Located, Location}; @@ -81,6 +80,7 @@ pub use path_resolution::Turbofish; use path_resolution::{ PathResolution, PathResolutionItem, PathResolutionMode, PathResolutionTarget, }; +use rustc_hash::FxHashMap as HashMap; use types::bind_ordered_generics; use self::traits::check_trait_impl_method_matches_declaration; diff --git a/compiler/noirc_frontend/src/hir_def/types.rs b/compiler/noirc_frontend/src/hir_def/types.rs index 7060e8bf600..00ad673943e 100644 --- a/compiler/noirc_frontend/src/hir_def/types.rs +++ b/compiler/noirc_frontend/src/hir_def/types.rs @@ -1,7 +1,7 @@ use std::{borrow::Cow, cell::RefCell, collections::BTreeSet, rc::Rc}; -use fxhash::FxHashMap as HashMap; use im::HashSet; +use rustc_hash::FxHashMap as HashMap; #[cfg(test)] use proptest_derive::Arbitrary; diff --git a/compiler/noirc_frontend/src/monomorphization/mod.rs b/compiler/noirc_frontend/src/monomorphization/mod.rs index 8d531ecf257..1418fc9cc14 100644 --- a/compiler/noirc_frontend/src/monomorphization/mod.rs +++ b/compiler/noirc_frontend/src/monomorphization/mod.rs @@ -28,10 +28,10 @@ use crate::{ }; use acvm::{FieldElement, acir::AcirField}; use ast::{GlobalId, IdentId, While}; -use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; use iter_extended::{btree_map, try_vecmap, vecmap}; use noirc_errors::Location; use noirc_printable_type::PrintableType; +use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; use std::{ collections::{BTreeMap, VecDeque}, unreachable, diff --git a/compiler/noirc_frontend/src/ownership/last_uses.rs b/compiler/noirc_frontend/src/ownership/last_uses.rs index 9701944febf..045d79d7a2b 100644 --- a/compiler/noirc_frontend/src/ownership/last_uses.rs +++ b/compiler/noirc_frontend/src/ownership/last_uses.rs @@ -27,7 +27,7 @@ //! ownership pass such that only `.c` is cloned but it is still an area for improvement. use crate::monomorphization::ast::{self, IdentId, LocalId}; use crate::monomorphization::ast::{Expression, Function, Literal}; -use fxhash::FxHashMap as HashMap; +use rustc_hash::FxHashMap as HashMap; use super::Context; diff --git a/compiler/noirc_frontend/src/ownership/mod.rs b/compiler/noirc_frontend/src/ownership/mod.rs index 332a63ac224..0684d2578b9 100644 --- a/compiler/noirc_frontend/src/ownership/mod.rs +++ b/compiler/noirc_frontend/src/ownership/mod.rs @@ -42,7 +42,7 @@ use crate::{ }, }; -use fxhash::FxHashMap as HashMap; +use rustc_hash::FxHashMap as HashMap; mod last_uses; mod tests; diff --git a/tooling/lsp/Cargo.toml b/tooling/lsp/Cargo.toml index ccbe4b39edf..3c03077d6fd 100644 --- a/tooling/lsp/Cargo.toml +++ b/tooling/lsp/Cargo.toml @@ -30,7 +30,7 @@ async-lsp = { workspace = true, features = ["omni-trait"] } thiserror.workspace = true fm.workspace = true rayon.workspace = true -fxhash.workspace = true +rustc-hash.workspace = true iter-extended.workspace = true convert_case = "0.6.0" num-bigint.workspace = true diff --git a/tooling/lsp/src/lib.rs b/tooling/lsp/src/lib.rs index 8c08492850d..6cd9dccbf8f 100644 --- a/tooling/lsp/src/lib.rs +++ b/tooling/lsp/src/lib.rs @@ -4,6 +4,7 @@ use std::{ collections::{BTreeMap, HashMap, HashSet}, future::Future, + hash::BuildHasher, ops::{self, ControlFlow}, path::{Path, PathBuf}, pin::Pin, @@ -21,7 +22,6 @@ use async_lsp::{ router::Router, }; use fm::{FileManager, codespan_files as files}; -use fxhash::FxHashSet; use nargo::{ package::{Package, PackageType}, parse_all, @@ -42,6 +42,7 @@ use noirc_frontend::{ usage_tracker::UsageTracker, }; use rayon::prelude::*; +use rustc_hash::FxHashSet; use notifications::{ on_did_change_configuration, on_did_change_text_document, on_did_close_text_document, @@ -364,7 +365,9 @@ fn parse_diff(file_manager: &FileManager, state: &mut LspState) -> ParsedFiles { Some(( file_id, file_path.to_path_buf(), - fxhash::hash(file_manager.fetch_file(file_id).expect("file must exist")), + rustc_hash::FxBuildHasher + .hash_one(file_manager.fetch_file(file_id).expect("file must exist")) + as usize, )) } else { None diff --git a/tooling/nargo_cli/Cargo.toml b/tooling/nargo_cli/Cargo.toml index ee6da9fe1fe..fc27807fceb 100644 --- a/tooling/nargo_cli/Cargo.toml +++ b/tooling/nargo_cli/Cargo.toml @@ -30,7 +30,7 @@ toml.workspace = true [dependencies] clap.workspace = true fm.workspace = true -fxhash.workspace = true +rustc-hash.workspace = true iter-extended.workspace = true # This is the only crate that really needs the RPC feature, # but enabling it here implicitly enables it for the whole diff --git a/tooling/nargo_cli/src/cli/check_cmd.rs b/tooling/nargo_cli/src/cli/check_cmd.rs index f4c0a8e260f..5b8ba34e267 100644 --- a/tooling/nargo_cli/src/cli/check_cmd.rs +++ b/tooling/nargo_cli/src/cli/check_cmd.rs @@ -1,3 +1,5 @@ +use std::hash::BuildHasher; + use crate::errors::CliError; use clap::Args; @@ -60,7 +62,7 @@ pub(crate) fn run(args: CheckCommand, workspace: Workspace) -> Result<(), CliErr continue; }; let program = monomorphize(main, &mut context.def_interner, false).unwrap(); - let hash = fxhash::hash64(&program); + let hash = rustc_hash::FxBuildHasher.hash_one(&program); println!("{}: {:x}", package.name, hash); continue; } diff --git a/tooling/nargo_cli/src/cli/compile_cmd.rs b/tooling/nargo_cli/src/cli/compile_cmd.rs index 5dfb3cecf5f..8b39208bece 100644 --- a/tooling/nargo_cli/src/cli/compile_cmd.rs +++ b/tooling/nargo_cli/src/cli/compile_cmd.rs @@ -1,3 +1,4 @@ +use std::hash::BuildHasher; use std::io::{Read, Write}; use std::path::Path; use std::time::Duration; @@ -218,7 +219,8 @@ fn compile_programs( // Hash over the entire compiled program, including any post-compile transformations. // This is used to detect whether `cached_program` is returned by `compile_program`. - let cached_hash = cached_program.as_ref().map(fxhash::hash64); + let cached_hash = + cached_program.as_ref().map(|prog| rustc_hash::FxBuildHasher.hash_one(prog)); // Compile the program, or use the cached artifacts if it matches. let (program, warnings) = compile_program( @@ -237,7 +239,7 @@ fn compile_programs( // If the compiled program is the same as the cached one, we don't apply transformations again, unless the target width has changed. // The transformations might not be idempotent, which would risk creating witnesses that don't work with earlier versions, // based on which we might have generated a verifier already. - if cached_hash == Some(fxhash::hash64(&program)) { + if cached_hash == Some(rustc_hash::FxBuildHasher.hash_one(&program)) { let width_matches = program .program .functions @@ -332,6 +334,7 @@ pub(crate) fn get_target_width( #[cfg(test)] mod tests { use std::{ + hash::BuildHasher, path::{Path, PathBuf}, str::FromStr, }; @@ -469,8 +472,9 @@ mod tests { } else { // Just compare hashes, which would just state that the program failed. // Then we can use the filter option to zoom in one one to see why. - assert!( - fxhash::hash64(&program_1) == fxhash::hash64(&program_2), + assert_eq!( + rustc_hash::FxBuildHasher.hash_one(&program_1), + rustc_hash::FxBuildHasher.hash_one(&program_2), "optimization not idempotent for test program '{}'", package.name ); diff --git a/tooling/profiler/Cargo.toml b/tooling/profiler/Cargo.toml index b61271e03ef..e97b858fc77 100644 --- a/tooling/profiler/Cargo.toml +++ b/tooling/profiler/Cargo.toml @@ -21,7 +21,7 @@ path = "src/main.rs" bn254_blackbox_solver.workspace = true color-eyre.workspace = true clap.workspace = true -fxhash.workspace = true +rustc-hash.workspace = true noirc_artifacts.workspace = true const_format.workspace = true serde.workspace = true diff --git a/tooling/profiler/src/flamegraph.rs b/tooling/profiler/src/flamegraph.rs index a1caf9446b5..84b3ffeda73 100644 --- a/tooling/profiler/src/flamegraph.rs +++ b/tooling/profiler/src/flamegraph.rs @@ -5,12 +5,12 @@ use acir::circuit::brillig::BrilligFunctionId; use acir::circuit::{AcirOpcodeLocation, OpcodeLocation}; use color_eyre::eyre; use fm::codespan_files::Files; -use fxhash::FxHashMap as HashMap; use inferno::flamegraph::{Options, TextTruncateDirection, from_lines}; use noirc_errors::Location; use noirc_errors::debug_info::DebugInfo; use noirc_errors::reporter::line_and_column_from_span; use noirc_evaluator::brillig::ProcedureId; +use rustc_hash::FxHashMap as HashMap; pub(crate) trait Sample { fn count(&self) -> usize; diff --git a/tooling/ssa_fuzzer/fuzzer/src/fuzz_lib/block_context.rs b/tooling/ssa_fuzzer/fuzzer/src/fuzz_lib/block_context.rs index 4b2b3b20631..ad62f6caa9a 100644 --- a/tooling/ssa_fuzzer/fuzzer/src/fuzz_lib/block_context.rs +++ b/tooling/ssa_fuzzer/fuzzer/src/fuzz_lib/block_context.rs @@ -1103,13 +1103,12 @@ impl BlockContext { index: Option, ) -> TypedValue { log::debug!("Finding values with type: {type_:?}"); - let values_of_such_type = self.stored_variables.get(type_); - if values_of_such_type.is_some() { + if let Some(values_of_such_type) = self.stored_variables.get(type_) { if let Some(index) = index { - let length = values_of_such_type.unwrap().len(); - return values_of_such_type.unwrap().get(index % length).cloned().unwrap(); + let length = values_of_such_type.len(); + return values_of_such_type.get(index % length).cloned().unwrap(); } else { - return values_of_such_type.unwrap().last().cloned().unwrap(); + return values_of_such_type.last().cloned().unwrap(); } } diff --git a/tooling/ssa_fuzzer/fuzzer/src/fuzz_lib/initial_witness.rs b/tooling/ssa_fuzzer/fuzzer/src/fuzz_lib/initial_witness.rs index 936c367ba49..7f3de345679 100644 --- a/tooling/ssa_fuzzer/fuzzer/src/fuzz_lib/initial_witness.rs +++ b/tooling/ssa_fuzzer/fuzzer/src/fuzz_lib/initial_witness.rs @@ -127,7 +127,8 @@ fn initialize_witness_map_internal(witness: &[WitnessValue]) -> (Vec