Skip to content

Commit 8e45a5a

Browse files
authored
Use hashbrown::HashSet instead of ahash::HashSet (#12951)
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.
1 parent 61adcf9 commit 8e45a5a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

.clippy.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
disallowed-types = [
2+
"std::collections::HashSet",
3+
"std::collections::HashMap",
4+
"ahash::HashSet",
5+
"ahash::HashMap",
6+
]

crates/accelerate/src/target_transpiler/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use std::ops::Index;
2020

2121
use ahash::RandomState;
2222

23-
use ahash::HashSet;
23+
use hashbrown::HashSet;
2424
use indexmap::{IndexMap, IndexSet};
2525
use itertools::Itertools;
2626
use nullable_index_map::NullableIndexMap;

0 commit comments

Comments
 (0)