X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc_mir%2Fdataflow%2Fat_location.rs;h=e4eb8506846c0b60b571ef0fc9603e780f2a2277;hb=83980aca2086e5c4dca5aae9a92a065a9ff4ac56;hp=e0ca10535237bd3c0bf87c820c97ba74d9c68b90;hpb=0e88e56a9a535bc0bf3b6c88f08a67ac33589c4a;p=rust.git diff --git a/src/librustc_mir/dataflow/at_location.rs b/src/librustc_mir/dataflow/at_location.rs index e0ca1053523..e4eb8506846 100644 --- a/src/librustc_mir/dataflow/at_location.rs +++ b/src/librustc_mir/dataflow/at_location.rs @@ -5,10 +5,9 @@ use rustc_index::bit_set::{BitIter, BitSet, HybridBitSet}; use crate::dataflow::{BitDenotation, DataflowResults, GenKillSet}; -use crate::dataflow::move_paths::{HasMoveData, MovePathIndex}; -use std::iter; use std::borrow::Borrow; +use std::iter; /// A trait for "cartesian products" of multiple FlowAtLocation. /// @@ -98,11 +97,7 @@ pub fn new(results: DR) -> Self { let bits_per_block = results.borrow().sets().bits_per_block(); let curr_state = BitSet::new_empty(bits_per_block); let stmt_trans = GenKillSet::from_elem(HybridBitSet::new_empty(bits_per_block)); - FlowAtLocation { - base_results: results, - curr_state, - stmt_trans, - } + FlowAtLocation { base_results: results, curr_state, stmt_trans } } /// Access the underlying operator. @@ -154,74 +149,21 @@ fn reset_to_exit_of(&mut self, bb: BasicBlock) { fn reconstruct_statement_effect(&mut self, loc: Location) { self.stmt_trans.clear(); - self.base_results - .borrow() - .operator() - .before_statement_effect(&mut self.stmt_trans, loc); + self.base_results.borrow().operator().before_statement_effect(&mut self.stmt_trans, loc); self.stmt_trans.apply(&mut self.curr_state); - self.base_results - .borrow() - .operator() - .statement_effect(&mut self.stmt_trans, loc); + self.base_results.borrow().operator().statement_effect(&mut self.stmt_trans, loc); } fn reconstruct_terminator_effect(&mut self, loc: Location) { self.stmt_trans.clear(); - self.base_results - .borrow() - .operator() - .before_terminator_effect(&mut self.stmt_trans, loc); + self.base_results.borrow().operator().before_terminator_effect(&mut self.stmt_trans, loc); self.stmt_trans.apply(&mut self.curr_state); - self.base_results - .borrow() - .operator() - .terminator_effect(&mut self.stmt_trans, loc); + self.base_results.borrow().operator().terminator_effect(&mut self.stmt_trans, loc); } fn apply_local_effect(&mut self, _loc: Location) { self.stmt_trans.apply(&mut self.curr_state) } } - - -impl<'tcx, T, DR> FlowAtLocation<'tcx, T, DR> -where - T: HasMoveData<'tcx> + BitDenotation<'tcx, Idx = MovePathIndex>, - DR: Borrow>, -{ - pub fn has_any_child_of(&self, mpi: T::Idx) -> Option { - // We process `mpi` before the loop below, for two reasons: - // - it's a little different from the loop case (we don't traverse its - // siblings); - // - ~99% of the time the loop isn't reached, and this code is hot, so - // we don't want to allocate `todo` unnecessarily. - if self.contains(mpi) { - return Some(mpi); - } - let move_data = self.operator().move_data(); - let move_path = &move_data.move_paths[mpi]; - let mut todo = if let Some(child) = move_path.first_child { - vec![child] - } else { - return None; - }; - - while let Some(mpi) = todo.pop() { - if self.contains(mpi) { - return Some(mpi); - } - let move_path = &move_data.move_paths[mpi]; - if let Some(child) = move_path.first_child { - todo.push(child); - } - // After we've processed the original `mpi`, we should always - // traverse the siblings of any of its children. - if let Some(sibling) = move_path.next_sibling { - todo.push(sibling); - } - } - return None; - } -}