|
2 | 2 | //! `.chalk` files containing those definitions. |
3 | 3 | use std::{ |
4 | 4 | borrow::Borrow, |
5 | | - cmp::{Ord, Ordering}, |
6 | | - collections::BTreeSet, |
| 5 | + // cmp::{Ord, Ordering}, |
| 6 | + // collections::BTreeSet, |
7 | 7 | fmt::{self, Debug, Display}, |
8 | 8 | io::Write, |
9 | 9 | marker::PhantomData, |
|
36 | 36 | I: Interner, |
37 | 37 | { |
38 | 38 | ws: WriterState<I, DB, P>, |
39 | | - def_ids: Mutex<BTreeSet<RecordedItemId<I>>>, |
| 39 | + def_ids: Mutex<indexmap::IndexSet<RecordedItemId<I>>>, |
40 | 40 | _phantom: PhantomData<DB>, |
41 | 41 | } |
42 | 42 |
|
@@ -535,7 +535,7 @@ where |
535 | 535 | } |
536 | 536 | } |
537 | 537 |
|
538 | | -#[derive(Copy, Clone, PartialEq, Eq, Debug)] |
| 538 | +#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)] |
539 | 539 | pub enum RecordedItemId<I: Interner> { |
540 | 540 | Adt(AdtId<I>), |
541 | 541 | Trait(TraitId<I>), |
@@ -581,37 +581,37 @@ impl<I: Interner> From<GeneratorId<I>> for RecordedItemId<I> { |
581 | 581 | } |
582 | 582 | } |
583 | 583 |
|
584 | | -/// Utility for implementing Ord for RecordedItemId. |
585 | | -#[derive(PartialEq, Eq, PartialOrd, Ord)] |
586 | | -enum OrderedItemId<'a, DefId, AdtId> { |
587 | | - DefId(&'a DefId), |
588 | | - AdtId(&'a AdtId), |
589 | | -} |
590 | | - |
591 | | -impl<I: Interner> RecordedItemId<I> { |
592 | | - /// Extract internal identifier. Allows for absolute ordering matching the |
593 | | - /// order in which chalk saw things (and thus reproducing that order in |
594 | | - /// printed programs) |
595 | | - fn ordered_item_id(&self) -> OrderedItemId<'_, I::DefId, I::InternedAdtId> { |
596 | | - match self { |
597 | | - RecordedItemId::Trait(TraitId(x)) |
598 | | - | RecordedItemId::Impl(ImplId(x)) |
599 | | - | RecordedItemId::OpaqueTy(OpaqueTyId(x)) |
600 | | - | RecordedItemId::Generator(GeneratorId(x)) |
601 | | - | RecordedItemId::FnDef(FnDefId(x)) => OrderedItemId::DefId(x), |
602 | | - RecordedItemId::Adt(AdtId(x)) => OrderedItemId::AdtId(x), |
603 | | - } |
604 | | - } |
605 | | -} |
606 | | - |
607 | | -impl<I: Interner> PartialOrd for RecordedItemId<I> { |
608 | | - fn partial_cmp(&self, other: &Self) -> Option<Ordering> { |
609 | | - Some(self.cmp(other)) |
610 | | - } |
611 | | -} |
612 | | - |
613 | | -impl<I: Interner> Ord for RecordedItemId<I> { |
614 | | - fn cmp(&self, other: &Self) -> Ordering { |
615 | | - self.ordered_item_id().cmp(&other.ordered_item_id()) |
616 | | - } |
617 | | -} |
| 584 | +// /// Utility for implementing Ord for RecordedItemId. |
| 585 | +// #[derive(PartialEq, Eq, PartialOrd, Ord)] |
| 586 | +// enum OrderedItemId<'a, DefId, AdtId> { |
| 587 | +// DefId(&'a DefId), |
| 588 | +// AdtId(&'a AdtId), |
| 589 | +// } |
| 590 | + |
| 591 | +// impl<I: Interner> RecordedItemId<I> { |
| 592 | +// /// Extract internal identifier. Allows for absolute ordering matching the |
| 593 | +// /// order in which chalk saw things (and thus reproducing that order in |
| 594 | +// /// printed programs) |
| 595 | +// fn ordered_item_id(&self) -> indexmap::IndexMap<I::DefId, I::InternedAdtId> { |
| 596 | +// match self { |
| 597 | +// RecordedItemId::Trait(TraitId(x)) |
| 598 | +// | RecordedItemId::Impl(ImplId(x)) |
| 599 | +// | RecordedItemId::OpaqueTy(OpaqueTyId(x)) |
| 600 | +// | RecordedItemId::Generator(GeneratorId(x)) |
| 601 | +// | RecordedItemId::FnDef(FnDefId(x)) => OrderedItemId::DefId(x), |
| 602 | +// RecordedItemId::Adt(AdtId(x)) => OrderedItemId::AdtId(x), |
| 603 | +// } |
| 604 | +// } |
| 605 | +// } |
| 606 | + |
| 607 | +// impl<I: Interner> PartialOrd for RecordedItemId<I> { |
| 608 | +// fn partial_cmp(&self, other: &Self) -> Option<Ordering> { |
| 609 | +// Some(self.cmp(other)) |
| 610 | +// } |
| 611 | +// } |
| 612 | + |
| 613 | +// impl<I: Interner> Ord for RecordedItemId<I> { |
| 614 | +// fn cmp(&self, other: &Self) -> Ordering { |
| 615 | +// self.ordered_item_id().cmp(&other.ordered_item_id()) |
| 616 | +// } |
| 617 | +// } |
0 commit comments