Skip to content

Commit 6a00b92

Browse files
committed
Continue fixing comparisons
1 parent 4d78bac commit 6a00b92

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

compiler/rustc_data_structures/src/graph/dominators/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn dominators<G: ControlFlowGraph>(graph: G) -> Dominators<G::Node> {
2121

2222
fn dominators_given_rpo<G: ControlFlowGraph>(graph: G, rpo: &[G::Node]) -> Dominators<G::Node> {
2323
let start_node = graph.start_node();
24-
assert_eq!(rpo[0], start_node);
24+
assert_eq!(rpo[0].index(), start_node.index());
2525

2626
// compute the post order index (rank) for each node
2727
let mut post_order_rank = IndexVec::from_elem_n(0, graph.num_nodes());
@@ -49,7 +49,9 @@ fn dominators_given_rpo<G: ControlFlowGraph>(graph: G, rpo: &[G::Node]) -> Domin
4949
}
5050
}
5151

52-
if new_idom != immediate_dominators[node] {
52+
if new_idom.clone().unwrap().index()
53+
!= immediate_dominators[node].clone().unwrap().index()
54+
{
5355
immediate_dominators[node] = new_idom;
5456
changed = true;
5557
}
@@ -65,7 +67,7 @@ fn intersect<Node: Idx>(
6567
mut node1: Node,
6668
mut node2: Node,
6769
) -> Node {
68-
while node1 != node2 {
70+
while node1.index() != node2.index() {
6971
while post_order_rank[node1] < post_order_rank[node2] {
7072
node1 = immediate_dominators[node1].unwrap();
7173
}
@@ -105,7 +107,7 @@ impl<Node: Idx> Dominators<Node> {
105107

106108
pub fn is_dominated_by(&self, node: Node, dom: Node) -> bool {
107109
// FIXME -- could be optimized by using post-order-rank
108-
self.dominators(node).any(|n| n == dom)
110+
self.dominators(node).any(|n| n.index() == dom.index())
109111
}
110112

111113
/// Provide deterministic ordering of nodes such that, if any two nodes have a dominator
@@ -128,7 +130,7 @@ impl<'dom, Node: Idx> Iterator for Iter<'dom, Node> {
128130
fn next(&mut self) -> Option<Self::Item> {
129131
if let Some(node) = self.node {
130132
let dom = self.dominators.immediate_dominator(node);
131-
if dom == node {
133+
if dom.index() == node.index() {
132134
self.node = None; // reached the root
133135
} else {
134136
self.node = Some(dom);

compiler/rustc_data_structures/src/graph/scc/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ where
311311
// We test this, to be extremely sure that we never
312312
// ever break our termination condition for the
313313
// reverse iteration loop.
314-
assert!(node != parent, "Node can not be in cycle with itself");
314+
assert!(node.index() != parent.index(), "Node can not be in cycle with itself");
315315
// Store the previous node as an inverted list link
316316
self.node_states[node] = NodeState::InCycleWith { parent: previous_node };
317317
// Update to parent node.
@@ -359,7 +359,7 @@ where
359359
// will know when we hit the state where previous_node == node.
360360
loop {
361361
// Back at the beginning, we can return.
362-
if previous_node == node {
362+
if previous_node.index() == node.index() {
363363
return node_state;
364364
}
365365
// Update to previous node in the link.

compiler/rustc_data_structures/src/graph/vec_graph/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub struct VecGraph<N: Idx> {
2020
impl<N: Idx> VecGraph<N> {
2121
pub fn new(num_nodes: usize, mut edge_pairs: Vec<(N, N)>) -> Self {
2222
// Sort the edges by the source -- this is important.
23-
edge_pairs.sort();
23+
edge_pairs.sort_by_cached_key(|&edge_pairs| (edge_pairs.0.index(), edge_pairs.1.index()));
2424

2525
let num_edges = edge_pairs.len();
2626

compiler/rustc_middle/src/ty/fast_reject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub type SimplifiedType = SimplifiedTypeGen<DefId>;
1919
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, TyEncodable, TyDecodable)]
2020
pub enum SimplifiedTypeGen<D>
2121
where
22-
D: Copy + Debug + Ord + Eq,
22+
D: Copy + Debug + Eq,
2323
{
2424
BoolSimplifiedType,
2525
CharSimplifiedType,

0 commit comments

Comments
 (0)