diff --git a/src/librustc/ty/query/mod.rs b/src/librustc/ty/query/mod.rs index ef22ebef9d7d4..5f7c5190159c4 100644 --- a/src/librustc/ty/query/mod.rs +++ b/src/librustc/ty/query/mod.rs @@ -49,7 +49,7 @@ use util::nodemap::{DefIdSet, DefIdMap, ItemLocalSet}; use util::common::{ErrorReported}; use util::profiling::ProfileCategory::*; -use rustc_data_structures::indexed_set::IdxSetBuf; +use rustc_data_structures::indexed_set::IdxSet; use rustc_target::spec::PanicStrategy; use rustc_data_structures::indexed_vec::IndexVec; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; @@ -208,7 +208,7 @@ define_queries! { <'tcx> /// Maps DefId's that have an associated Mir to the result /// of the MIR qualify_consts pass. The actual meaning of /// the value isn't known except to the pass itself. - [] fn mir_const_qualif: MirConstQualif(DefId) -> (u8, Lrc>), + [] fn mir_const_qualif: MirConstQualif(DefId) -> (u8, Lrc>), /// Fetch the MIR for a given def-id right after it's built - this includes /// unreachable code. diff --git a/src/librustc_data_structures/indexed_set.rs b/src/librustc_data_structures/indexed_set.rs index 6c64e5de37807..f21c898a28a34 100644 --- a/src/librustc_data_structures/indexed_set.rs +++ b/src/librustc_data_structures/indexed_set.rs @@ -27,21 +27,18 @@ use rustc_serialize; /// /// The representation is dense, using one bit per possible element. #[derive(Eq, PartialEq)] -pub struct IdxSetBuf { +pub struct IdxSet { _pd: PhantomData, bits: Vec, } -// FIXME: temporary -pub type IdxSet = IdxSetBuf; - -impl Clone for IdxSetBuf { +impl Clone for IdxSet { fn clone(&self) -> Self { - IdxSetBuf { _pd: PhantomData, bits: self.bits.clone() } + IdxSet { _pd: PhantomData, bits: self.bits.clone() } } } -impl rustc_serialize::Encodable for IdxSetBuf { +impl rustc_serialize::Encodable for IdxSet { fn encode(&self, encoder: &mut E) -> Result<(), E::Error> { @@ -49,11 +46,11 @@ impl rustc_serialize::Encodable for IdxSetBuf { } } -impl rustc_serialize::Decodable for IdxSetBuf { - fn decode(d: &mut D) -> Result, D::Error> { +impl rustc_serialize::Decodable for IdxSet { + fn decode(d: &mut D) -> Result, D::Error> { let words: Vec = rustc_serialize::Decodable::decode(d)?; - Ok(IdxSetBuf { + Ok(IdxSet { _pd: PhantomData, bits: words, }) @@ -62,7 +59,7 @@ impl rustc_serialize::Decodable for IdxSetBuf { const BITS_PER_WORD: usize = mem::size_of::() * 8; -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()) @@ -70,10 +67,10 @@ impl fmt::Debug for IdxSetBuf { } } -impl IdxSetBuf { +impl IdxSet { fn new(init: Word, universe_size: usize) -> Self { let num_words = (universe_size + (BITS_PER_WORD - 1)) / BITS_PER_WORD; - IdxSetBuf { + IdxSet { _pd: Default::default(), bits: vec![init; num_words], } @@ -92,13 +89,13 @@ impl IdxSetBuf { } /// Duplicates as a hybrid set. - pub fn to_hybrid(&self) -> HybridIdxSetBuf { + pub fn to_hybrid(&self) -> HybridIdxSet { // This universe_size may be slightly larger than the one specified // upon creation, due to rounding up to a whole word. That's ok. let universe_size = self.bits.len() * BITS_PER_WORD; // Note: we currently don't bother trying to make a Sparse set. - HybridIdxSetBuf::Dense(self.to_owned(), universe_size) + HybridIdxSet::Dense(self.to_owned(), universe_size) } /// Removes all elements @@ -171,8 +168,8 @@ impl IdxSetBuf { bitwise(self.words_mut(), other.words(), &Union) } - /// Like `union()`, but takes a `SparseIdxSetBuf` argument. - fn union_sparse(&mut self, other: &SparseIdxSetBuf) -> bool { + /// Like `union()`, but takes a `SparseIdxSet` argument. + fn union_sparse(&mut self, other: &SparseIdxSet) -> bool { let mut changed = false; for elem in other.iter() { changed |= self.add(&elem); @@ -180,11 +177,11 @@ impl IdxSetBuf { changed } - /// Like `union()`, but takes a `HybridIdxSetBuf` argument. - pub fn union_hybrid(&mut self, other: &HybridIdxSetBuf) -> bool { + /// Like `union()`, but takes a `HybridIdxSet` argument. + pub fn union_hybrid(&mut self, other: &HybridIdxSet) -> bool { match other { - HybridIdxSetBuf::Sparse(sparse, _) => self.union_sparse(sparse), - HybridIdxSetBuf::Dense(dense, _) => self.union(dense), + HybridIdxSet::Sparse(sparse, _) => self.union_sparse(sparse), + HybridIdxSet::Dense(dense, _) => self.union(dense), } } @@ -194,8 +191,8 @@ impl IdxSetBuf { bitwise(self.words_mut(), other.words(), &Subtract) } - /// Like `subtract()`, but takes a `SparseIdxSetBuf` argument. - fn subtract_sparse(&mut self, other: &SparseIdxSetBuf) -> bool { + /// Like `subtract()`, but takes a `SparseIdxSet` argument. + fn subtract_sparse(&mut self, other: &SparseIdxSet) -> bool { let mut changed = false; for elem in other.iter() { changed |= self.remove(&elem); @@ -203,11 +200,11 @@ impl IdxSetBuf { changed } - /// Like `subtract()`, but takes a `HybridIdxSetBuf` argument. - pub fn subtract_hybrid(&mut self, other: &HybridIdxSetBuf) -> bool { + /// Like `subtract()`, but takes a `HybridIdxSet` argument. + pub fn subtract_hybrid(&mut self, other: &HybridIdxSet) -> bool { match other { - HybridIdxSetBuf::Sparse(sparse, _) => self.subtract_sparse(sparse), - HybridIdxSetBuf::Dense(dense, _) => self.subtract(dense), + HybridIdxSet::Sparse(sparse, _) => self.subtract_sparse(sparse), + HybridIdxSet::Dense(dense, _) => self.subtract(dense), } } @@ -255,15 +252,15 @@ impl<'a, T: Idx> Iterator for Iter<'a, T> { const SPARSE_MAX: usize = 8; /// A sparse index set with a maximum of SPARSE_MAX elements. Used by -/// HybridIdxSetBuf; do not use directly. +/// HybridIdxSet; do not use directly. /// /// The elements are stored as an unsorted vector with no duplicates. #[derive(Clone, Debug)] -pub struct SparseIdxSetBuf(ArrayVec<[T; SPARSE_MAX]>); +pub struct SparseIdxSet(ArrayVec<[T; SPARSE_MAX]>); -impl SparseIdxSetBuf { +impl SparseIdxSet { fn new() -> Self { - SparseIdxSetBuf(ArrayVec::new()) + SparseIdxSet(ArrayVec::new()) } fn len(&self) -> usize { @@ -296,8 +293,8 @@ impl SparseIdxSetBuf { } } - fn to_dense(&self, universe_size: usize) -> IdxSetBuf { - let mut dense = IdxSetBuf::new_empty(universe_size); + fn to_dense(&self, universe_size: usize) -> IdxSet { + let mut dense = IdxSet::new_empty(universe_size); for elem in self.0.iter() { dense.add(elem); } @@ -323,72 +320,72 @@ impl<'a, T: Idx> Iterator for SparseIter<'a, T> { } } -/// Like IdxSetBuf, but with a hybrid representation: sparse when there are few +/// Like IdxSet, but with a hybrid representation: sparse when there are few /// elements in the set, but dense when there are many. It's especially /// efficient for sets that typically have a small number of elements, but a /// large `universe_size`, and are cleared frequently. #[derive(Clone, Debug)] -pub enum HybridIdxSetBuf { - Sparse(SparseIdxSetBuf, usize), - Dense(IdxSetBuf, usize), +pub enum HybridIdxSet { + Sparse(SparseIdxSet, usize), + Dense(IdxSet, usize), } -impl HybridIdxSetBuf { +impl HybridIdxSet { pub fn new_empty(universe_size: usize) -> Self { - HybridIdxSetBuf::Sparse(SparseIdxSetBuf::new(), universe_size) + HybridIdxSet::Sparse(SparseIdxSet::new(), universe_size) } fn universe_size(&mut self) -> usize { match *self { - HybridIdxSetBuf::Sparse(_, size) => size, - HybridIdxSetBuf::Dense(_, size) => size, + HybridIdxSet::Sparse(_, size) => size, + HybridIdxSet::Dense(_, size) => size, } } pub fn clear(&mut self) { let universe_size = self.universe_size(); - *self = HybridIdxSetBuf::new_empty(universe_size); + *self = HybridIdxSet::new_empty(universe_size); } /// Returns true iff set `self` contains `elem`. pub fn contains(&self, elem: &T) -> bool { match self { - HybridIdxSetBuf::Sparse(sparse, _) => sparse.contains(elem), - HybridIdxSetBuf::Dense(dense, _) => dense.contains(elem), + HybridIdxSet::Sparse(sparse, _) => sparse.contains(elem), + HybridIdxSet::Dense(dense, _) => dense.contains(elem), } } /// Adds `elem` to the set `self`. pub fn add(&mut self, elem: &T) -> bool { match self { - HybridIdxSetBuf::Sparse(sparse, _) if sparse.len() < SPARSE_MAX => { + HybridIdxSet::Sparse(sparse, _) if sparse.len() < SPARSE_MAX => { // The set is sparse and has space for `elem`. sparse.add(elem) } - HybridIdxSetBuf::Sparse(sparse, _) if sparse.contains(elem) => { + HybridIdxSet::Sparse(sparse, _) if sparse.contains(elem) => { // The set is sparse and does not have space for `elem`, but // that doesn't matter because `elem` is already present. false } - HybridIdxSetBuf::Sparse(_, _) => { + HybridIdxSet::Sparse(_, _) => { // The set is sparse and full. Convert to a dense set. // // FIXME: This code is awful, but I can't work out how else to // appease the borrow checker. - let dummy = HybridIdxSetBuf::Sparse(SparseIdxSetBuf::new(), 0); + let dummy = HybridIdxSet::Sparse(SparseIdxSet::new(), 0); match mem::replace(self, dummy) { - HybridIdxSetBuf::Sparse(sparse, universe_size) => { + HybridIdxSet::Sparse(sparse, universe_size) => { let mut dense = sparse.to_dense(universe_size); let changed = dense.add(elem); assert!(changed); - mem::replace(self, HybridIdxSetBuf::Dense(dense, universe_size)); + mem::replace(self, HybridIdxSet::Dense(dense, universe_size)); changed } _ => panic!("impossible"), } } - HybridIdxSetBuf::Dense(dense, _) => dense.add(elem), + HybridIdxSet::Dense(dense, _) => dense.add(elem), } } @@ -396,24 +393,24 @@ impl HybridIdxSetBuf { pub fn remove(&mut self, elem: &T) -> bool { // Note: we currently don't bother going from Dense back to Sparse. match self { - HybridIdxSetBuf::Sparse(sparse, _) => sparse.remove(elem), - HybridIdxSetBuf::Dense(dense, _) => dense.remove(elem), + HybridIdxSet::Sparse(sparse, _) => sparse.remove(elem), + HybridIdxSet::Dense(dense, _) => dense.remove(elem), } } /// Converts to a dense set, consuming itself in the process. - pub fn to_dense(self) -> IdxSetBuf { + pub fn to_dense(self) -> IdxSet { match self { - HybridIdxSetBuf::Sparse(sparse, universe_size) => sparse.to_dense(universe_size), - HybridIdxSetBuf::Dense(dense, _) => dense, + HybridIdxSet::Sparse(sparse, universe_size) => sparse.to_dense(universe_size), + HybridIdxSet::Dense(dense, _) => dense, } } /// Iteration order is unspecified. pub fn iter(&self) -> HybridIter { match self { - HybridIdxSetBuf::Sparse(sparse, _) => HybridIter::Sparse(sparse.iter()), - HybridIdxSetBuf::Dense(dense, _) => HybridIter::Dense(dense.iter()), + HybridIdxSet::Sparse(sparse, _) => HybridIter::Sparse(sparse.iter()), + HybridIdxSet::Dense(dense, _) => HybridIter::Dense(dense.iter()), } } } @@ -439,7 +436,7 @@ fn test_trim_to() { use std::cmp; for i in 0..256 { - let mut idx_buf: IdxSetBuf = IdxSetBuf::new_filled(128); + let mut idx_buf: IdxSet = IdxSet::new_filled(128); idx_buf.trim_to(i); let elems: Vec = idx_buf.iter().collect(); @@ -452,7 +449,7 @@ fn test_trim_to() { fn test_set_up_to() { for i in 0..128 { for mut idx_buf in - vec![IdxSetBuf::new_empty(128), IdxSetBuf::new_filled(128)] + vec![IdxSet::new_empty(128), IdxSet::new_filled(128)] .into_iter() { idx_buf.set_up_to(i); @@ -467,7 +464,7 @@ fn test_set_up_to() { #[test] fn test_new_filled() { for i in 0..128 { - let idx_buf = IdxSetBuf::new_filled(i); + let idx_buf = IdxSet::new_filled(i); let elems: Vec = idx_buf.iter().collect(); let expected: Vec = (0..i).collect(); assert_eq!(elems, expected); diff --git a/src/librustc_data_structures/stable_hasher.rs b/src/librustc_data_structures/stable_hasher.rs index 9f1c7dac1194e..1024e69cc2b0e 100644 --- a/src/librustc_data_structures/stable_hasher.rs +++ b/src/librustc_data_structures/stable_hasher.rs @@ -432,7 +432,7 @@ impl HashStable for ::indexed_vec::IndexVec< } -impl HashStable for ::indexed_set::IdxSetBuf +impl HashStable for ::indexed_set::IdxSet { fn hash_stable(&self, ctx: &mut CTX, diff --git a/src/librustc_data_structures/work_queue.rs b/src/librustc_data_structures/work_queue.rs index b8e8b249bb504..0c8ec753a18f6 100644 --- a/src/librustc_data_structures/work_queue.rs +++ b/src/librustc_data_structures/work_queue.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use indexed_set::IdxSetBuf; +use indexed_set::IdxSet; use indexed_vec::Idx; use std::collections::VecDeque; @@ -20,7 +20,7 @@ use std::collections::VecDeque; /// and also use a bit set to track occupancy. pub struct WorkQueue { deque: VecDeque, - set: IdxSetBuf, + set: IdxSet, } impl WorkQueue { @@ -29,7 +29,7 @@ impl WorkQueue { pub fn with_all(len: usize) -> Self { WorkQueue { deque: (0..len).map(T::new).collect(), - set: IdxSetBuf::new_filled(len), + set: IdxSet::new_filled(len), } } @@ -38,7 +38,7 @@ impl WorkQueue { pub fn with_none(len: usize) -> Self { WorkQueue { deque: VecDeque::with_capacity(len), - set: IdxSetBuf::new_empty(len), + set: IdxSet::new_empty(len), } } diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 4926da3b880e7..bbc4dbe09e147 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -43,7 +43,7 @@ use syntax::edition::Edition; use syntax::parse::filemap_to_stream; use syntax::symbol::Symbol; use syntax_pos::{Span, NO_EXPANSION, FileName}; -use rustc_data_structures::indexed_set::IdxSetBuf; +use rustc_data_structures::indexed_set::IdxSet; use rustc::hir; macro_rules! provide { @@ -142,7 +142,7 @@ provide! { <'tcx> tcx, def_id, other, cdata, mir } mir_const_qualif => { - (cdata.mir_const_qualif(def_id.index), Lrc::new(IdxSetBuf::new_empty(0))) + (cdata.mir_const_qualif(def_id.index), Lrc::new(IdxSet::new_empty(0))) } fn_sig => { cdata.fn_sig(def_id.index, tcx) } inherent_impls => { Lrc::new(cdata.get_inherent_implementations_for_type(def_id.index)) } diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index ce0e76a636db2..fdec7e70622e4 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -27,7 +27,7 @@ use rustc::ty::{self, ParamEnv, TyCtxt, Ty}; use rustc_errors::{Diagnostic, DiagnosticBuilder, Level}; use rustc_data_structures::graph::dominators::Dominators; use rustc_data_structures::fx::FxHashSet; -use rustc_data_structures::indexed_set::IdxSetBuf; +use rustc_data_structures::indexed_set::IdxSet; use rustc_data_structures::indexed_vec::Idx; use rustc_data_structures::small_vec::SmallVec; @@ -166,7 +166,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>( _ => Some(tcx.hir.body_owned_by(id)), }; - let dead_unwinds = IdxSetBuf::new_empty(mir.basic_blocks().len()); + let dead_unwinds = IdxSet::new_empty(mir.basic_blocks().len()); let mut flow_inits = FlowAtLocation::new(do_dataflow( tcx, mir, diff --git a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs index ebcc044093a65..ff68b5987e85a 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs @@ -27,7 +27,7 @@ use rustc::mir::{ use rustc::ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable}; use rustc::util::common; use rustc_data_structures::graph::scc::Sccs; -use rustc_data_structures::indexed_set::{IdxSet, IdxSetBuf}; +use rustc_data_structures::indexed_set::IdxSet; use rustc_data_structures::indexed_vec::IndexVec; use rustc_errors::Diagnostic; @@ -468,7 +468,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { // SCC. For each SCC, we visit its successors and compute // their values, then we union all those values to get our // own. - let visited = &mut IdxSetBuf::new_empty(self.constraint_sccs.num_sccs()); + let visited = &mut IdxSet::new_empty(self.constraint_sccs.num_sccs()); for scc_index in self.constraint_sccs.all_sccs() { self.propagate_constraint_sccs_if_new(scc_index, visited); } diff --git a/src/librustc_mir/dataflow/at_location.rs b/src/librustc_mir/dataflow/at_location.rs index d2a8a9dcf4ba2..0dfc5b5b4b7e0 100644 --- a/src/librustc_mir/dataflow/at_location.rs +++ b/src/librustc_mir/dataflow/at_location.rs @@ -12,7 +12,7 @@ //! locations. use rustc::mir::{BasicBlock, Location}; -use rustc_data_structures::indexed_set::{HybridIdxSetBuf, IdxSetBuf, Iter}; +use rustc_data_structures::indexed_set::{HybridIdxSet, IdxSet, Iter}; use rustc_data_structures::indexed_vec::Idx; use dataflow::{BitDenotation, BlockSets, DataflowResults}; @@ -67,9 +67,9 @@ where BD: BitDenotation, { base_results: DataflowResults, - curr_state: IdxSetBuf, - stmt_gen: HybridIdxSetBuf, - stmt_kill: HybridIdxSetBuf, + curr_state: IdxSet, + stmt_gen: HybridIdxSet, + stmt_kill: HybridIdxSet, } impl FlowAtLocation @@ -96,9 +96,9 @@ where pub fn new(results: DataflowResults) -> Self { let bits_per_block = results.sets().bits_per_block(); - let curr_state = IdxSetBuf::new_empty(bits_per_block); - let stmt_gen = HybridIdxSetBuf::new_empty(bits_per_block); - let stmt_kill = HybridIdxSetBuf::new_empty(bits_per_block); + let curr_state = IdxSet::new_empty(bits_per_block); + let stmt_gen = HybridIdxSet::new_empty(bits_per_block); + let stmt_kill = HybridIdxSet::new_empty(bits_per_block); FlowAtLocation { base_results: results, curr_state: curr_state, diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs index 0881b66e5508b..54f19428df765 100644 --- a/src/librustc_mir/dataflow/mod.rs +++ b/src/librustc_mir/dataflow/mod.rs @@ -11,7 +11,7 @@ use syntax::ast::{self, MetaItem}; use rustc_data_structures::bitslice::{bitwise, BitwiseOperator}; -use rustc_data_structures::indexed_set::{HybridIdxSetBuf, IdxSet, IdxSetBuf}; +use rustc_data_structures::indexed_set::{HybridIdxSet, IdxSet}; use rustc_data_structures::indexed_vec::Idx; use rustc_data_structures::work_queue::WorkQueue; @@ -182,7 +182,7 @@ struct PropagationContext<'b, 'a: 'b, 'tcx: 'a, O> where O: 'b + BitDenotation impl<'a, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD> where BD: BitDenotation { fn propagate(&mut self) { - let mut temp = IdxSetBuf::new_empty(self.flow_state.sets.bits_per_block); + let mut temp = IdxSet::new_empty(self.flow_state.sets.bits_per_block); let mut propcx = PropagationContext { builder: self, }; @@ -353,7 +353,7 @@ pub fn state_for_location<'tcx, T: BitDenotation>(loc: Location, analysis: &T, result: &DataflowResults, mir: &Mir<'tcx>) - -> IdxSetBuf { + -> IdxSet { let mut on_entry = result.sets().on_entry_set_for(loc.block.index()).to_owned(); let mut kill_set = on_entry.to_hybrid(); let mut gen_set = kill_set.clone(); @@ -437,7 +437,7 @@ impl DataflowState { pub(crate) fn interpret_hybrid_set<'c, P>(&self, o: &'c O, - set: &HybridIdxSetBuf, + set: &HybridIdxSet, render_idx: &P) -> Vec where P: Fn(&O, O::Idx) -> DebugFormatted @@ -452,17 +452,17 @@ pub struct AllSets { bits_per_block: usize, /// For each block, bits valid on entry to the block. - on_entry_sets: Vec>, + on_entry_sets: Vec>, /// For each block, bits generated by executing the statements in /// the block. (For comparison, the Terminator for each block is /// handled in a flow-specific manner during propagation.) - gen_sets: Vec>, + gen_sets: Vec>, /// For each block, bits killed by executing the statements in the /// block. (For comparison, the Terminator for each block is /// handled in a flow-specific manner during propagation.) - kill_sets: Vec>, + kill_sets: Vec>, } /// Triple of sets associated with a given block. @@ -486,11 +486,11 @@ pub struct BlockSets<'a, E: Idx> { /// Bits that are set to 1 by the time we exit the given block. Hybrid /// because it usually contains only 0 or 1 elements. - pub(crate) gen_set: &'a mut HybridIdxSetBuf, + pub(crate) gen_set: &'a mut HybridIdxSet, /// Bits that are set to 0 by the time we exit the given block. Hybrid /// because it usually contains only 0 or 1 elements. - pub(crate) kill_set: &'a mut HybridIdxSetBuf, + pub(crate) kill_set: &'a mut HybridIdxSet, } impl<'a, E:Idx> BlockSets<'a, E> { @@ -549,13 +549,13 @@ impl AllSets { } } - pub fn on_entry_set_for(&self, block_idx: usize) -> &IdxSetBuf { + pub fn on_entry_set_for(&self, block_idx: usize) -> &IdxSet { &self.on_entry_sets[block_idx] } - pub fn gen_set_for(&self, block_idx: usize) -> &HybridIdxSetBuf { + pub fn gen_set_for(&self, block_idx: usize) -> &HybridIdxSet { &self.gen_sets[block_idx] } - pub fn kill_set_for(&self, block_idx: usize) -> &HybridIdxSetBuf { + pub fn kill_set_for(&self, block_idx: usize) -> &HybridIdxSet { &self.kill_sets[block_idx] } } @@ -713,11 +713,11 @@ impl<'a, 'tcx, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation let num_blocks = mir.basic_blocks().len(); let on_entry_sets = if D::bottom_value() { - vec![IdxSetBuf::new_filled(bits_per_block); num_blocks] + vec![IdxSet::new_filled(bits_per_block); num_blocks] } else { - vec![IdxSetBuf::new_empty(bits_per_block); num_blocks] + vec![IdxSet::new_empty(bits_per_block); num_blocks] }; - let gen_sets = vec![HybridIdxSetBuf::new_empty(bits_per_block); num_blocks]; + let gen_sets = vec![HybridIdxSet::new_empty(bits_per_block); num_blocks]; let kill_sets = gen_sets.clone(); DataflowAnalysis { diff --git a/src/librustc_mir/transform/elaborate_drops.rs b/src/librustc_mir/transform/elaborate_drops.rs index 937d01a0c5e88..bbf896e624f20 100644 --- a/src/librustc_mir/transform/elaborate_drops.rs +++ b/src/librustc_mir/transform/elaborate_drops.rs @@ -18,7 +18,7 @@ use dataflow::{self, do_dataflow, DebugFormatted}; use rustc::ty::{self, TyCtxt}; use rustc::mir::*; use rustc::util::nodemap::FxHashMap; -use rustc_data_structures::indexed_set::IdxSetBuf; +use rustc_data_structures::indexed_set::IdxSet; use rustc_data_structures::indexed_vec::Idx; use transform::{MirPass, MirSource}; use util::patch::MirPatch; @@ -93,12 +93,12 @@ fn find_dead_unwinds<'a, 'tcx>( mir: &Mir<'tcx>, id: ast::NodeId, env: &MoveDataParamEnv<'tcx, 'tcx>) - -> IdxSetBuf + -> IdxSet { debug!("find_dead_unwinds({:?})", mir.span); // We only need to do this pass once, because unwind edges can only // reach cleanup blocks, which can't have unwind edges themselves. - let mut dead_unwinds = IdxSetBuf::new_empty(mir.basic_blocks().len()); + let mut dead_unwinds = IdxSet::new_empty(mir.basic_blocks().len()); let flow_inits = do_dataflow(tcx, mir, id, &[], &dead_unwinds, MaybeInitializedPlaces::new(tcx, mir, &env), @@ -112,7 +112,7 @@ fn find_dead_unwinds<'a, 'tcx>( let mut init_data = InitializationData { live: flow_inits.sets().on_entry_set_for(bb.index()).to_owned(), - dead: IdxSetBuf::new_empty(env.move_data.move_paths.len()), + dead: IdxSet::new_empty(env.move_data.move_paths.len()), }; debug!("find_dead_unwinds @ {:?}: {:?}; init_data={:?}", bb, bb_data, init_data.live); @@ -147,8 +147,8 @@ fn find_dead_unwinds<'a, 'tcx>( } struct InitializationData { - live: IdxSetBuf, - dead: IdxSetBuf + live: IdxSet, + dead: IdxSet } impl InitializationData { diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index a3647edd155d3..744efb3783226 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -68,7 +68,7 @@ use rustc::ty::subst::Substs; use util::dump_mir; use util::liveness::{self, IdentityMap, LivenessMode}; use rustc_data_structures::indexed_vec::Idx; -use rustc_data_structures::indexed_set::IdxSetBuf; +use rustc_data_structures::indexed_set::IdxSet; use std::collections::HashMap; use std::borrow::Cow; use std::iter::once; @@ -369,7 +369,7 @@ fn locals_live_across_suspend_points<'a, 'tcx,>(tcx: TyCtxt<'a, 'tcx, 'tcx>, movable: bool) -> (liveness::LiveVarSet, HashMap>) { - let dead_unwinds = IdxSetBuf::new_empty(mir.basic_blocks().len()); + let dead_unwinds = IdxSet::new_empty(mir.basic_blocks().len()); let node_id = tcx.hir.as_local_node_id(source.def_id).unwrap(); // Calculate when MIR locals have live storage. This gives us an upper bound of their @@ -381,7 +381,7 @@ fn locals_live_across_suspend_points<'a, 'tcx,>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // Find the MIR locals which do not use StorageLive/StorageDead statements. // The storage of these locals are always live. - let mut ignored = StorageIgnored(IdxSetBuf::new_filled(mir.local_decls.len())); + let mut ignored = StorageIgnored(IdxSet::new_filled(mir.local_decls.len())); ignored.visit_mir(mir); // Calculate the MIR locals which have been previously diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index d876ee77e76cf..22bf764506039 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -15,7 +15,7 @@ //! diagnostics as to why a constant rvalue wasn't promoted. use rustc_data_structures::bitvec::BitArray; -use rustc_data_structures::indexed_set::IdxSetBuf; +use rustc_data_structures::indexed_set::IdxSet; use rustc_data_structures::indexed_vec::{IndexVec, Idx}; use rustc_data_structures::fx::FxHashSet; use rustc::hir; @@ -279,7 +279,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> { } /// Qualify a whole const, static initializer or const fn. - fn qualify_const(&mut self) -> (Qualif, Lrc>) { + fn qualify_const(&mut self) -> (Qualif, Lrc>) { debug!("qualifying {} {:?}", self.mode, self.def_id); let mir = self.mir; @@ -382,7 +382,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> { // Collect all the temps we need to promote. - let mut promoted_temps = IdxSetBuf::new_empty(self.temp_promotion_state.len()); + let mut promoted_temps = IdxSet::new_empty(self.temp_promotion_state.len()); for candidate in &self.promotion_candidates { match *candidate { @@ -1082,7 +1082,7 @@ pub fn provide(providers: &mut Providers) { fn mir_const_qualif<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) - -> (u8, Lrc>) { + -> (u8, Lrc>) { // NB: This `borrow()` is guaranteed to be valid (i.e., the value // cannot yet be stolen), because `mir_validated()`, which steals // from `mir_const(), forces this query to execute before @@ -1091,7 +1091,7 @@ fn mir_const_qualif<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, if mir.return_ty().references_error() { tcx.sess.delay_span_bug(mir.span, "mir_const_qualif: Mir had errors"); - return (Qualif::NOT_CONST.bits(), Lrc::new(IdxSetBuf::new_empty(0))); + return (Qualif::NOT_CONST.bits(), Lrc::new(IdxSet::new_empty(0))); } let mut qualifier = Qualifier::new(tcx, def_id, mir, Mode::Const); diff --git a/src/librustc_mir/transform/rustc_peek.rs b/src/librustc_mir/transform/rustc_peek.rs index 776d7888459f7..c471853175422 100644 --- a/src/librustc_mir/transform/rustc_peek.rs +++ b/src/librustc_mir/transform/rustc_peek.rs @@ -14,7 +14,7 @@ use syntax_pos::Span; use rustc::ty::{self, TyCtxt}; use rustc::mir::{self, Mir, Location}; -use rustc_data_structures::indexed_set::IdxSetBuf; +use rustc_data_structures::indexed_set::IdxSet; use rustc_data_structures::indexed_vec::Idx; use transform::{MirPass, MirSource}; @@ -47,7 +47,7 @@ impl MirPass for SanityCheck { let param_env = tcx.param_env(def_id); let move_data = MoveData::gather_moves(mir, tcx).unwrap(); let mdpe = MoveDataParamEnv { move_data: move_data, param_env: param_env }; - let dead_unwinds = IdxSetBuf::new_empty(mir.basic_blocks().len()); + let dead_unwinds = IdxSet::new_empty(mir.basic_blocks().len()); let flow_inits = do_dataflow(tcx, mir, id, &attributes, &dead_unwinds, MaybeInitializedPlaces::new(tcx, mir, &mdpe), diff --git a/src/librustc_mir/util/liveness.rs b/src/librustc_mir/util/liveness.rs index 6c5b38a806e57..04fa516a655a6 100644 --- a/src/librustc_mir/util/liveness.rs +++ b/src/librustc_mir/util/liveness.rs @@ -38,7 +38,7 @@ use rustc::mir::visit::{PlaceContext, Visitor}; use rustc::mir::Local; use rustc::mir::*; use rustc::ty::{item_path, TyCtxt}; -use rustc_data_structures::indexed_set::IdxSetBuf; +use rustc_data_structures::indexed_set::IdxSet; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use rustc_data_structures::work_queue::WorkQueue; use std::fs; @@ -47,7 +47,7 @@ use std::path::{Path, PathBuf}; use transform::MirSource; use util::pretty::{dump_enabled, write_basic_block, write_mir_intro}; -pub type LiveVarSet = IdxSetBuf; +pub type LiveVarSet = IdxSet; /// This gives the result of the liveness analysis at the boundary of /// basic blocks. You can use `simulate_block` to obtain the