Skip to content

Commit ae690eb

Browse files
committed
Remove hhgoal
1 parent b9037b3 commit ae690eb

File tree

6 files changed

+35
-102
lines changed

6 files changed

+35
-102
lines changed

chalk-engine/src/context.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
//! `DomainGoal` type, add arena lifetime parameters, and more. See
66
//! [`Context`] trait for a list of types.
77
8-
use crate::hh::HhGoal;
98
use crate::{CompleteAnswer, ExClause};
109
use chalk_base::results::{Fallible, Floundered};
1110
use chalk_ir::interner::Interner;
@@ -40,11 +39,6 @@ pub trait Context<I: Interner>: Clone + Debug {
4039
/// Represents an inference table.
4140
type InferenceTable: InferenceTable<I, Self> + Clone;
4241

43-
/// How to relate two kinds when unifying: for example in rustc, we
44-
/// may want to unify parameters either for the sub-typing relation or for
45-
/// the equality relation.
46-
type Variance;
47-
4842
/// Selects the next appropriate subgoal index for evaluation.
4943
/// Used by: logic
5044
fn next_subgoal_index(ex_clause: &ExClause<I>) -> usize;
@@ -141,16 +135,6 @@ pub trait ContextOps<I: Interner, C: Context<I>>: Sized + Clone + Debug + Aggreg
141135
u_canon: &UCanonical<InEnvironment<Goal<I>>>,
142136
canonical_subst: &Canonical<AnswerSubst<I>>,
143137
) -> bool;
144-
145-
/// Convert the context's goal type into the `HhGoal` type that
146-
/// the SLG solver understands. The expectation is that the
147-
/// context's goal type has the same set of variants, but with
148-
/// different names and a different setup. If you inspect
149-
/// `HhGoal`, you will see that this is a "shallow" or "lazy"
150-
/// conversion -- that is, we convert the outermost goal into an
151-
/// `HhGoal`, but the goals contained within are left as context
152-
/// goals.
153-
fn into_hh_goal(&self, goal: Goal<I>) -> HhGoal<I, C>;
154138
}
155139

156140
/// Methods for combining solutions to yield an aggregate solution.
@@ -238,7 +222,6 @@ pub trait UnificationOps<I: Interner, C: Context<I>> {
238222
&mut self,
239223
interner: &I,
240224
environment: &Environment<I>,
241-
variance: C::Variance,
242225
a: &GenericArg<I>,
243226
b: &GenericArg<I>,
244227
ex_clause: &mut ExClause<I>,

chalk-engine/src/hh.rs

Lines changed: 0 additions & 27 deletions
This file was deleted.

chalk-engine/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ mod boring_impls;
6666
pub mod context;
6767
mod derived;
6868
pub mod forest;
69-
pub mod hh;
7069
mod logic;
7170
mod simplify;
7271
mod stack;

chalk-engine/src/logic.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::context::{
22
Context, ContextOps, InferenceTable, ResolventOps, TruncateOps, UnificationOps,
33
};
44
use crate::forest::Forest;
5-
use crate::hh::HhGoal;
65
use crate::stack::{Stack, StackIndex};
76
use crate::strand::{CanonicalStrand, SelectedSubgoal, Strand};
87
use crate::table::{AnswerIndex, Table};
@@ -12,7 +11,7 @@ use crate::{
1211
use chalk_base::results::{Floundered, NoSolution};
1312

1413
use chalk_ir::interner::Interner;
15-
use chalk_ir::{Canonical, ConstrainedSubst, Goal, InEnvironment, Substitution, UCanonical, UniverseMap};
14+
use chalk_ir::{Canonical, ConstrainedSubst, Goal, GoalData, InEnvironment, Substitution, UCanonical, UniverseMap};
1615

1716
type RootSearchResult<T> = Result<T, RootSearchFail>;
1817

@@ -234,7 +233,7 @@ impl<I: Interner, C: Context<I>> Forest<I, C> {
234233
/// domain goal, these strands are created from the program
235234
/// clauses as well as the clauses found in the environment. If
236235
/// the table represents a non-domain goal, such as `for<T> G`
237-
/// etc, then `simplify_hh_goal` is invoked to create a strand
236+
/// etc, then `simplify_goal` is invoked to create a strand
238237
/// that breaks the goal down.
239238
///
240239
/// In terms of the NFTD paper, this corresponds to the *Program
@@ -247,8 +246,8 @@ impl<I: Interner, C: Context<I>> Forest<I, C> {
247246
) -> Table<I> {
248247
let mut table = Table::new(goal.clone(), context.is_coinductive(&goal));
249248
let (mut infer, subst, environment, goal) = context.instantiate_ucanonical_goal(&goal);
250-
match context.into_hh_goal(goal) {
251-
HhGoal::DomainGoal(domain_goal) => {
249+
match goal.data(context.interner()) {
250+
GoalData::DomainGoal(domain_goal) => {
252251
match context.program_clauses(&environment, &domain_goal, &mut infer) {
253252
Ok(clauses) => {
254253
for clause in clauses {
@@ -280,7 +279,7 @@ impl<I: Interner, C: Context<I>> Forest<I, C> {
280279
}
281280
}
282281

283-
hh_goal => {
282+
_ => {
284283
// `canonical_goal` is an HH goal. We can simplify it
285284
// into a series of *literals*, all of which must be
286285
// true. Thus, in EWFS terms, we are effectively
@@ -290,7 +289,7 @@ impl<I: Interner, C: Context<I>> Forest<I, C> {
290289
// applying built-in "meta program clauses" that
291290
// reduce HH goals into Domain goals.
292291
if let Ok(ex_clause) =
293-
Self::simplify_hh_goal(context, &mut infer, subst, environment, hh_goal)
292+
Self::simplify_goal(context, &mut infer, subst, environment, goal)
294293
{
295294
info!(
296295
"pushing initial strand with ex-clause: {:#?}",

chalk-engine/src/simplify.rs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
use crate::context::{Context, ContextOps, InferenceTable};
22
use crate::forest::Forest;
3-
use crate::hh::HhGoal;
43
use crate::{ExClause, Literal, TimeStamp};
54
use chalk_base::results::Fallible;
65

76
use chalk_ir::interner::Interner;
8-
use chalk_ir::{Environment, InEnvironment, Substitution};
7+
use chalk_ir::{Environment, InEnvironment, Goal, GoalData, Substitution, QuantifierKind};
98

109
impl<I: Interner, C: Context<I>> Forest<I, C> {
1110
/// Simplifies an HH goal into a series of positive domain goals
1211
/// and negative HH goals. This operation may fail if the HH goal
1312
/// includes unifications that cannot be completed.
14-
pub(super) fn simplify_hh_goal(
13+
pub(super) fn simplify_goal(
1514
context: &impl ContextOps<I, C>,
1615
infer: &mut dyn InferenceTable<I, C>,
1716
subst: Substitution<I>,
1817
initial_environment: Environment<I>,
19-
initial_hh_goal: HhGoal<I, C>,
18+
initial_hh_goal: Goal<I>,
2019
) -> Fallible<ExClause<I>> {
2120
let mut ex_clause = ExClause {
2221
subst,
@@ -32,45 +31,46 @@ impl<I: Interner, C: Context<I>> Forest<I, C> {
3231
let mut pending_goals = vec![(initial_environment, initial_hh_goal)];
3332

3433
while let Some((environment, hh_goal)) = pending_goals.pop() {
35-
match hh_goal {
36-
HhGoal::ForAll(subgoal) => {
34+
match hh_goal.data(context.interner()) {
35+
GoalData::Quantified(QuantifierKind::ForAll, subgoal) => {
3736
let subgoal =
3837
infer.instantiate_binders_universally(context.interner(), &subgoal);
39-
pending_goals.push((environment, context.into_hh_goal(subgoal)));
38+
pending_goals.push((environment, subgoal.clone()));
4039
}
41-
HhGoal::Exists(subgoal) => {
40+
GoalData::Quantified(QuantifierKind::Exists, subgoal) => {
4241
let subgoal =
4342
infer.instantiate_binders_existentially(context.interner(), &subgoal);
44-
pending_goals.push((environment, context.into_hh_goal(subgoal)))
43+
pending_goals.push((environment, subgoal.clone()));
4544
}
46-
HhGoal::Implies(wc, subgoal) => {
47-
let new_environment = context.add_clauses(&environment, wc);
48-
pending_goals.push((new_environment, context.into_hh_goal(subgoal)));
45+
GoalData::Implies(wc, subgoal) => {
46+
let new_environment = context.add_clauses(&environment, wc.clone());
47+
pending_goals.push((new_environment, subgoal.clone()));
4948
}
50-
HhGoal::All(subgoals) => {
51-
for subgoal in subgoals {
52-
pending_goals.push((environment.clone(), context.into_hh_goal(subgoal)));
49+
GoalData::All(subgoals) => {
50+
for subgoal in subgoals.iter(context.interner()) {
51+
pending_goals.push((environment.clone(), subgoal.clone()));
5352
}
5453
}
55-
HhGoal::Not(subgoal) => {
54+
GoalData::Not(subgoal) => {
5655
ex_clause
5756
.subgoals
58-
.push(Literal::Negative(InEnvironment::new(&environment, subgoal)));
57+
.push(Literal::Negative(InEnvironment::new(&environment, subgoal.clone())));
5958
}
60-
HhGoal::Unify(variance, a, b) => infer.unify_generic_args_into_ex_clause(
61-
context.interner(),
62-
&environment,
63-
variance,
64-
&a,
65-
&b,
66-
&mut ex_clause,
67-
)?,
68-
HhGoal::DomainGoal(domain_goal) => {
59+
GoalData::EqGoal(goal) => {
60+
infer.unify_generic_args_into_ex_clause(
61+
context.interner(),
62+
&environment,
63+
&goal.a,
64+
&goal.b,
65+
&mut ex_clause,
66+
)?
67+
},
68+
GoalData::DomainGoal(domain_goal) => {
6969
ex_clause
7070
.subgoals
71-
.push(Literal::Positive(InEnvironment::new(&environment, context.into_goal(domain_goal))));
71+
.push(Literal::Positive(InEnvironment::new(&environment, context.into_goal(domain_goal.clone()))));
7272
}
73-
HhGoal::CannotProve => {
73+
GoalData::CannotProve(()) => {
7474
ex_clause.ambiguous = true;
7575
}
7676
}

chalk-solve/src/solve/slg.rs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ use crate::RustIrDatabase;
99
use chalk_base::results::{Fallible, Floundered};
1010
use chalk_derive::HasInterner;
1111
use chalk_engine::context;
12-
use chalk_engine::hh::HhGoal;
13-
use chalk_engine::{CompleteAnswer, ExClause, Literal};
12+
use chalk_engine::{ExClause, Literal};
1413
use chalk_ir::cast::Cast;
1514
use chalk_ir::cast::Caster;
1615
use chalk_ir::interner::Interner;
@@ -67,7 +66,6 @@ pub struct TruncatingInferenceTable<I: Interner> {
6766
impl<I: Interner> context::Context<I> for SlgContext<I> {
6867
type Solution = Solution<I>;
6968
type InferenceTable = TruncatingInferenceTable<I>;
70-
type Variance = ();
7169

7270
// Used by: logic
7371
fn next_subgoal_index(ex_clause: &ExClause<I>) -> usize {
@@ -210,24 +208,6 @@ impl<'me, I: Interner> context::ContextOps<I, SlgContext<I>> for SlgContextOps<'
210208
let interner = self.interner();
211209
u_canon.is_trivial_substitution(interner, canonical_subst)
212210
}
213-
214-
fn into_hh_goal(&self, goal: Goal<I>) -> HhGoal<I, SlgContext<I>> {
215-
let interner = self.interner();
216-
match goal.data(interner).clone() {
217-
GoalData::Quantified(QuantifierKind::ForAll, binders_goal) => {
218-
HhGoal::ForAll(binders_goal)
219-
}
220-
GoalData::Quantified(QuantifierKind::Exists, binders_goal) => {
221-
HhGoal::Exists(binders_goal)
222-
}
223-
GoalData::Implies(dg, subgoal) => HhGoal::Implies(dg, subgoal),
224-
GoalData::All(goals) => HhGoal::All(goals.iter(interner).cloned().collect()),
225-
GoalData::Not(g1) => HhGoal::Not(g1),
226-
GoalData::EqGoal(EqGoal { a, b }) => HhGoal::Unify((), a, b),
227-
GoalData::DomainGoal(domain_goal) => HhGoal::DomainGoal(domain_goal),
228-
GoalData::CannotProve(()) => HhGoal::CannotProve,
229-
}
230-
}
231211
}
232212

233213
impl<I: Interner> TruncatingInferenceTable<I> {
@@ -332,7 +312,6 @@ impl<I: Interner> context::UnificationOps<I, SlgContext<I>> for TruncatingInfere
332312
&mut self,
333313
interner: &I,
334314
environment: &Environment<I>,
335-
_: (),
336315
a: &GenericArg<I>,
337316
b: &GenericArg<I>,
338317
ex_clause: &mut ExClause<I>,

0 commit comments

Comments
 (0)