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.
This commit is contained in:
Matthew Treinish 2024-08-13 12:41:26 -04:00 committed by GitHub
parent 61adcf9d5f
commit 8e45a5aad1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

6
.clippy.toml Normal file
View File

@ -0,0 +1,6 @@
disallowed-types = [
"std::collections::HashSet",
"std::collections::HashMap",
"ahash::HashSet",
"ahash::HashMap",
]

View File

@ -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;