Skip to content

Commit

Permalink
fix: Replace std::HashMap with FxHashMap to fix frontend indeterminism (
Browse files Browse the repository at this point in the history
#5385)

# Description

## Problem\*

Resolves frontend indeterminism

## Summary\*



## Additional Context



## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
sirasistant authored Jul 2, 2024
1 parent c8161c8 commit 9501495
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/elaborator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,7 @@ impl<'context> Elaborator<'context> {
traits: BTreeMap::new(),
trait_impls: Vec::new(),
globals: Vec::new(),
impls: std::collections::HashMap::new(),
impls: rustc_hash::FxHashMap::default(),
};

items.functions = function_sets;
Expand Down
5 changes: 3 additions & 2 deletions compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ use crate::parser::{ParserError, SortedModule};
use fm::FileId;
use iter_extended::vecmap;
use noirc_errors::{CustomDiagnostic, Span};
use std::collections::{BTreeMap, HashMap};
use rustc_hash::FxHashMap as HashMap;
use std::collections::BTreeMap;

use std::vec;

Expand Down Expand Up @@ -253,7 +254,7 @@ impl DefCollector {
types: BTreeMap::new(),
type_aliases: BTreeMap::new(),
traits: BTreeMap::new(),
impls: HashMap::new(),
impls: HashMap::default(),
globals: vec![],
trait_impls: vec![],
},
Expand Down
5 changes: 3 additions & 2 deletions compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use std::path::Path;
use std::{collections::HashMap, vec};
use std::vec;

use acvm::{AcirField, FieldElement};
use fm::{FileId, FileManager, FILE_EXTENSION};
use noirc_errors::Location;
use num_bigint::BigUint;
use num_traits::Num;
use rustc_hash::FxHashMap as HashMap;

use crate::ast::{
FunctionDefinition, Ident, ItemVisibility, LetStatement, ModuleDeclaration, NoirFunction,
Expand Down Expand Up @@ -400,7 +401,7 @@ impl<'a> ModCollector<'a> {
self_type: None,
};

let mut method_ids = HashMap::new();
let mut method_ids = HashMap::default();
for trait_item in &trait_definition.items {
match trait_item {
TraitItem::Function {
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/hir_def/traits.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::HashMap;
use rustc_hash::FxHashMap as HashMap;

use crate::ast::{Ident, NoirFunction};
use crate::{
Expand Down

0 comments on commit 9501495

Please sign in to comment.