Enable potential_query_instability lint in rustc_hir_typeck.
Fix linting errors by using FxIndex(Map|Set) and Unord(Map|Set) as appropriate.
This commit is contained in:
parent
fe03b46ee4
commit
cfb310939b
15 changed files with 172 additions and 145 deletions
|
@ -31,6 +31,7 @@ use crate::{
|
|||
///
|
||||
/// It's still possible to do the same thing with an `Fn` by using interior mutability,
|
||||
/// but the chance of doing it accidentally is reduced.
|
||||
#[derive(Clone)]
|
||||
pub struct UnordItems<T, I: Iterator<Item = T>>(I);
|
||||
|
||||
impl<T, I: Iterator<Item = T>> UnordItems<T, I> {
|
||||
|
@ -194,6 +195,11 @@ impl<V: Eq + Hash> UnordSet<V> {
|
|||
Self { inner: Default::default() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn with_capacity(capacity: usize) -> Self {
|
||||
Self { inner: FxHashSet::with_capacity_and_hasher(capacity, Default::default()) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn len(&self) -> usize {
|
||||
self.inner.len()
|
||||
|
@ -258,9 +264,9 @@ impl<V: Eq + Hash> UnordSet<V> {
|
|||
#[inline]
|
||||
pub fn to_sorted_stable_ord(&self) -> Vec<V>
|
||||
where
|
||||
V: Ord + StableOrd + Copy,
|
||||
V: Ord + StableOrd + Clone,
|
||||
{
|
||||
let mut items: Vec<V> = self.inner.iter().copied().collect();
|
||||
let mut items: Vec<V> = self.inner.iter().cloned().collect();
|
||||
items.sort_unstable();
|
||||
items
|
||||
}
|
||||
|
@ -312,6 +318,12 @@ impl<V: Hash + Eq> From<FxHashSet<V>> for UnordSet<V> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<V: Hash + Eq, I: Iterator<Item = V>> From<UnordItems<V, I>> for UnordSet<V> {
|
||||
fn from(value: UnordItems<V, I>) -> Self {
|
||||
UnordSet { inner: FxHashSet::from_iter(value.0) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<HCX, V: Hash + Eq + HashStable<HCX>> HashStable<HCX> for UnordSet<V> {
|
||||
#[inline]
|
||||
fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) {
|
||||
|
@ -362,6 +374,11 @@ impl<K: Hash + Eq, V, I: Iterator<Item = (K, V)>> From<UnordItems<(K, V), I>> fo
|
|||
}
|
||||
|
||||
impl<K: Eq + Hash, V> UnordMap<K, V> {
|
||||
#[inline]
|
||||
pub fn with_capacity(capacity: usize) -> Self {
|
||||
Self { inner: FxHashMap::with_capacity_and_hasher(capacity, Default::default()) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn len(&self) -> usize {
|
||||
self.inner.len()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue