From 6e85c4e2d99c794e4a9172cd38468a098427c07f Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 13 Oct 2025 08:35:21 +1100 Subject: [PATCH] Remove some unused bitset code. --- compiler/rustc_index/src/bit_set.rs | 51 ----------------------- compiler/rustc_index/src/bit_set/tests.rs | 28 ------------- 2 files changed, 79 deletions(-) diff --git a/compiler/rustc_index/src/bit_set.rs b/compiler/rustc_index/src/bit_set.rs index 85ec302a6aa9..6f207ff20ed3 100644 --- a/compiler/rustc_index/src/bit_set.rs +++ b/compiler/rustc_index/src/bit_set.rs @@ -973,48 +973,6 @@ impl BitRelations> for ChunkedBitSet { } } -impl BitRelations> for DenseBitSet { - fn union(&mut self, other: &ChunkedBitSet) -> bool { - sequential_update(|elem| self.insert(elem), other.iter()) - } - - fn subtract(&mut self, _other: &ChunkedBitSet) -> bool { - unimplemented!("implement if/when necessary"); - } - - fn intersect(&mut self, other: &ChunkedBitSet) -> bool { - assert_eq!(self.domain_size(), other.domain_size); - let mut changed = false; - for (i, chunk) in other.chunks.iter().enumerate() { - let mut words = &mut self.words[i * CHUNK_WORDS..]; - if words.len() > CHUNK_WORDS { - words = &mut words[..CHUNK_WORDS]; - } - match chunk { - Zeros => { - for word in words { - if *word != 0 { - changed = true; - *word = 0; - } - } - } - Ones => (), - Mixed(_, data) => { - for (i, word) in words.iter_mut().enumerate() { - let new_val = *word & data[i]; - if new_val != *word { - changed = true; - *word = new_val; - } - } - } - } - } - changed - } -} - impl Clone for ChunkedBitSet { fn clone(&self) -> Self { ChunkedBitSet { @@ -1125,15 +1083,6 @@ enum ChunkIter<'a> { Finished, } -// Applies a function to mutate a bitset, and returns true if any -// of the applications return true -fn sequential_update( - mut self_update: impl FnMut(T) -> bool, - it: impl Iterator, -) -> bool { - it.fold(false, |changed, elem| self_update(elem) | changed) -} - impl fmt::Debug for ChunkedBitSet { fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result { w.debug_list().entries(self.iter()).finish() diff --git a/compiler/rustc_index/src/bit_set/tests.rs b/compiler/rustc_index/src/bit_set/tests.rs index deddc8726143..341e0622df75 100644 --- a/compiler/rustc_index/src/bit_set/tests.rs +++ b/compiler/rustc_index/src/bit_set/tests.rs @@ -306,34 +306,6 @@ fn with_elements_chunked(elements: &[usize], domain_size: usize) -> ChunkedBitSe s } -fn with_elements_standard(elements: &[usize], domain_size: usize) -> DenseBitSet { - let mut s = DenseBitSet::new_empty(domain_size); - for &e in elements { - assert!(s.insert(e)); - } - s -} - -#[test] -fn chunked_bitset_into_bitset_operations() { - let a = vec![1, 5, 7, 11, 15, 2000, 3000]; - let b = vec![3, 4, 11, 3000, 4000]; - let aub = vec![1, 3, 4, 5, 7, 11, 15, 2000, 3000, 4000]; - let aib = vec![11, 3000]; - - let b = with_elements_chunked(&b, 9876); - - let mut union = with_elements_standard(&a, 9876); - assert!(union.union(&b)); - assert!(!union.union(&b)); - assert!(union.iter().eq(aub.iter().copied())); - - let mut intersection = with_elements_standard(&a, 9876); - assert!(intersection.intersect(&b)); - assert!(!intersection.intersect(&b)); - assert!(intersection.iter().eq(aib.iter().copied())); -} - #[test] fn chunked_bitset_iter() { fn check_iter(bit: &ChunkedBitSet, vec: &Vec) {