about summary refs log tree commit diff
path: root/src/librustc_data_structures
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-10-19 23:15:01 +0200
committerGitHub <noreply@github.com>2016-10-19 23:15:01 +0200
commite7dc035f92c2e753c2a8b2cb6a6e80dbf2dd5d34 (patch)
tree394f9652830c38049562ecab11955fd1612079a7 /src/librustc_data_structures
parentdfb74ee97b2210fb9f3f00bbbd3494180b0e527b (diff)
parentf1e4ae17b1a80119599e501e26fed0d7635b65f7 (diff)
downloadrust-e7dc035f92c2e753c2a8b2cb6a6e80dbf2dd5d34.tar.gz
rust-e7dc035f92c2e753c2a8b2cb6a6e80dbf2dd5d34.zip
Rollup merge of #37285 - srinivasreddy:cfg, r=nikomatsakis
run rustfmt on control_flow_graph folder
Diffstat (limited to 'src/librustc_data_structures')
-rw-r--r--src/librustc_data_structures/control_flow_graph/dominators/mod.rs28
-rw-r--r--src/librustc_data_structures/control_flow_graph/dominators/test.rs22
-rw-r--r--src/librustc_data_structures/control_flow_graph/iterate/test.rs20
-rw-r--r--src/librustc_data_structures/control_flow_graph/mod.rs6
-rw-r--r--src/librustc_data_structures/control_flow_graph/reachable/mod.rs9
-rw-r--r--src/librustc_data_structures/control_flow_graph/reachable/test.rs22
-rw-r--r--src/librustc_data_structures/control_flow_graph/reference.rs8
-rw-r--r--src/librustc_data_structures/control_flow_graph/test.rs11
-rw-r--r--src/librustc_data_structures/control_flow_graph/transpose.rs11
9 files changed, 48 insertions, 89 deletions
diff --git a/src/librustc_data_structures/control_flow_graph/dominators/mod.rs b/src/librustc_data_structures/control_flow_graph/dominators/mod.rs
index 250b89d12ed..ab675db2150 100644
--- a/src/librustc_data_structures/control_flow_graph/dominators/mod.rs
+++ b/src/librustc_data_structures/control_flow_graph/dominators/mod.rs
@@ -57,9 +57,9 @@ pub fn dominators_given_rpo<G: ControlFlowGraph>(graph: &G,
                     // (*)
                     // (*) dominators for `pred` have been calculated
                     new_idom = intersect_opt(&post_order_rank,
-                                                  &immediate_dominators,
-                                                  new_idom,
-                                                  Some(pred));
+                                             &immediate_dominators,
+                                             new_idom,
+                                             Some(pred));
                 }
             }
 
@@ -77,10 +77,10 @@ pub fn dominators_given_rpo<G: ControlFlowGraph>(graph: &G,
 }
 
 fn intersect_opt<Node: Idx>(post_order_rank: &IndexVec<Node, usize>,
-                                      immediate_dominators: &IndexVec<Node, Option<Node>>,
-                                      node1: Option<Node>,
-                                      node2: Option<Node>)
-                                      -> Option<Node> {
+                            immediate_dominators: &IndexVec<Node, Option<Node>>,
+                            node1: Option<Node>,
+                            node2: Option<Node>)
+                            -> Option<Node> {
     match (node1, node2) {
         (None, None) => None,
         (Some(n), None) | (None, Some(n)) => Some(n),
@@ -89,10 +89,10 @@ fn intersect_opt<Node: Idx>(post_order_rank: &IndexVec<Node, usize>,
 }
 
 fn intersect<Node: Idx>(post_order_rank: &IndexVec<Node, usize>,
-                                  immediate_dominators: &IndexVec<Node, Option<Node>>,
-                                  mut node1: Node,
-                                  mut node2: Node)
-                                  -> Node {
+                        immediate_dominators: &IndexVec<Node, Option<Node>>,
+                        mut node1: Node,
+                        mut node2: Node)
+                        -> Node {
     while node1 != node2 {
         while post_order_rank[node1] < post_order_rank[node2] {
             node1 = immediate_dominators[node1].unwrap();
@@ -142,9 +142,9 @@ impl<Node: Idx> Dominators<Node> {
                 "node {:?} is not reachable",
                 node2);
         intersect::<Node>(&self.post_order_rank,
-                  &self.immediate_dominators,
-                  node1,
-                  node2)
+                          &self.immediate_dominators,
+                          node1,
+                          node2)
     }
 
     pub fn mutual_dominator<I>(&self, iter: I) -> Option<Node>
diff --git a/src/librustc_data_structures/control_flow_graph/dominators/test.rs b/src/librustc_data_structures/control_flow_graph/dominators/test.rs
index a6db5f2fe3e..0af878cac2d 100644
--- a/src/librustc_data_structures/control_flow_graph/dominators/test.rs
+++ b/src/librustc_data_structures/control_flow_graph/dominators/test.rs
@@ -14,12 +14,7 @@ use super::*;
 
 #[test]
 fn diamond() {
-    let graph = TestGraph::new(0, &[
-        (0, 1),
-        (0, 2),
-        (1, 3),
-        (2, 3),
-    ]);
+    let graph = TestGraph::new(0, &[(0, 1), (0, 2), (1, 3), (2, 3)]);
 
     let dominators = dominators(&graph);
     let immediate_dominators = dominators.all_immediate_dominators();
@@ -32,17 +27,9 @@ fn diamond() {
 #[test]
 fn paper() {
     // example from the paper:
-    let graph = TestGraph::new(6, &[
-        (6, 5),
-        (6, 4),
-        (5, 1),
-        (4, 2),
-        (4, 3),
-        (1, 2),
-        (2, 3),
-        (3, 2),
-        (2, 1),
-    ]);
+    let graph = TestGraph::new(6,
+                               &[(6, 5), (6, 4), (5, 1), (4, 2), (4, 3), (1, 2), (2, 3), (3, 2),
+                                 (2, 1)]);
 
     let dominators = dominators(&graph);
     let immediate_dominators = dominators.all_immediate_dominators();
@@ -54,4 +41,3 @@ fn paper() {
     assert_eq!(immediate_dominators[5], Some(6));
     assert_eq!(immediate_dominators[6], Some(6));
 }
-
diff --git a/src/librustc_data_structures/control_flow_graph/iterate/test.rs b/src/librustc_data_structures/control_flow_graph/iterate/test.rs
index 28297d55bdf..dca45602f17 100644
--- a/src/librustc_data_structures/control_flow_graph/iterate/test.rs
+++ b/src/librustc_data_structures/control_flow_graph/iterate/test.rs
@@ -15,12 +15,7 @@ use super::*;
 
 #[test]
 fn diamond_post_order() {
-    let graph = TestGraph::new(0, &[
-        (0, 1),
-        (0, 2),
-        (1, 3),
-        (2, 3),
-    ]);
+    let graph = TestGraph::new(0, &[(0, 1), (0, 2), (1, 3), (2, 3)]);
 
     let result = post_order_from(&graph, 0);
     assert_eq!(result, vec![3, 1, 2, 0]);
@@ -33,16 +28,8 @@ fn rev_post_order_inner_loop() {
     //      ^     ^    v      |
     //      |     6 <- 4      |
     //      +-----------------+
-    let graph = TestGraph::new(0, &[
-        (0, 1),
-        (1, 2),
-        (2, 3),
-        (3, 5),
-        (3, 1),
-        (2, 4),
-        (4, 6),
-        (6, 2),
-    ]);
+    let graph = TestGraph::new(0,
+                               &[(0, 1), (1, 2), (2, 3), (3, 5), (3, 1), (2, 4), (4, 6), (6, 2)]);
 
     let rev_graph = TransposedGraph::new(&graph);
 
@@ -52,4 +39,3 @@ fn rev_post_order_inner_loop() {
     let result = post_order_from_to(&rev_graph, 3, Some(1));
     assert_eq!(result, vec![4, 6, 2, 3]);
 }
-
diff --git a/src/librustc_data_structures/control_flow_graph/mod.rs b/src/librustc_data_structures/control_flow_graph/mod.rs
index f9e75b12e03..eb6839df627 100644
--- a/src/librustc_data_structures/control_flow_graph/mod.rs
+++ b/src/librustc_data_structures/control_flow_graph/mod.rs
@@ -36,10 +36,10 @@ pub trait ControlFlowGraph
 
 pub trait GraphPredecessors<'graph> {
     type Item;
-    type Iter: Iterator<Item=Self::Item>;
+    type Iter: Iterator<Item = Self::Item>;
 }
 
 pub trait GraphSuccessors<'graph> {
     type Item;
-    type Iter: Iterator<Item=Self::Item>;
-}
\ No newline at end of file
+    type Iter: Iterator<Item = Self::Item>;
+}
diff --git a/src/librustc_data_structures/control_flow_graph/reachable/mod.rs b/src/librustc_data_structures/control_flow_graph/reachable/mod.rs
index e520e23f3af..24210ebb95d 100644
--- a/src/librustc_data_structures/control_flow_graph/reachable/mod.rs
+++ b/src/librustc_data_structures/control_flow_graph/reachable/mod.rs
@@ -19,8 +19,7 @@ use super::super::indexed_vec::{IndexVec, Idx};
 #[cfg(test)]
 mod test;
 
-pub fn reachable<G: ControlFlowGraph>(graph: &G)
-                                      -> Reachability<G::Node> {
+pub fn reachable<G: ControlFlowGraph>(graph: &G) -> Reachability<G::Node> {
     let reverse_post_order = reverse_post_order(graph, graph.start_node());
     reachable_given_rpo(graph, &reverse_post_order)
 }
@@ -53,12 +52,10 @@ pub struct Reachability<Node: Idx> {
 impl<Node: Idx> Reachability<Node> {
     fn new<G: ControlFlowGraph>(graph: &G) -> Self {
         let num_nodes = graph.num_nodes();
-        Reachability {
-            bits: IndexVec::from_elem_n(BitVector::new(num_nodes), num_nodes),
-        }
+        Reachability { bits: IndexVec::from_elem_n(BitVector::new(num_nodes), num_nodes) }
     }
 
-    pub fn can_reach(&self, source: Node, target: Node)-> bool {
+    pub fn can_reach(&self, source: Node, target: Node) -> bool {
         let bit: usize = target.index();
         self.bits[source].contains(bit)
     }
diff --git a/src/librustc_data_structures/control_flow_graph/reachable/test.rs b/src/librustc_data_structures/control_flow_graph/reachable/test.rs
index 6aa906a0804..ef45deeaafc 100644
--- a/src/librustc_data_structures/control_flow_graph/reachable/test.rs
+++ b/src/librustc_data_structures/control_flow_graph/reachable/test.rs
@@ -17,15 +17,7 @@ fn test1() {
     // 0 -> 1 -> 2 -> 3
     //      ^    v
     //      6 <- 4 -> 5
-    let graph = TestGraph::new(0, &[
-        (0, 1),
-        (1, 2),
-        (2, 3),
-        (2, 4),
-        (4, 5),
-        (4, 6),
-        (6, 1),
-    ]);
+    let graph = TestGraph::new(0, &[(0, 1), (1, 2), (2, 3), (2, 4), (4, 5), (4, 6), (6, 1)]);
     let reachable = reachable(&graph);
     assert!((0..6).all(|i| reachable.can_reach(0, i)));
     assert!((1..6).all(|i| reachable.can_reach(1, i)));
@@ -43,15 +35,9 @@ fn test2() {
     // 30 -> 31 -> 32 -> 33
     //       ^      v
     //       36 <- 34 -> 35
-    let graph = TestGraph::new(30, &[
-        (30, 31),
-        (31, 32),
-        (32, 33),
-        (32, 34),
-        (34, 35),
-        (34, 36),
-        (36, 31),
-    ]);
+    let graph = TestGraph::new(30,
+                               &[(30, 31), (31, 32), (32, 33), (32, 34), (34, 35), (34, 36),
+                                 (36, 31)]);
     let reachable = reachable(&graph);
     assert!((30..36).all(|i| reachable.can_reach(30, i)));
     assert!((31..36).all(|i| reachable.can_reach(31, i)));
diff --git a/src/librustc_data_structures/control_flow_graph/reference.rs b/src/librustc_data_structures/control_flow_graph/reference.rs
index d735be1ed2f..3b8b01f2ff4 100644
--- a/src/librustc_data_structures/control_flow_graph/reference.rs
+++ b/src/librustc_data_structures/control_flow_graph/reference.rs
@@ -21,13 +21,13 @@ impl<'graph, G: ControlFlowGraph> ControlFlowGraph for &'graph G {
         (**self).start_node()
     }
 
-    fn predecessors<'iter>(&'iter self, node: Self::Node)
-                            -> <Self as GraphPredecessors<'iter>>::Iter {
+    fn predecessors<'iter>(&'iter self,
+                           node: Self::Node)
+                           -> <Self as GraphPredecessors<'iter>>::Iter {
         (**self).predecessors(node)
     }
 
-    fn successors<'iter>(&'iter self, node: Self::Node)
-                          -> <Self as GraphSuccessors<'iter>>::Iter {
+    fn successors<'iter>(&'iter self, node: Self::Node) -> <Self as GraphSuccessors<'iter>>::Iter {
         (**self).successors(node)
     }
 }
diff --git a/src/librustc_data_structures/control_flow_graph/test.rs b/src/librustc_data_structures/control_flow_graph/test.rs
index 57b2a858de5..d48a6e684ad 100644
--- a/src/librustc_data_structures/control_flow_graph/test.rs
+++ b/src/librustc_data_structures/control_flow_graph/test.rs
@@ -28,7 +28,7 @@ impl TestGraph {
             num_nodes: start_node + 1,
             start_node: start_node,
             successors: HashMap::new(),
-            predecessors: HashMap::new()
+            predecessors: HashMap::new(),
         };
         for &(source, target) in edges {
             graph.num_nodes = max(graph.num_nodes, source + 1);
@@ -55,13 +55,13 @@ impl ControlFlowGraph for TestGraph {
         self.num_nodes
     }
 
-    fn predecessors<'graph>(&'graph self, node: usize)
+    fn predecessors<'graph>(&'graph self,
+                            node: usize)
                             -> <Self as GraphPredecessors<'graph>>::Iter {
-       self.predecessors[&node].iter().cloned()
+        self.predecessors[&node].iter().cloned()
     }
 
-    fn successors<'graph>(&'graph self, node: usize)
-                            -> <Self as GraphSuccessors<'graph>>::Iter {
+    fn successors<'graph>(&'graph self, node: usize) -> <Self as GraphSuccessors<'graph>>::Iter {
         self.successors[&node].iter().cloned()
     }
 }
@@ -75,4 +75,3 @@ impl<'graph> GraphSuccessors<'graph> for TestGraph {
     type Item = usize;
     type Iter = iter::Cloned<slice::Iter<'graph, usize>>;
 }
-
diff --git a/src/librustc_data_structures/control_flow_graph/transpose.rs b/src/librustc_data_structures/control_flow_graph/transpose.rs
index 792e079c28c..a1a117edb94 100644
--- a/src/librustc_data_structures/control_flow_graph/transpose.rs
+++ b/src/librustc_data_structures/control_flow_graph/transpose.rs
@@ -22,7 +22,10 @@ impl<G: ControlFlowGraph> TransposedGraph<G> {
     }
 
     pub fn with_start(base_graph: G, start_node: G::Node) -> Self {
-        TransposedGraph { base_graph: base_graph, start_node: start_node }
+        TransposedGraph {
+            base_graph: base_graph,
+            start_node: start_node,
+        }
     }
 }
 
@@ -37,12 +40,14 @@ impl<G: ControlFlowGraph> ControlFlowGraph for TransposedGraph<G> {
         self.start_node
     }
 
-    fn predecessors<'graph>(&'graph self, node: Self::Node)
+    fn predecessors<'graph>(&'graph self,
+                            node: Self::Node)
                             -> <Self as GraphPredecessors<'graph>>::Iter {
         self.base_graph.successors(node)
     }
 
-    fn successors<'graph>(&'graph self, node: Self::Node)
+    fn successors<'graph>(&'graph self,
+                          node: Self::Node)
                           -> <Self as GraphSuccessors<'graph>>::Iter {
         self.base_graph.predecessors(node)
     }