Skip to content

Commit 77f262f

Browse files
committed
Rebase fixes; flounder instead of truncating, like SLG
1 parent a952c87 commit 77f262f

File tree

5 files changed

+29
-23
lines changed

5 files changed

+29
-23
lines changed

chalk-solve/src/clauses/generalize.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ impl<I: Interner> Generalize<'_, I> {
3030
let value = value
3131
.fold_with(&mut generalize, DebruijnIndex::INNERMOST)
3232
.unwrap();
33-
Binders {
34-
binders: generalize.binders,
35-
value,
36-
}
33+
Binders::new(generalize.binders, value)
3734
}
3835
}
3936

chalk-solve/src/recursive.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,7 @@ impl<'me, I: Interner> Solver<'me, I> {
369369
ProgramClauseData::Implies(implication) => {
370370
let res = self.solve_via_implication(
371371
canonical_goal,
372-
&Binders {
373-
binders: vec![],
374-
value: implication.clone(),
375-
},
372+
&Binders::new(vec![], implication.clone()),
376373
minimums,
377374
);
378375
if let (Ok(solution), priority) = res {
@@ -452,7 +449,10 @@ impl<'me, I: Interner> Solver<'me, I> {
452449
}
453450

454451
// and then try to solve
455-
(fulfill.solve(subst, minimums), clause.value.priority)
452+
(
453+
fulfill.solve(subst, minimums),
454+
clause.skip_binders().priority,
455+
)
456456
}
457457

458458
fn program_clauses_for_goal(

chalk-solve/src/recursive/fulfill.rs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,30 @@ impl<'s, 'db, I: Interner> Fulfill<'s, 'db, I> {
119119

120120
fn push_obligation(&mut self, obligation: Obligation<I>) {
121121
// truncate to avoid overflows
122-
let obligation = match obligation {
122+
match &obligation {
123123
Obligation::Prove(goal) => {
124-
let truncated =
125-
truncate::truncate(self.solver.program.interner(), &mut self.infer, 30, &goal);
126-
Obligation::Prove(truncated.value)
124+
if truncate::needs_truncation(
125+
self.solver.program.interner(),
126+
&mut self.infer,
127+
30,
128+
goal,
129+
) {
130+
// the goal is too big. Record that we should return Ambiguous
131+
self.cannot_prove = true;
132+
return;
133+
}
127134
}
128135
Obligation::Refute(goal) => {
129-
let truncated =
130-
truncate::truncate(self.solver.program.interner(), &mut self.infer, 30, &goal);
131-
Obligation::Refute(truncated.value)
136+
if truncate::needs_truncation(
137+
self.solver.program.interner(),
138+
&mut self.infer,
139+
30,
140+
goal,
141+
) {
142+
// the goal is too big. Record that we should return Ambiguous
143+
self.cannot_prove = true;
144+
return;
145+
}
132146
}
133147
};
134148
self.obligations.push(obligation);

chalk-solve/src/solve/slg.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ use chalk_engine::hh::HhGoal;
1414
use chalk_engine::{CompleteAnswer, ExClause, Literal};
1515
use chalk_ir::cast::Cast;
1616
use chalk_ir::cast::Caster;
17-
use chalk_ir::could_match::CouldMatch;
18-
use chalk_ir::interner::{HasInterner, Interner};
17+
use chalk_ir::interner::Interner;
1918
use chalk_ir::*;
2019

2120
use std::fmt::Debug;

tests/test/cycle.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,8 @@ fn overflow() {
165165
S<Z>: Q
166166
} yields[SolverChoice::slg(10, None)] {
167167
"Ambiguous; no inference guidance"
168-
}
169-
170-
goal {
171-
S<Z>: Q
172168
} yields[SolverChoice::recursive()] {
173-
"No possible solution"
169+
"Ambiguous; no inference guidance"
174170
}
175171
}
176172
}

0 commit comments

Comments
 (0)