Skip to content

Commit 47a3880

Browse files
adamrkjackh726
authored andcommitted
simplify SubGoalSelection variants
1 parent 129a150 commit 47a3880

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

chalk-engine/src/logic.rs

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,9 @@ enum SubGoalSelection {
5353
/// coinductive, or create a cycle.
5454
Selected,
5555

56-
/// This strand has no remaining subgoals.
57-
NoRemainingSubgoals,
58-
59-
/// This strand has floundered. Either all the positive subgoals
60-
/// have floundered or a single negative subgoal has floundered.
61-
Floundered,
56+
/// This strand has no remaining subgoals, but there may still be
57+
/// floundered subgoals.
58+
NotSelected,
6259
}
6360

6461
/// This is returned `on_no_remaining_subgoals`
@@ -506,12 +503,8 @@ impl<'forest, I: Interner, C: Context<I> + 'forest, CO: ContextOps<I, C> + 'fore
506503
self.on_subgoal_selected(strand)?;
507504
continue;
508505
}
509-
selection @ SubGoalSelection::NoRemainingSubgoals
510-
| selection @ SubGoalSelection::Floundered => {
511-
match self.on_no_remaining_subgoals(
512-
strand,
513-
selection == SubGoalSelection::Floundered,
514-
) {
506+
SubGoalSelection::NotSelected => {
507+
match self.on_no_remaining_subgoals(strand) {
515508
NoRemainingSubgoalsResult::RootAnswerAvailable => return Ok(()),
516509
NoRemainingSubgoalsResult::RootSearchFail(e) => return Err(e),
517510
NoRemainingSubgoalsResult::Success => {}
@@ -895,11 +888,8 @@ impl<'forest, I: Interner, C: Context<I> + 'forest, CO: ContextOps<I, C> + 'fore
895888
Ok(())
896889
}
897890

898-
fn on_no_remaining_subgoals(
899-
&mut self,
900-
strand: Strand<I, C>,
901-
floundered: bool,
902-
) -> NoRemainingSubgoalsResult {
891+
fn on_no_remaining_subgoals(&mut self, strand: Strand<I, C>) -> NoRemainingSubgoalsResult {
892+
let floundered = strand.ex_clause.floundered_subgoals.len() > 0;
903893
let possible_answer = if !floundered {
904894
debug!("no remaining subgoals for the table");
905895
self.pursue_answer(strand)
@@ -1231,14 +1221,14 @@ impl<'forest, I: Interner, C: Context<I> + 'forest, CO: ContextOps<I, C> + 'fore
12311221
while strand.selected_subgoal.is_none() {
12321222
if strand.ex_clause.subgoals.len() == 0 {
12331223
if strand.ex_clause.floundered_subgoals.is_empty() {
1234-
return SubGoalSelection::NoRemainingSubgoals;
1224+
return SubGoalSelection::NotSelected;
12351225
}
12361226

12371227
self.reconsider_floundered_subgoals(&mut strand.ex_clause);
12381228

12391229
if strand.ex_clause.subgoals.is_empty() {
12401230
assert!(!strand.ex_clause.floundered_subgoals.is_empty());
1241-
return SubGoalSelection::Floundered;
1231+
return SubGoalSelection::NotSelected;
12421232
}
12431233

12441234
continue;
@@ -1274,7 +1264,7 @@ impl<'forest, I: Interner, C: Context<I> + 'forest, CO: ContextOps<I, C> + 'fore
12741264
if self.forest.tables[selected_subgoal_table].is_floundered() {
12751265
if self.propagate_floundered_subgoal(strand) {
12761266
// This strand will never lead anywhere of interest.
1277-
return SubGoalSelection::Floundered;
1267+
return SubGoalSelection::NotSelected;
12781268
} else {
12791269
// This subgoal has floundered and has been marked.
12801270
// We previously would immediately mark the table as
@@ -1329,7 +1319,7 @@ impl<'forest, I: Interner, C: Context<I> + 'forest, CO: ContextOps<I, C> + 'fore
13291319
let is_trivial_answer = self
13301320
.context
13311321
.is_trivial_substitution(&self.forest.tables[table].table_goal, &answer.subst)
1332-
&& C::empty_constraints(&answer.subst);
1322+
&& answer.subst.value.constraints.is_empty();
13331323

13341324
if is_trivial_answer {
13351325
None

0 commit comments

Comments
 (0)