Skip to content

Commit 914459a

Browse files
committed
Add Eq and PartialEq to Idx
1 parent 6a00b92 commit 914459a

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ where
419419

420420
// Move the stack to a local variable. We want to utilize the existing allocation and
421421
// mutably borrow it without borrowing self at the same time.
422-
let mut successors_stack = core::mem::take(&mut self.successors_stack);
422+
let mut successors_stack: Vec<S> = core::mem::take(&mut self.successors_stack);
423423
debug_assert_eq!(successors_stack.len(), 0);
424424

425425
let mut stack: Vec<VisitingNodeFrame<G, _>> = vec![VisitingNodeFrame {
@@ -524,7 +524,7 @@ where
524524

525525
// Completed walk, remove `node` from the stack.
526526
let r = self.node_stack.pop();
527-
debug_assert_eq!(r, Some(node));
527+
debug_assert_eq!(r.unwrap().index(), node.index());
528528

529529
// Remove the frame, it's done.
530530
let frame = stack.pop().unwrap();

compiler/rustc_data_structures/src/sorted_map/index_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl<I: Idx, K: Eq, V: Eq> Eq for SortedIndexMultiMap<I, K, V> {}
9797
impl<I: Idx, K: PartialEq, V: PartialEq> PartialEq for SortedIndexMultiMap<I, K, V> {
9898
fn eq(&self, other: &Self) -> bool {
9999
// No need to compare the sorted index. If the items are the same, the index will be too.
100-
self.items == other.items
100+
self == other
101101
}
102102
}
103103

compiler/rustc_index/src/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::vec;
1212
/// Represents some newtyped `usize` wrapper.
1313
///
1414
/// Purpose: avoid mixing indexes for different bitvector domains.
15-
pub trait Idx: Copy + 'static + Debug + Hash {
15+
pub trait Idx: Copy + 'static + Eq + PartialEq + Debug + Hash {
1616
fn new(idx: usize) -> Self;
1717

1818
fn index(self) -> usize;

0 commit comments

Comments
 (0)