80
80
}
81
81
}
82
82
83
+ /// Solves a canonical goal. The substitution returned in the
84
+ /// solution will be for the fully decomposed goal. For example, given the
85
+ /// program
86
+ ///
87
+ /// ```ignore
88
+ /// struct u8 { }
89
+ /// struct SomeType<T> { }
90
+ /// trait Foo<T> { }
91
+ /// impl<U> Foo<u8> for SomeType<U> { }
92
+ /// ```
93
+ ///
94
+ /// and the goal `exists<V> { forall<U> { SomeType<U>: Foo<V> }
95
+ /// }`, `into_peeled_goal` can be used to create a canonical goal
96
+ /// `SomeType<!1>: Foo<?0>`. This function will then return a
97
+ /// solution with the substitution `?0 := u8`.
98
+ pub ( crate ) fn solve_root_goal (
99
+ & mut self ,
100
+ canonical_goal : & K ,
101
+ solver_stuff : impl SolverStuff < K , V > ,
102
+ ) -> V {
103
+ debug ! ( "solve_root_goal(canonical_goal={:?})" , canonical_goal) ;
104
+ assert ! ( self . stack. is_empty( ) ) ;
105
+ let minimums = & mut Minimums :: new ( ) ;
106
+ self . solve_goal ( canonical_goal, minimums, solver_stuff)
107
+ }
108
+
83
109
/// Attempt to solve a goal that has been fully broken down into leaf form
84
110
/// and canonicalized. This is where the action really happens, and is the
85
111
/// place where we would perform caching in rustc (and may eventually do in Chalk).
@@ -212,31 +238,6 @@ impl<'me, I: Interner> Solver<'me, I> {
212
238
) -> Self {
213
239
Self { program, context }
214
240
}
215
-
216
- /// Solves a canonical goal. The substitution returned in the
217
- /// solution will be for the fully decomposed goal. For example, given the
218
- /// program
219
- ///
220
- /// ```ignore
221
- /// struct u8 { }
222
- /// struct SomeType<T> { }
223
- /// trait Foo<T> { }
224
- /// impl<U> Foo<u8> for SomeType<U> { }
225
- /// ```
226
- ///
227
- /// and the goal `exists<V> { forall<U> { SomeType<U>: Foo<V> }
228
- /// }`, `into_peeled_goal` can be used to create a canonical goal
229
- /// `SomeType<!1>: Foo<?0>`. This function will then return a
230
- /// solution with the substitution `?0 := u8`.
231
- pub ( crate ) fn solve_root_goal (
232
- & mut self ,
233
- canonical_goal : & UCanonicalGoal < I > ,
234
- ) -> Fallible < Solution < I > > {
235
- debug ! ( "solve_root_goal(canonical_goal={:?})" , canonical_goal) ;
236
- assert ! ( self . context. stack. is_empty( ) ) ;
237
- let minimums = & mut Minimums :: new ( ) ;
238
- self . solve_goal ( canonical_goal. clone ( ) , minimums)
239
- }
240
241
}
241
242
242
243
trait SolverStuff < K , V > : Copy
@@ -339,9 +340,7 @@ impl<I: Interner> chalk_solve::Solver<I> for RecursiveSolver<I> {
339
340
program : & dyn RustIrDatabase < I > ,
340
341
goal : & UCanonical < InEnvironment < Goal < I > > > ,
341
342
) -> Option < chalk_solve:: Solution < I > > {
342
- Solver :: new ( & mut self . ctx , program)
343
- . solve_root_goal ( goal)
344
- . ok ( )
343
+ self . ctx . solve_root_goal ( goal, program) . ok ( )
345
344
}
346
345
347
346
fn solve_limited (
@@ -351,9 +350,7 @@ impl<I: Interner> chalk_solve::Solver<I> for RecursiveSolver<I> {
351
350
_should_continue : & dyn std:: ops:: Fn ( ) -> bool ,
352
351
) -> Option < chalk_solve:: Solution < I > > {
353
352
// TODO support should_continue in recursive solver
354
- Solver :: new ( & mut self . ctx , program)
355
- . solve_root_goal ( goal)
356
- . ok ( )
353
+ self . ctx . solve_root_goal ( goal, program) . ok ( )
357
354
}
358
355
359
356
fn solve_multiple (
0 commit comments