Skip to content

Commit 557966e

Browse files
committed
Some fixes after rebase.
1 parent 40369a2 commit 557966e

File tree

7 files changed

+34
-17
lines changed

7 files changed

+34
-17
lines changed

chalk-integration/src/lowering.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use chalk_ir::cast::{Cast, Caster};
22
use chalk_ir::interner::{ChalkIr, HasInterner};
33
use chalk_ir::{
4-
self, AssocTypeId, BoundVar, ClausePriority, DebruijnIndex, ImplId, OpaqueTyId, ParameterKinds, QuantifiedWhereClauses,
5-
StructId, Substitution, TraitId,
4+
self, AssocTypeId, BoundVar, ClausePriority, DebruijnIndex, ImplId, OpaqueTyId, ParameterKinds,
5+
QuantifiedWhereClauses, StructId, Substitution, TraitId,
66
};
77
use chalk_parse::ast::*;
88
use chalk_rust_ir as rust_ir;
@@ -635,11 +635,15 @@ impl LowerTypeKind for TraitDefn {
635635

636636
impl LowerTypeKind for OpaqueTyDefn {
637637
fn lower_type_kind(&self) -> LowerResult<TypeKind> {
638+
let interner = &ChalkIr;
638639
let binders: Vec<_> = self.parameter_kinds.iter().map(|p| p.lower()).collect();
639640
Ok(TypeKind {
640641
sort: TypeSort::Opaque,
641642
name: self.identifier.str,
642-
binders: chalk_ir::Binders::new(binders.anonymize(), ()),
643+
binders: chalk_ir::Binders::new(
644+
ParameterKinds::from(interner, binders.anonymize()),
645+
crate::Unit,
646+
),
643647
})
644648
}
645649
}

chalk-ir/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,12 +1638,12 @@ impl<T: HasInterner> UCanonical<T> {
16381638
subst.is_identity_subst(interner)
16391639
}
16401640

1641-
pub fn trivial_substitution<I: Interner>(&self, interner: &I) -> Substitution<I> {
1641+
pub fn trivial_substitution(&self, interner: &T::Interner) -> Substitution<T::Interner> {
16421642
let binders = &self.canonical.binders;
16431643
Substitution::from(
16441644
interner,
16451645
binders
1646-
.iter()
1646+
.iter(interner)
16471647
.enumerate()
16481648
.map(|(index, pk)| {
16491649
let bound_var = BoundVar::new(DebruijnIndex::INNERMOST, index);

chalk-ir/src/tls.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use crate::interner::ChalkIr;
22
use crate::{
33
debug::SeparatorTraitRef, AliasTy, ApplicationTy, AssocTypeId, CanonicalVarKinds, Goal, Goals,
4-
Lifetime, OpaqueTy, OpaqueTyId, Parameter, ParameterKinds, ProgramClause, ProgramClauseImplication,
5-
ProgramClauses, ProjectionTy, QuantifiedWhereClauses, StructId, Substitution, TraitId, Ty,
4+
Lifetime, OpaqueTy, OpaqueTyId, Parameter, ParameterKinds, ProgramClause,
5+
ProgramClauseImplication, ProgramClauses, ProjectionTy, QuantifiedWhereClauses, StructId,
6+
Substitution, TraitId, Ty,
67
};
78
use std::cell::RefCell;
89
use std::fmt;

chalk-solve/src/clauses/generalize.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
use chalk_engine::fallible::Fallible;
1010
use chalk_ir::{
1111
fold::{Fold, Folder},
12-
interner::Interner,
13-
Binders, BoundVar, DebruijnIndex, Lifetime, LifetimeData, ParameterKind, Ty, TyData,
12+
interner::{HasInterner, Interner},
13+
Binders, BoundVar, DebruijnIndex, Lifetime, LifetimeData, ParameterKind, ParameterKinds, Ty,
14+
TyData,
1415
};
1516
use std::collections::HashMap;
1617

@@ -21,7 +22,11 @@ pub struct Generalize<'i, I: Interner> {
2122
}
2223

2324
impl<I: Interner> Generalize<'_, I> {
24-
pub fn apply<T: Fold<I, I>>(interner: &I, value: &T) -> Binders<T::Result> {
25+
pub fn apply<T>(interner: &I, value: &T) -> Binders<T::Result>
26+
where
27+
T: HasInterner<Interner = I> + Fold<I, I>,
28+
T::Result: HasInterner<Interner = I>,
29+
{
2530
let mut generalize = Generalize {
2631
binders: Vec::new(),
2732
mapping: HashMap::new(),
@@ -30,7 +35,7 @@ impl<I: Interner> Generalize<'_, I> {
3035
let value = value
3136
.fold_with(&mut generalize, DebruijnIndex::INNERMOST)
3237
.unwrap();
33-
Binders::new(generalize.binders, value)
38+
Binders::new(ParameterKinds::from(interner, generalize.binders), value)
3439
}
3540
}
3641

chalk-solve/src/recursive.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,10 @@ impl<'me, I: Interner> Solver<'me, I> {
366366
ProgramClauseData::Implies(implication) => {
367367
let res = self.solve_via_implication(
368368
canonical_goal,
369-
&Binders::new(vec![], implication.clone()),
369+
&Binders::new(
370+
ParameterKinds::from(self.program.interner(), vec![]),
371+
implication.clone(),
372+
),
370373
minimums,
371374
);
372375
if let (Ok(solution), priority) = res {
@@ -521,10 +524,10 @@ fn combine_with_priorities<I: Interner>(
521524
);
522525
(higher, ClausePriority::High)
523526
} else {
524-
(higher.combine(lower), ClausePriority::High)
527+
(higher.combine(lower, interner), ClausePriority::High)
525528
}
526529
}
527-
(_, _, a, b) => (a.combine(b), prio_a),
530+
(_, _, a, b) => (a.combine(b, interner), prio_a),
528531
}
529532
}
530533

chalk-solve/src/recursive/fulfill.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<'s, 'db, I: Interner> Fulfill<'s, 'db, I> {
108108
/// Wraps `InferenceTable::instantiate_in`
109109
pub(crate) fn instantiate_binders_existentially<T>(
110110
&mut self,
111-
arg: impl IntoBindersAndValue<Value = T>,
111+
arg: impl IntoBindersAndValue<'s, I, Value = T>,
112112
) -> T::Result
113113
where
114114
T: Fold<I, I>,

chalk-solve/src/solve.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,18 @@ impl<I: Interner> Solution<I> {
6969
// Clone`.
7070
//
7171
// But you get the idea.
72-
pub(crate) fn combine(self, other: Solution<I>) -> Solution<I> {
72+
pub(crate) fn combine(self, other: Solution<I>, interner: &I) -> Solution<I> {
7373
use self::Guidance::*;
7474

7575
if self == other {
7676
return self;
7777
}
7878

79-
debug!("combine {} with {}", self, other);
79+
debug!(
80+
"combine {} with {}",
81+
self.display(interner),
82+
other.display(interner)
83+
);
8084

8185
// Otherwise, always downgrade to Ambig:
8286

0 commit comments

Comments
 (0)