solver comments + remove TyCtxt::evaluate_goal
This commit is contained in:
parent
e187f8871e
commit
727b987e06
2 changed files with 11 additions and 13 deletions
|
@ -141,17 +141,6 @@ type CanonicalResponse<'tcx> = Canonical<'tcx, Response<'tcx>>;
|
||||||
/// solver, merge the two responses again.
|
/// solver, merge the two responses again.
|
||||||
pub type QueryResult<'tcx> = Result<CanonicalResponse<'tcx>, NoSolution>;
|
pub type QueryResult<'tcx> = Result<CanonicalResponse<'tcx>, NoSolution>;
|
||||||
|
|
||||||
pub trait TyCtxtExt<'tcx> {
|
|
||||||
fn evaluate_goal(self, goal: CanonicalGoal<'tcx>) -> QueryResult<'tcx>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> TyCtxtExt<'tcx> for TyCtxt<'tcx> {
|
|
||||||
fn evaluate_goal(self, goal: CanonicalGoal<'tcx>) -> QueryResult<'tcx> {
|
|
||||||
let mut search_graph = search_graph::SearchGraph::new(self);
|
|
||||||
EvalCtxt::evaluate_canonical_goal(self, &mut search_graph, goal)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait InferCtxtEvalExt<'tcx> {
|
pub trait InferCtxtEvalExt<'tcx> {
|
||||||
/// Evaluates a goal from **outside** of the trait solver.
|
/// Evaluates a goal from **outside** of the trait solver.
|
||||||
///
|
///
|
||||||
|
@ -194,6 +183,15 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
|
||||||
self.infcx.tcx
|
self.infcx.tcx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The entry point of the solver.
|
||||||
|
///
|
||||||
|
/// This function deals with (coinductive) cycles, overflow, and caching
|
||||||
|
/// and then calls [`EvalCtxt::compute_goal`] which contains the actual
|
||||||
|
/// logic of the solver.
|
||||||
|
///
|
||||||
|
/// Instead of calling this function directly, use either [EvalCtxt::evaluate_goal]
|
||||||
|
/// if you're inside of the solver or [InferCtxtEvalExt::evaluate_root_goal] if you're
|
||||||
|
/// outside of it.
|
||||||
#[instrument(level = "debug", skip(tcx, search_graph), ret)]
|
#[instrument(level = "debug", skip(tcx, search_graph), ret)]
|
||||||
fn evaluate_canonical_goal(
|
fn evaluate_canonical_goal(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
|
|
|
@ -28,8 +28,8 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
||||||
// To only compute normalization once for each projection we only
|
// To only compute normalization once for each projection we only
|
||||||
// normalize if the expected term is an unconstrained inference variable.
|
// normalize if the expected term is an unconstrained inference variable.
|
||||||
//
|
//
|
||||||
// E.g. for `<T as Trait>::Assoc = u32` we recursively compute the goal
|
// E.g. for `<T as Trait>::Assoc == u32` we recursively compute the goal
|
||||||
// `exists<U> <T as Trait>::Assoc = U` and then take the resulting type for
|
// `exists<U> <T as Trait>::Assoc == U` and then take the resulting type for
|
||||||
// `U` and equate it with `u32`. This means that we don't need a separate
|
// `U` and equate it with `u32`. This means that we don't need a separate
|
||||||
// projection cache in the solver.
|
// projection cache in the solver.
|
||||||
if self.term_is_fully_unconstrained(goal) {
|
if self.term_is_fully_unconstrained(goal) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue