Skip to content

Commit

Permalink
import indexmap
Browse files Browse the repository at this point in the history
  • Loading branch information
pierwill committed Dec 17, 2021
1 parent 045f19d commit d270a5e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
6 changes: 4 additions & 2 deletions chalk-solve/src/coherence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use chalk_ir::{self, ImplId, TraitId};
use std::fmt;
use std::sync::Arc;

use indexmap::IndexMap;

pub mod orphan;
mod solve;

Expand Down Expand Up @@ -41,13 +43,13 @@ impl<I: Interner> std::error::Error for CoherenceError<I> {}
/// This basically encodes which impls specialize one another.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct SpecializationPriorities<I: Interner> {
map: indexmap::IndexMap<ImplId<I>, SpecializationPriority>,
map: IndexMap<ImplId<I>, SpecializationPriority>,
}

impl<I: Interner> SpecializationPriorities<I> {
pub fn new() -> Self {
Self {
map: indexmap::IndexMap::new(),
map: IndexMap::new(),
}
}

Expand Down
6 changes: 3 additions & 3 deletions chalk-solve/src/display/state.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//! Persistent state passed down between writers.
//!
//! This is essentially `InternalWriterState` and other things supporting that.
use std::{
Expand All @@ -12,6 +11,7 @@ use std::{

use crate::RustIrDatabase;
use chalk_ir::{interner::Interner, *};
use indexmap::IndexMap;
use itertools::Itertools;

/// Like a BoundVar, but with the debrujin index inverted so as to create a
Expand Down Expand Up @@ -46,15 +46,15 @@ enum UnifiedId<I: Interner> {
pub struct IdAliasStore<T> {
/// Map from the DefIds we've encountered to a u32 alias id unique to all ids
/// the same name.
aliases: indexmap::IndexMap<T, u32>,
aliases: IndexMap<T, u32>,
/// Map from each name to the next unused u32 alias id.
next_unused_for_name: BTreeMap<String, u32>,
}

impl<T> Default for IdAliasStore<T> {
fn default() -> Self {
IdAliasStore {
aliases: indexmap::IndexMap::default(),
aliases: IndexMap::default(),
next_unused_for_name: BTreeMap::default(),
}
}
Expand Down
4 changes: 3 additions & 1 deletion chalk-solve/src/logging_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use crate::{
};
use chalk_ir::{interner::Interner, *};

use indexmap::IndexSet;

mod id_collector;

/// Wraps another `RustIrDatabase` (`DB`) and records which definitions are
Expand All @@ -34,7 +36,7 @@ where
I: Interner,
{
ws: WriterState<I, DB, P>,
def_ids: Mutex<indexmap::IndexSet<RecordedItemId<I>>>,
def_ids: Mutex<IndexSet<RecordedItemId<I>>>,
_phantom: PhantomData<DB>,
}

Expand Down
10 changes: 6 additions & 4 deletions chalk-solve/src/logging_db/id_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use chalk_ir::{
};
use std::ops::ControlFlow;

use indexmap::IndexSet;

/// Collects the identifiers needed to resolve all the names for a given
/// set of identifers, excluding identifiers we already have.
///
Expand All @@ -33,11 +35,11 @@ use std::ops::ControlFlow;
/// resolution is successful.
pub fn collect_unrecorded_ids<'i, I: Interner, DB: RustIrDatabase<I>>(
db: &'i DB,
identifiers: &'_ indexmap::IndexSet<RecordedItemId<I>>,
) -> indexmap::IndexSet<RecordedItemId<I>> {
identifiers: &'_ IndexSet<RecordedItemId<I>>,
) -> IndexSet<RecordedItemId<I>> {
let mut collector = IdCollector {
db,
found_identifiers: indexmap::IndexSet::new(),
found_identifiers: IndexSet::new(),
};
for id in identifiers {
match *id {
Expand Down Expand Up @@ -95,7 +97,7 @@ pub fn collect_unrecorded_ids<'i, I: Interner, DB: RustIrDatabase<I>>(

struct IdCollector<'i, I: Interner, DB: RustIrDatabase<I>> {
db: &'i DB,
found_identifiers: indexmap::IndexSet<RecordedItemId<I>>,
found_identifiers: IndexSet<RecordedItemId<I>>,
}

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

0 comments on commit d270a5e

Please sign in to comment.