Skip to content

Commit

Permalink
Use hashbrown::HashSet instead of ahash::HashSet (#12951)
Browse files Browse the repository at this point in the history
In the `target_transpiler/mod.rs` module we were using ahash::HashSet
for a hash set implementation, but the rest of Qiskit has standardized
on using hashbrown for the `HashSet` and `HashMap` types. Hashbrown uses
ahash for it's hashing algorithm but it also provides other advantages.
To ensure that hash sets are compatible across the library we should be
using the same library for everything. To support this goal, this commit
also adds a clippy rule that raises a warning if the std library hashmap
or hashset is used, or the versions from ahash. This means with our
current dependency set the only allowed hashset types are
`hashbrown::HashMap`/`HashSet` and `indexmap::IndexMap`/`IndexSet` (for
where we need to maintain insertion order). Ideally we'd have a rule
that forces the use of ahash with `IndexMap` and `IndexSet` (see #12935)
but I don't think clippy exposes an option to enable something like that.
  • Loading branch information
mtreinish authored Aug 13, 2024
1 parent 61adcf9 commit 8e45a5a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
disallowed-types = [
"std::collections::HashSet",
"std::collections::HashMap",
"ahash::HashSet",
"ahash::HashMap",
]
2 changes: 1 addition & 1 deletion crates/accelerate/src/target_transpiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::ops::Index;

use ahash::RandomState;

use ahash::HashSet;
use hashbrown::HashSet;
use indexmap::{IndexMap, IndexSet};
use itertools::Itertools;
use nullable_index_map::NullableIndexMap;
Expand Down

0 comments on commit 8e45a5a

Please sign in to comment.