about summary refs log tree commit diff
path: root/src/librustc_data_structures
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-10-19 17:41:49 -0700
committerGitHub <noreply@github.com>2016-10-19 17:41:49 -0700
commitdfd98ebd3e862d6fe23519fc6605d03a1c146914 (patch)
treec55534ab1c084f6aa36529c6b28c316c4f79e35f /src/librustc_data_structures
parentd337f345ca8b3bb4aac988ace1c0676abc5310a0 (diff)
parentdd3a014ed9e61ba9d2f86e00ef299edf285e276c (diff)
downloadrust-dfd98ebd3e862d6fe23519fc6605d03a1c146914.tar.gz
rust-dfd98ebd3e862d6fe23519fc6605d03a1c146914.zip
Auto merge of #37289 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 7 pull requests

- Successful merges: #37165, #37187, #37241, #37283, #37285, #37287, #37288
- Failed merges:
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
-rw-r--r--src/librustc_data_structures/snapshot_map/mod.rs17
-rw-r--r--src/librustc_data_structures/unify/mod.rs14
11 files changed, 63 insertions, 105 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)
     }
diff --git a/src/librustc_data_structures/snapshot_map/mod.rs b/src/librustc_data_structures/snapshot_map/mod.rs
index b3989013d21..0306066d6e7 100644
--- a/src/librustc_data_structures/snapshot_map/mod.rs
+++ b/src/librustc_data_structures/snapshot_map/mod.rs
@@ -23,7 +23,7 @@ pub struct SnapshotMap<K, V>
 }
 
 pub struct Snapshot {
-    len: usize
+    len: usize,
 }
 
 enum UndoLog<K, V> {
@@ -39,7 +39,7 @@ impl<K, V> SnapshotMap<K, V>
     pub fn new() -> Self {
         SnapshotMap {
             map: FnvHashMap(),
-            undo_log: vec![]
+            undo_log: vec![],
         }
     }
 
@@ -68,9 +68,7 @@ impl<K, V> SnapshotMap<K, V>
                 }
                 true
             }
-            None => {
-                false
-            }
+            None => false,
         }
     }
 
@@ -88,7 +86,7 @@ impl<K, V> SnapshotMap<K, V>
         assert!(snapshot.len < self.undo_log.len());
         assert!(match self.undo_log[snapshot.len] {
             UndoLog::OpenSnapshot => true,
-            _ => false
+            _ => false,
         });
     }
 
@@ -110,7 +108,7 @@ impl<K, V> SnapshotMap<K, V>
                     panic!("cannot rollback an uncommitted snapshot");
                 }
 
-                UndoLog::CommittedSnapshot => { }
+                UndoLog::CommittedSnapshot => {}
 
                 UndoLog::Inserted(key) => {
                     self.map.remove(&key);
@@ -123,7 +121,10 @@ impl<K, V> SnapshotMap<K, V>
         }
 
         let v = self.undo_log.pop().unwrap();
-        assert!(match v { UndoLog::OpenSnapshot => true, _ => false });
+        assert!(match v {
+            UndoLog::OpenSnapshot => true,
+            _ => false,
+        });
         assert!(self.undo_log.len() == snapshot.len);
     }
 }
diff --git a/src/librustc_data_structures/unify/mod.rs b/src/librustc_data_structures/unify/mod.rs
index 3feea3218d0..1f4d09a9224 100644
--- a/src/librustc_data_structures/unify/mod.rs
+++ b/src/librustc_data_structures/unify/mod.rs
@@ -27,7 +27,7 @@ mod tests;
 ///
 /// Clients are expected to provide implementations of this trait; you
 /// can see some examples in the `test` module.
-pub trait UnifyKey : Copy + Clone + Debug + PartialEq {
+pub trait UnifyKey: Copy + Clone + Debug + PartialEq {
     type Value: Clone + PartialEq + Debug;
 
     fn index(&self) -> u32;
@@ -115,11 +115,7 @@ impl<K: UnifyKey> VarValue<K> {
     }
 
     fn if_not_self(&self, key: K, self_key: K) -> Option<K> {
-        if key == self_key {
-            None
-        } else {
-            Some(key)
-        }
+        if key == self_key { None } else { Some(key) }
     }
 }
 
@@ -236,7 +232,8 @@ impl<K: UnifyKey> UnificationTable<K> {
                      new_rank: u32,
                      old_root: VarValue<K>,
                      new_root: VarValue<K>,
-                     new_value: K::Value) -> K {
+                     new_value: K::Value)
+                     -> K {
         let old_root_key = old_root.key();
         let new_root_key = new_root.key();
         self.set(old_root_key, old_root.redirect(new_root_key));
@@ -306,7 +303,8 @@ impl<'tcx, K, V> UnificationTable<K>
         let combined = {
             match (&node_a.value, &node_b.value) {
                 (&None, &None) => None,
-                (&Some(ref v), &None) | (&None, &Some(ref v)) => Some(v.clone()),
+                (&Some(ref v), &None) |
+                (&None, &Some(ref v)) => Some(v.clone()),
                 (&Some(ref v1), &Some(ref v2)) => {
                     if *v1 != *v2 {
                         return Err((v1.clone(), v2.clone()));