Skip to content

Commit fdaa393

Browse files
committed
remove priority from the search graph
It turns out we only use this when we are comparing multiple program clauses.
1 parent c35c5ee commit fdaa393

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

chalk-recursive/src/recursive.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl<'me, I: Interner> Solver<'me, I> {
149149
// so this function will eventually be constant and the loop terminates.
150150
loop {
151151
let minimums = &mut Minimums::new();
152-
let (current_answer, current_prio) = self.solve_iteration(&canonical_goal, minimums);
152+
let current_answer = self.solve_iteration(&canonical_goal, minimums);
153153

154154
debug!(
155155
"solve_new_subgoal: loop iteration result = {:?} with minimums {:?}",
@@ -160,7 +160,6 @@ impl<'me, I: Interner> Solver<'me, I> {
160160
// None of our subgoals depended on us directly.
161161
// We can return.
162162
self.context.search_graph[dfn].solution = current_answer;
163-
self.context.search_graph[dfn].solution_priority = current_prio;
164163
return *minimums;
165164
}
166165

@@ -177,7 +176,6 @@ impl<'me, I: Interner> Solver<'me, I> {
177176
};
178177

179178
self.context.search_graph[dfn].solution = current_answer;
180-
self.context.search_graph[dfn].solution_priority = current_prio;
181179

182180
// Subtle: if our current answer is ambiguous, we can just stop, and
183181
// in fact we *must* -- otherwise, we sometimes fail to reach a
@@ -231,10 +229,9 @@ impl<'me, I: Interner> SolveDatabase<I> for Solver<'me, I> {
231229

232230
// Return the solution from the table.
233231
let previous_solution = self.context.search_graph[dfn].solution.clone();
234-
let previous_solution_priority = self.context.search_graph[dfn].solution_priority;
235232
info!(
236-
"solve_goal: cycle detected, previous solution {:?} with prio {:?}",
237-
previous_solution, previous_solution_priority
233+
"solve_goal: cycle detected, previous solution {:?}",
234+
previous_solution,
238235
);
239236
previous_solution
240237
} else {
@@ -265,7 +262,6 @@ impl<'me, I: Interner> SolveDatabase<I> for Solver<'me, I> {
265262

266263
// Read final result from table.
267264
let result = self.context.search_graph[dfn].solution.clone();
268-
let priority = self.context.search_graph[dfn].solution_priority;
269265

270266
// If processing this subgoal did not involve anything
271267
// outside of its subtree, then we can promote it to the
@@ -283,7 +279,7 @@ impl<'me, I: Interner> SolveDatabase<I> for Solver<'me, I> {
283279
}
284280
}
285281

286-
info!("solve_goal: solution = {:?} prio {:?}", result, priority);
282+
info!("solve_goal: solution = {:?}", result);
287283
result
288284
}
289285
}

chalk-recursive/src/search_graph.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use super::stack::StackDepth;
22
use crate::{Cache, Minimums};
3-
use chalk_ir::ClausePriority;
43
use rustc_hash::FxHashMap;
54
use std::fmt::Debug;
65
use std::hash::Hash;
@@ -30,7 +29,6 @@ pub(super) struct Node<K, V> {
3029
pub(crate) goal: K,
3130

3231
pub(crate) solution: V,
33-
pub(crate) solution_priority: ClausePriority,
3432

3533
/// This is `Some(X)` if we are actively exploring this node, or
3634
/// `None` otherwise.
@@ -78,7 +76,6 @@ where
7876
let node = Node {
7977
goal: goal.clone(),
8078
solution,
81-
solution_priority: ClausePriority::High,
8279
stack_depth: Some(stack_depth),
8380
links: Minimums { positive: dfn },
8481
};

chalk-recursive/src/solve.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub(super) trait SolveIteration<I: Interner>: SolveDatabase<I> {
3939
&mut self,
4040
canonical_goal: &UCanonicalGoal<I>,
4141
minimums: &mut Minimums,
42-
) -> (Fallible<Solution<I>>, ClausePriority) {
42+
) -> Fallible<Solution<I>> {
4343
let UCanonical {
4444
universes,
4545
canonical:
@@ -68,14 +68,14 @@ pub(super) trait SolveIteration<I: Interner>: SolveDatabase<I> {
6868
// or from the lowered program, which includes fallback
6969
// clauses. We try each approach in turn:
7070

71-
let (prog_solution, prog_prio) = {
71+
let prog_solution = {
7272
debug_span!("prog_clauses");
7373

7474
self.solve_from_clauses(&canonical_goal, minimums)
7575
};
7676
debug!(?prog_solution);
7777

78-
(prog_solution, prog_prio)
78+
prog_solution
7979
}
8080

8181
_ => {
@@ -107,11 +107,11 @@ trait SolveIterationHelpers<I: Interner>: SolveDatabase<I> {
107107
&mut self,
108108
canonical_goal: &UCanonicalGoal<I>,
109109
minimums: &mut Minimums,
110-
) -> (Fallible<Solution<I>>, ClausePriority) {
110+
) -> Fallible<Solution<I>> {
111111
let (infer, subst, goal) = self.new_inference_table(canonical_goal);
112112
match Fulfill::new_with_simplification(self, infer, subst, goal) {
113-
Ok(fulfill) => (fulfill.solve(minimums), ClausePriority::High),
114-
Err(e) => (Err(e), ClausePriority::High),
113+
Ok(fulfill) => fulfill.solve(minimums),
114+
Err(e) => Err(e),
115115
}
116116
}
117117

@@ -122,7 +122,7 @@ trait SolveIterationHelpers<I: Interner>: SolveDatabase<I> {
122122
&mut self,
123123
canonical_goal: &UCanonical<InEnvironment<DomainGoal<I>>>,
124124
minimums: &mut Minimums,
125-
) -> (Fallible<Solution<I>>, ClausePriority) {
125+
) -> Fallible<Solution<I>> {
126126
let mut clauses = vec![];
127127

128128
let db = self.db();
@@ -137,7 +137,7 @@ trait SolveIterationHelpers<I: Interner>: SolveDatabase<I> {
137137
match program_clauses_that_could_match(db, canonical_goal) {
138138
Ok(goal_clauses) => clauses.extend(goal_clauses.into_iter().filter(could_match)),
139139
Err(Floundered) => {
140-
return (Ok(Solution::Ambig(Guidance::Unknown)), ClausePriority::High);
140+
return Ok(Solution::Ambig(Guidance::Unknown));
141141
}
142142
}
143143

@@ -155,7 +155,7 @@ trait SolveIterationHelpers<I: Interner>: SolveDatabase<I> {
155155

156156
// If we have a completely ambiguous answer, it's not going to get better, so stop
157157
if cur_solution == Some((Solution::Ambig(Guidance::Unknown), ClausePriority::High)) {
158-
return (Ok(Solution::Ambig(Guidance::Unknown)), ClausePriority::High);
158+
return Ok(Solution::Ambig(Guidance::Unknown));
159159
}
160160

161161
let ProgramClauseData(implication) = program_clause.data(self.interner());
@@ -184,7 +184,12 @@ trait SolveIterationHelpers<I: Interner>: SolveDatabase<I> {
184184
debug!("Error");
185185
}
186186
}
187-
cur_solution.map_or((Err(NoSolution), ClausePriority::High), |(s, p)| (Ok(s), p))
187+
188+
if let Some((s, _)) = cur_solution {
189+
Ok(s)
190+
} else {
191+
Err(NoSolution)
192+
}
188193
}
189194

190195
fn new_inference_table<T: Fold<I, Result = T> + HasInterner<Interner = I> + Clone>(

0 commit comments

Comments
 (0)