Skip to content

Commit 51b3e22

Browse files
committed
Use FxHashMap/FxHashSet and add well-formed clause for tuples
1 parent 2c94b0e commit 51b3e22

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

chalk-solve/src/clauses.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,9 @@ fn match_type_name<I: Interner>(
461461
TypeName::Scalar(_) => {
462462
builder.push_fact(WellFormed::Ty(application.clone().intern(interner)))
463463
}
464-
TypeName::Tuple(_) => (),
464+
TypeName::Tuple(_) => {
465+
builder.push_fact(WellFormed::Ty(application.clone().intern(interner)))
466+
}
465467
}
466468
}
467469

chalk-solve/src/clauses/generalize.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ use chalk_ir::{
1313
Binders, BoundVar, DebruijnIndex, Lifetime, LifetimeData, ParameterKind, ParameterKinds, Ty,
1414
TyData,
1515
};
16-
use std::collections::HashMap;
16+
use rustc_hash::FxHashMap;
1717

1818
pub struct Generalize<'i, I: Interner> {
1919
binders: Vec<ParameterKind<()>>,
20-
mapping: HashMap<BoundVar, usize>,
20+
mapping: FxHashMap<BoundVar, usize>,
2121
interner: &'i I,
2222
}
2323

@@ -29,7 +29,7 @@ impl<I: Interner> Generalize<'_, I> {
2929
{
3030
let mut generalize = Generalize {
3131
binders: Vec::new(),
32-
mapping: HashMap::new(),
32+
mapping: FxHashMap::default(),
3333
interner,
3434
};
3535
let value = value

chalk-solve/src/recursive/fulfill.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use infer::{
1111
InferenceTable, ParameterEnaVariable, ParameterEnaVariableExt,
1212
};
1313
use interner::HasInterner;
14-
use std::collections::HashSet;
14+
use rustc_hash::FxHashSet;
1515
use std::fmt::Debug;
1616
use zip::Zip;
1717

@@ -77,7 +77,7 @@ pub(crate) struct Fulfill<'s, 'db, I: Interner> {
7777

7878
/// Lifetime constraints that must be fulfilled for a solution to be fully
7979
/// validated.
80-
constraints: HashSet<InEnvironment<Constraint<I>>>,
80+
constraints: FxHashSet<InEnvironment<Constraint<I>>>,
8181

8282
/// Record that a goal has been processed that can neither be proved nor
8383
/// refuted. In such a case the solution will be either `CannotProve`, or `Err`
@@ -99,7 +99,7 @@ impl<'s, 'db, I: Interner> Fulfill<'s, 'db, I> {
9999
solver,
100100
infer,
101101
obligations: vec![],
102-
constraints: HashSet::new(),
102+
constraints: FxHashSet::default(),
103103
cannot_prove: false,
104104
};
105105
(fulfill, subst, canonical_goal)

chalk-solve/src/recursive/search_graph.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std::collections::HashMap;
21
use std::ops::Add;
32
use std::ops::Index;
43
use std::ops::IndexMut;
@@ -12,7 +11,7 @@ use chalk_ir::{interner::Interner, ClausePriority};
1211
use rustc_hash::FxHashMap;
1312

1413
pub(super) struct SearchGraph<I: Interner> {
15-
indices: HashMap<UCanonicalGoal<I>, DepthFirstNumber>,
14+
indices: FxHashMap<UCanonicalGoal<I>, DepthFirstNumber>,
1615
nodes: Vec<Node<I>>,
1716
}
1817

@@ -41,7 +40,7 @@ pub(super) struct Node<I: Interner> {
4140
impl<I: Interner> SearchGraph<I> {
4241
pub(crate) fn new() -> Self {
4342
SearchGraph {
44-
indices: HashMap::new(),
43+
indices: FxHashMap::default(),
4544
nodes: vec![],
4645
}
4746
}

0 commit comments

Comments
 (0)