diff --git a/src/librustc_data_structures/indexed_set.rs b/src/librustc_data_structures/indexed_set.rs index a7672d1ffe8..6c64e5de378 100644 --- a/src/librustc_data_structures/indexed_set.rs +++ b/src/librustc_data_structures/indexed_set.rs @@ -9,20 +9,18 @@ // except according to those terms. use array_vec::ArrayVec; -use std::borrow::{Borrow, BorrowMut, ToOwned}; use std::fmt; use std::iter; use std::marker::PhantomData; use std::mem; -use std::ops::{Deref, DerefMut, Range}; use std::slice; use bitslice::{BitSlice, Word}; use bitslice::{bitwise, Union, Subtract, Intersect}; use indexed_vec::Idx; use rustc_serialize; -/// Represents a set (or packed family of sets), of some element type -/// E, where each E is identified by some unique index type `T`. +/// Represents a set of some element type E, where each E is identified by some +/// unique index type `T`. /// /// In other words, `T` is the type used to index into the bitvector /// this type uses to represent the set of object it holds. @@ -34,6 +32,9 @@ pub struct IdxSetBuf { bits: Vec, } +// FIXME: temporary +pub type IdxSet = IdxSetBuf; + impl Clone for IdxSetBuf { fn clone(&self) -> Self { IdxSetBuf { _pd: PhantomData, bits: self.bits.clone() } @@ -59,40 +60,6 @@ impl rustc_serialize::Decodable for IdxSetBuf { } } - -// pnkfelix wants to have this be `IdxSet([Word]) and then pass -// around `&mut IdxSet` or `&IdxSet`. - -/// Represents a set (or packed family of sets), of some element type -/// E, where each E is identified by some unique index type `T`. -/// -/// In other words, `T` is the type used to index into the bitslice -/// this type uses to represent the set of object it holds. -#[repr(transparent)] -pub struct IdxSet { - _pd: PhantomData, - bits: [Word], -} - -impl Borrow> for IdxSetBuf { - fn borrow(&self) -> &IdxSet { - &*self - } -} - -impl BorrowMut> for IdxSetBuf { - fn borrow_mut(&mut self) -> &mut IdxSet { - &mut *self - } -} - -impl ToOwned for IdxSet { - type Owned = IdxSetBuf; - fn to_owned(&self) -> Self::Owned { - IdxSet::to_owned(self) - } -} - const BITS_PER_WORD: usize = mem::size_of::() * 8; impl fmt::Debug for IdxSetBuf { @@ -103,14 +70,6 @@ impl fmt::Debug for IdxSetBuf { } } -impl fmt::Debug for IdxSet { - fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { - w.debug_list() - .entries(self.iter()) - .finish() - } -} - impl IdxSetBuf { fn new(init: Word, universe_size: usize) -> Self { let num_words = (universe_size + (BITS_PER_WORD - 1)) / BITS_PER_WORD; @@ -131,38 +90,6 @@ impl IdxSetBuf { pub fn new_empty(universe_size: usize) -> Self { Self::new(0, universe_size) } -} - -impl IdxSet { - unsafe fn from_slice(s: &[Word]) -> &Self { - &*(s as *const [Word] as *const Self) - } - - unsafe fn from_slice_mut(s: &mut [Word]) -> &mut Self { - &mut *(s as *mut [Word] as *mut Self) - } -} - -impl Deref for IdxSetBuf { - type Target = IdxSet; - fn deref(&self) -> &IdxSet { - unsafe { IdxSet::from_slice(&self.bits) } - } -} - -impl DerefMut for IdxSetBuf { - fn deref_mut(&mut self) -> &mut IdxSet { - unsafe { IdxSet::from_slice_mut(&mut self.bits) } - } -} - -impl IdxSet { - pub fn to_owned(&self) -> IdxSetBuf { - IdxSetBuf { - _pd: Default::default(), - bits: self.bits.to_owned(), - } - } /// Duplicates as a hybrid set. pub fn to_hybrid(&self) -> HybridIdxSetBuf { @@ -219,16 +146,6 @@ impl IdxSet { self.bits.set_bit(elem.index()) } - pub fn range(&self, elems: &Range) -> &Self { - let elems = elems.start.index()..elems.end.index(); - unsafe { Self::from_slice(&self.bits[elems]) } - } - - pub fn range_mut(&mut self, elems: &Range) -> &mut Self { - let elems = elems.start.index()..elems.end.index(); - unsafe { Self::from_slice_mut(&mut self.bits[elems]) } - } - /// Returns true iff set `self` contains `elem`. pub fn contains(&self, elem: &T) -> bool { self.bits.get_bit(elem.index())