Skip to content

Commit 92bc820

Browse files
committed
Use IndexSets of RecordedItemId
1 parent 0bf3e21 commit 92bc820

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

chalk-solve/src/logging_db.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//! `.chalk` files containing those definitions.
33
use std::{
44
borrow::Borrow,
5-
collections::BTreeSet,
65
fmt::{self, Debug, Display},
76
io::Write,
87
marker::PhantomData,
@@ -35,7 +34,7 @@ where
3534
I: Interner,
3635
{
3736
ws: WriterState<I, DB, P>,
38-
def_ids: Mutex<BTreeSet<RecordedItemId<I>>>,
37+
def_ids: Mutex<indexmap::IndexSet<RecordedItemId<I>>>,
3938
_phantom: PhantomData<DB>,
4039
}
4140

@@ -534,7 +533,7 @@ where
534533
}
535534
}
536535

537-
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
536+
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
538537
pub enum RecordedItemId<I: Interner> {
539538
Adt(AdtId<I>),
540539
Trait(TraitId<I>),
@@ -595,3 +594,10 @@ impl<I: Interner> RecordedItemId<I> {
595594
}
596595
}
597596
}
597+
598+
/// Utility for implementing Ord for RecordedItemId.
599+
#[derive(PartialEq, Eq, PartialOrd, Ord)]
600+
enum OrderedItemId<'a, DefId, AdtId> {
601+
DefId(&'a DefId),
602+
AdtId(&'a AdtId),
603+
}

chalk-solve/src/logging_db/id_collector.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use chalk_ir::{
66
visit::{SuperVisit, Visit},
77
AliasTy, DebruijnIndex, TyKind, WhereClause,
88
};
9-
use std::collections::BTreeSet;
109
use std::ops::ControlFlow;
1110

1211
/// Collects the identifiers needed to resolve all the names for a given
@@ -34,11 +33,11 @@ use std::ops::ControlFlow;
3433
/// resolution is successful.
3534
pub fn collect_unrecorded_ids<'i, I: Interner, DB: RustIrDatabase<I>>(
3635
db: &'i DB,
37-
identifiers: &'_ BTreeSet<RecordedItemId<I>>,
38-
) -> BTreeSet<RecordedItemId<I>> {
36+
identifiers: &'_ indexmap::IndexSet<RecordedItemId<I>>,
37+
) -> indexmap::IndexSet<RecordedItemId<I>> {
3938
let mut collector = IdCollector {
4039
db,
41-
found_identifiers: BTreeSet::new(),
40+
found_identifiers: indexmap::IndexSet::new(),
4241
};
4342
for id in identifiers {
4443
match *id {
@@ -96,7 +95,7 @@ pub fn collect_unrecorded_ids<'i, I: Interner, DB: RustIrDatabase<I>>(
9695

9796
struct IdCollector<'i, I: Interner, DB: RustIrDatabase<I>> {
9897
db: &'i DB,
99-
found_identifiers: BTreeSet<RecordedItemId<I>>,
98+
found_identifiers: indexmap::IndexSet<RecordedItemId<I>>,
10099
}
101100

102101
impl<'i, I: Interner, DB: RustIrDatabase<I>> IdCollector<'i, I, DB> {

0 commit comments

Comments
 (0)