Skip to content

Commit f1e4ae1

Browse files
committedOct 19, 2016
run rustfmt on control_flow_graph folder
1 parent a41505f commit f1e4ae1

File tree

9 files changed

+48
-89
lines changed

9 files changed

+48
-89
lines changed
 

‎src/librustc_data_structures/control_flow_graph/dominators/mod.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ pub fn dominators_given_rpo<G: ControlFlowGraph>(graph: &G,
5757
// (*)
5858
// (*) dominators for `pred` have been calculated
5959
new_idom = intersect_opt(&post_order_rank,
60-
&immediate_dominators,
61-
new_idom,
62-
Some(pred));
60+
&immediate_dominators,
61+
new_idom,
62+
Some(pred));
6363
}
6464
}
6565

@@ -77,10 +77,10 @@ pub fn dominators_given_rpo<G: ControlFlowGraph>(graph: &G,
7777
}
7878

7979
fn intersect_opt<Node: Idx>(post_order_rank: &IndexVec<Node, usize>,
80-
immediate_dominators: &IndexVec<Node, Option<Node>>,
81-
node1: Option<Node>,
82-
node2: Option<Node>)
83-
-> Option<Node> {
80+
immediate_dominators: &IndexVec<Node, Option<Node>>,
81+
node1: Option<Node>,
82+
node2: Option<Node>)
83+
-> Option<Node> {
8484
match (node1, node2) {
8585
(None, None) => None,
8686
(Some(n), None) | (None, Some(n)) => Some(n),
@@ -89,10 +89,10 @@ fn intersect_opt<Node: Idx>(post_order_rank: &IndexVec<Node, usize>,
8989
}
9090

9191
fn intersect<Node: Idx>(post_order_rank: &IndexVec<Node, usize>,
92-
immediate_dominators: &IndexVec<Node, Option<Node>>,
93-
mut node1: Node,
94-
mut node2: Node)
95-
-> Node {
92+
immediate_dominators: &IndexVec<Node, Option<Node>>,
93+
mut node1: Node,
94+
mut node2: Node)
95+
-> Node {
9696
while node1 != node2 {
9797
while post_order_rank[node1] < post_order_rank[node2] {
9898
node1 = immediate_dominators[node1].unwrap();
@@ -142,9 +142,9 @@ impl<Node: Idx> Dominators<Node> {
142142
"node {:?} is not reachable",
143143
node2);
144144
intersect::<Node>(&self.post_order_rank,
145-
&self.immediate_dominators,
146-
node1,
147-
node2)
145+
&self.immediate_dominators,
146+
node1,
147+
node2)
148148
}
149149

150150
pub fn mutual_dominator<I>(&self, iter: I) -> Option<Node>

‎src/librustc_data_structures/control_flow_graph/dominators/test.rs

+4-18
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@ use super::*;
1414

1515
#[test]
1616
fn diamond() {
17-
let graph = TestGraph::new(0, &[
18-
(0, 1),
19-
(0, 2),
20-
(1, 3),
21-
(2, 3),
22-
]);
17+
let graph = TestGraph::new(0, &[(0, 1), (0, 2), (1, 3), (2, 3)]);
2318

2419
let dominators = dominators(&graph);
2520
let immediate_dominators = dominators.all_immediate_dominators();
@@ -32,17 +27,9 @@ fn diamond() {
3227
#[test]
3328
fn paper() {
3429
// example from the paper:
35-
let graph = TestGraph::new(6, &[
36-
(6, 5),
37-
(6, 4),
38-
(5, 1),
39-
(4, 2),
40-
(4, 3),
41-
(1, 2),
42-
(2, 3),
43-
(3, 2),
44-
(2, 1),
45-
]);
30+
let graph = TestGraph::new(6,
31+
&[(6, 5), (6, 4), (5, 1), (4, 2), (4, 3), (1, 2), (2, 3), (3, 2),
32+
(2, 1)]);
4633

4734
let dominators = dominators(&graph);
4835
let immediate_dominators = dominators.all_immediate_dominators();
@@ -54,4 +41,3 @@ fn paper() {
5441
assert_eq!(immediate_dominators[5], Some(6));
5542
assert_eq!(immediate_dominators[6], Some(6));
5643
}
57-

‎src/librustc_data_structures/control_flow_graph/iterate/test.rs

+3-17
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ use super::*;
1515

1616
#[test]
1717
fn diamond_post_order() {
18-
let graph = TestGraph::new(0, &[
19-
(0, 1),
20-
(0, 2),
21-
(1, 3),
22-
(2, 3),
23-
]);
18+
let graph = TestGraph::new(0, &[(0, 1), (0, 2), (1, 3), (2, 3)]);
2419

2520
let result = post_order_from(&graph, 0);
2621
assert_eq!(result, vec![3, 1, 2, 0]);
@@ -33,16 +28,8 @@ fn rev_post_order_inner_loop() {
3328
// ^ ^ v |
3429
// | 6 <- 4 |
3530
// +-----------------+
36-
let graph = TestGraph::new(0, &[
37-
(0, 1),
38-
(1, 2),
39-
(2, 3),
40-
(3, 5),
41-
(3, 1),
42-
(2, 4),
43-
(4, 6),
44-
(6, 2),
45-
]);
31+
let graph = TestGraph::new(0,
32+
&[(0, 1), (1, 2), (2, 3), (3, 5), (3, 1), (2, 4), (4, 6), (6, 2)]);
4633

4734
let rev_graph = TransposedGraph::new(&graph);
4835

@@ -52,4 +39,3 @@ fn rev_post_order_inner_loop() {
5239
let result = post_order_from_to(&rev_graph, 3, Some(1));
5340
assert_eq!(result, vec![4, 6, 2, 3]);
5441
}
55-

‎src/librustc_data_structures/control_flow_graph/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ pub trait ControlFlowGraph
3636

3737
pub trait GraphPredecessors<'graph> {
3838
type Item;
39-
type Iter: Iterator<Item=Self::Item>;
39+
type Iter: Iterator<Item = Self::Item>;
4040
}
4141

4242
pub trait GraphSuccessors<'graph> {
4343
type Item;
44-
type Iter: Iterator<Item=Self::Item>;
45-
}
44+
type Iter: Iterator<Item = Self::Item>;
45+
}

‎src/librustc_data_structures/control_flow_graph/reachable/mod.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ use super::super::indexed_vec::{IndexVec, Idx};
1919
#[cfg(test)]
2020
mod test;
2121

22-
pub fn reachable<G: ControlFlowGraph>(graph: &G)
23-
-> Reachability<G::Node> {
22+
pub fn reachable<G: ControlFlowGraph>(graph: &G) -> Reachability<G::Node> {
2423
let reverse_post_order = reverse_post_order(graph, graph.start_node());
2524
reachable_given_rpo(graph, &reverse_post_order)
2625
}
@@ -53,12 +52,10 @@ pub struct Reachability<Node: Idx> {
5352
impl<Node: Idx> Reachability<Node> {
5453
fn new<G: ControlFlowGraph>(graph: &G) -> Self {
5554
let num_nodes = graph.num_nodes();
56-
Reachability {
57-
bits: IndexVec::from_elem_n(BitVector::new(num_nodes), num_nodes),
58-
}
55+
Reachability { bits: IndexVec::from_elem_n(BitVector::new(num_nodes), num_nodes) }
5956
}
6057

61-
pub fn can_reach(&self, source: Node, target: Node)-> bool {
58+
pub fn can_reach(&self, source: Node, target: Node) -> bool {
6259
let bit: usize = target.index();
6360
self.bits[source].contains(bit)
6461
}

‎src/librustc_data_structures/control_flow_graph/reachable/test.rs

+4-18
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,7 @@ fn test1() {
1717
// 0 -> 1 -> 2 -> 3
1818
// ^ v
1919
// 6 <- 4 -> 5
20-
let graph = TestGraph::new(0, &[
21-
(0, 1),
22-
(1, 2),
23-
(2, 3),
24-
(2, 4),
25-
(4, 5),
26-
(4, 6),
27-
(6, 1),
28-
]);
20+
let graph = TestGraph::new(0, &[(0, 1), (1, 2), (2, 3), (2, 4), (4, 5), (4, 6), (6, 1)]);
2921
let reachable = reachable(&graph);
3022
assert!((0..6).all(|i| reachable.can_reach(0, i)));
3123
assert!((1..6).all(|i| reachable.can_reach(1, i)));
@@ -43,15 +35,9 @@ fn test2() {
4335
// 30 -> 31 -> 32 -> 33
4436
// ^ v
4537
// 36 <- 34 -> 35
46-
let graph = TestGraph::new(30, &[
47-
(30, 31),
48-
(31, 32),
49-
(32, 33),
50-
(32, 34),
51-
(34, 35),
52-
(34, 36),
53-
(36, 31),
54-
]);
38+
let graph = TestGraph::new(30,
39+
&[(30, 31), (31, 32), (32, 33), (32, 34), (34, 35), (34, 36),
40+
(36, 31)]);
5541
let reachable = reachable(&graph);
5642
assert!((30..36).all(|i| reachable.can_reach(30, i)));
5743
assert!((31..36).all(|i| reachable.can_reach(31, i)));

‎src/librustc_data_structures/control_flow_graph/reference.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ impl<'graph, G: ControlFlowGraph> ControlFlowGraph for &'graph G {
2121
(**self).start_node()
2222
}
2323

24-
fn predecessors<'iter>(&'iter self, node: Self::Node)
25-
-> <Self as GraphPredecessors<'iter>>::Iter {
24+
fn predecessors<'iter>(&'iter self,
25+
node: Self::Node)
26+
-> <Self as GraphPredecessors<'iter>>::Iter {
2627
(**self).predecessors(node)
2728
}
2829

29-
fn successors<'iter>(&'iter self, node: Self::Node)
30-
-> <Self as GraphSuccessors<'iter>>::Iter {
30+
fn successors<'iter>(&'iter self, node: Self::Node) -> <Self as GraphSuccessors<'iter>>::Iter {
3131
(**self).successors(node)
3232
}
3333
}

‎src/librustc_data_structures/control_flow_graph/test.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl TestGraph {
2828
num_nodes: start_node + 1,
2929
start_node: start_node,
3030
successors: HashMap::new(),
31-
predecessors: HashMap::new()
31+
predecessors: HashMap::new(),
3232
};
3333
for &(source, target) in edges {
3434
graph.num_nodes = max(graph.num_nodes, source + 1);
@@ -55,13 +55,13 @@ impl ControlFlowGraph for TestGraph {
5555
self.num_nodes
5656
}
5757

58-
fn predecessors<'graph>(&'graph self, node: usize)
58+
fn predecessors<'graph>(&'graph self,
59+
node: usize)
5960
-> <Self as GraphPredecessors<'graph>>::Iter {
60-
self.predecessors[&node].iter().cloned()
61+
self.predecessors[&node].iter().cloned()
6162
}
6263

63-
fn successors<'graph>(&'graph self, node: usize)
64-
-> <Self as GraphSuccessors<'graph>>::Iter {
64+
fn successors<'graph>(&'graph self, node: usize) -> <Self as GraphSuccessors<'graph>>::Iter {
6565
self.successors[&node].iter().cloned()
6666
}
6767
}
@@ -75,4 +75,3 @@ impl<'graph> GraphSuccessors<'graph> for TestGraph {
7575
type Item = usize;
7676
type Iter = iter::Cloned<slice::Iter<'graph, usize>>;
7777
}
78-

‎src/librustc_data_structures/control_flow_graph/transpose.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ impl<G: ControlFlowGraph> TransposedGraph<G> {
2222
}
2323

2424
pub fn with_start(base_graph: G, start_node: G::Node) -> Self {
25-
TransposedGraph { base_graph: base_graph, start_node: start_node }
25+
TransposedGraph {
26+
base_graph: base_graph,
27+
start_node: start_node,
28+
}
2629
}
2730
}
2831

@@ -37,12 +40,14 @@ impl<G: ControlFlowGraph> ControlFlowGraph for TransposedGraph<G> {
3740
self.start_node
3841
}
3942

40-
fn predecessors<'graph>(&'graph self, node: Self::Node)
43+
fn predecessors<'graph>(&'graph self,
44+
node: Self::Node)
4145
-> <Self as GraphPredecessors<'graph>>::Iter {
4246
self.base_graph.successors(node)
4347
}
4448

45-
fn successors<'graph>(&'graph self, node: Self::Node)
49+
fn successors<'graph>(&'graph self,
50+
node: Self::Node)
4651
-> <Self as GraphSuccessors<'graph>>::Iter {
4752
self.base_graph.predecessors(node)
4853
}

0 commit comments

Comments
 (0)
Please sign in to comment.