diff options
| author | Michael Woerister <michaelwoerister@posteo> | 2022-07-08 18:06:18 +0200 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@posteo> | 2022-07-20 13:11:39 +0200 |
| commit | 88f6c6d8a0245938f9f49e8b088114d6862e793d (patch) | |
| tree | b7fe1673ec1dd989ffe2368d494f1e87a3102888 /compiler/rustc_data_structures | |
| parent | b8138db0ffbb7d29e5af2482c6eb0ef4e117d4a3 (diff) | |
| download | rust-88f6c6d8a0245938f9f49e8b088114d6862e793d.tar.gz rust-88f6c6d8a0245938f9f49e8b088114d6862e793d.zip | |
Remove unused StableMap and StableSet types from rustc_data_structures
Diffstat (limited to 'compiler/rustc_data_structures')
| -rw-r--r-- | compiler/rustc_data_structures/src/lib.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_data_structures/src/stable_map.rs | 100 | ||||
| -rw-r--r-- | compiler/rustc_data_structures/src/stable_set.rs | 77 |
3 files changed, 0 insertions, 179 deletions
diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index 0a2d2b40709..265f45b72d1 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -61,12 +61,10 @@ pub mod sip128; pub mod small_c_str; pub mod small_str; pub mod snapshot_map; -pub mod stable_map; pub mod svh; pub use ena::snapshot_vec; pub mod memmap; pub mod sorted_map; -pub mod stable_set; #[macro_use] pub mod stable_hasher; mod atomic_ref; diff --git a/compiler/rustc_data_structures/src/stable_map.rs b/compiler/rustc_data_structures/src/stable_map.rs deleted file mode 100644 index 670452d0d8c..00000000000 --- a/compiler/rustc_data_structures/src/stable_map.rs +++ /dev/null @@ -1,100 +0,0 @@ -pub use rustc_hash::FxHashMap; -use std::borrow::Borrow; -use std::collections::hash_map::Entry; -use std::fmt; -use std::hash::Hash; - -/// A deterministic wrapper around FxHashMap that does not provide iteration support. -/// -/// It supports insert, remove, get and get_mut functions from FxHashMap. -/// It also allows to convert hashmap to a sorted vector with the method `into_sorted_vector()`. -#[derive(Clone)] -pub struct StableMap<K, V> { - base: FxHashMap<K, V>, -} - -impl<K, V> Default for StableMap<K, V> -where - K: Eq + Hash, -{ - fn default() -> StableMap<K, V> { - StableMap::new() - } -} - -impl<K, V> fmt::Debug for StableMap<K, V> -where - K: Eq + Hash + fmt::Debug, - V: fmt::Debug, -{ - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{:?}", self.base) - } -} - -impl<K, V> PartialEq for StableMap<K, V> -where - K: Eq + Hash, - V: PartialEq, -{ - fn eq(&self, other: &StableMap<K, V>) -> bool { - self.base == other.base - } -} - -impl<K, V> Eq for StableMap<K, V> -where - K: Eq + Hash, - V: Eq, -{ -} - -impl<K, V> StableMap<K, V> -where - K: Eq + Hash, -{ - pub fn new() -> StableMap<K, V> { - StableMap { base: FxHashMap::default() } - } - - pub fn into_sorted_vector(self) -> Vec<(K, V)> - where - K: Ord + Copy, - { - let mut vector = self.base.into_iter().collect::<Vec<_>>(); - vector.sort_unstable_by_key(|pair| pair.0); - vector - } - - pub fn entry(&mut self, k: K) -> Entry<'_, K, V> { - self.base.entry(k) - } - - pub fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V> - where - K: Borrow<Q>, - Q: Hash + Eq, - { - self.base.get(k) - } - - pub fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut V> - where - K: Borrow<Q>, - Q: Hash + Eq, - { - self.base.get_mut(k) - } - - pub fn insert(&mut self, k: K, v: V) -> Option<V> { - self.base.insert(k, v) - } - - pub fn remove<Q: ?Sized>(&mut self, k: &Q) -> Option<V> - where - K: Borrow<Q>, - Q: Hash + Eq, - { - self.base.remove(k) - } -} diff --git a/compiler/rustc_data_structures/src/stable_set.rs b/compiler/rustc_data_structures/src/stable_set.rs deleted file mode 100644 index c7ca74f5fbd..00000000000 --- a/compiler/rustc_data_structures/src/stable_set.rs +++ /dev/null @@ -1,77 +0,0 @@ -pub use rustc_hash::FxHashSet; -use std::borrow::Borrow; -use std::fmt; -use std::hash::Hash; - -/// A deterministic wrapper around FxHashSet that does not provide iteration support. -/// -/// It supports insert, remove, get functions from FxHashSet. -/// It also allows to convert hashset to a sorted vector with the method `into_sorted_vector()`. -#[derive(Clone)] -pub struct StableSet<T> { - base: FxHashSet<T>, -} - -impl<T> Default for StableSet<T> -where - T: Eq + Hash, -{ - fn default() -> StableSet<T> { - StableSet::new() - } -} - -impl<T> fmt::Debug for StableSet<T> -where - T: Eq + Hash + fmt::Debug, -{ - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{:?}", self.base) - } -} - -impl<T> PartialEq<StableSet<T>> for StableSet<T> -where - T: Eq + Hash, -{ - fn eq(&self, other: &StableSet<T>) -> bool { - self.base == other.base - } -} - -impl<T> Eq for StableSet<T> where T: Eq + Hash {} - -impl<T: Hash + Eq> StableSet<T> { - pub fn new() -> StableSet<T> { - StableSet { base: FxHashSet::default() } - } - - pub fn into_sorted_vector(self) -> Vec<T> - where - T: Ord, - { - let mut vector = self.base.into_iter().collect::<Vec<_>>(); - vector.sort_unstable(); - vector - } - - pub fn get<Q: ?Sized>(&self, value: &Q) -> Option<&T> - where - T: Borrow<Q>, - Q: Hash + Eq, - { - self.base.get(value) - } - - pub fn insert(&mut self, value: T) -> bool { - self.base.insert(value) - } - - pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool - where - T: Borrow<Q>, - Q: Hash + Eq, - { - self.base.remove(value) - } -} |
