diff --git a/compiler/rustc_data_structures/src/graph/dominators/mod.rs b/compiler/rustc_data_structures/src/graph/dominators/mod.rs index 1cfbce2355e3a..ad62e3c9fc8f4 100644 --- a/compiler/rustc_data_structures/src/graph/dominators/mod.rs +++ b/compiler/rustc_data_structures/src/graph/dominators/mod.rs @@ -8,7 +8,6 @@ use super::iterate::reverse_post_order; use super::ControlFlowGraph; use rustc_index::vec::{Idx, IndexVec}; -use std::borrow::BorrowMut; use std::cmp::Ordering; #[cfg(test)] @@ -20,22 +19,17 @@ pub fn dominators(graph: G) -> Dominators { dominators_given_rpo(graph, &rpo) } -fn dominators_given_rpo>( - mut graph: G, - rpo: &[G::Node], -) -> Dominators { - let start_node = graph.borrow().start_node(); +fn dominators_given_rpo(graph: G, rpo: &[G::Node]) -> Dominators { + let start_node = graph.start_node(); assert_eq!(rpo[0], start_node); // compute the post order index (rank) for each node - let mut post_order_rank: IndexVec = - (0..graph.borrow().num_nodes()).map(|_| 0).collect(); + let mut post_order_rank = IndexVec::from_elem_n(0, graph.num_nodes()); for (index, node) in rpo.iter().rev().cloned().enumerate() { post_order_rank[node] = index; } - let mut immediate_dominators: IndexVec> = - (0..graph.borrow().num_nodes()).map(|_| None).collect(); + let mut immediate_dominators = IndexVec::from_elem_n(None, graph.num_nodes()); immediate_dominators[start_node] = Some(start_node); let mut changed = true; @@ -44,7 +38,7 @@ fn dominators_given_rpo>( for &node in &rpo[1..] { let mut new_idom = None; - for pred in graph.borrow_mut().predecessors(node) { + for pred in graph.predecessors(node) { if immediate_dominators[pred].is_some() { // (*) dominators for `pred` have been calculated new_idom = Some(if let Some(new_idom) = new_idom {