diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2023-01-28 00:23:14 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-28 00:23:14 +0900 |
| commit | d62f6fdff9fac2c28554475fa9731a7bc8439ea3 (patch) | |
| tree | c1e0dc631f76da3734a28ceb7c33969d359282a2 | |
| parent | 9ec7492862e5bb101746bc14ead8152ac9da1930 (diff) | |
| parent | 727b987e0668fb87a328b7312cafdd40b75e8ed9 (diff) | |
| download | rust-d62f6fdff9fac2c28554475fa9731a7bc8439ea3.tar.gz rust-d62f6fdff9fac2c28554475fa9731a7bc8439ea3.zip | |
Rollup merge of #107321 - lcnr:comment, r=compiler-errors
solver comments + remove `TyCtxt::evaluate_goal` from the `RustcContributor::explore` session yesterday. This also removes `TyCtxt::evaluate_goal` because to canonicalize you have to use an `InferCtxt` anyways at which point we should just always get people to use `evaluate_root_goal`. r? ``@spastorino``
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/mod.rs | 20 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/project_goals.rs | 4 |
2 files changed, 11 insertions, 13 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/mod.rs b/compiler/rustc_trait_selection/src/solve/mod.rs index f44648c95d7..7880cbad5fe 100644 --- a/compiler/rustc_trait_selection/src/solve/mod.rs +++ b/compiler/rustc_trait_selection/src/solve/mod.rs @@ -141,17 +141,6 @@ type CanonicalResponse<'tcx> = Canonical<'tcx, Response<'tcx>>; /// solver, merge the two responses again. 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> { /// Evaluates a goal from **outside** of the trait solver. /// @@ -194,6 +183,15 @@ impl<'a, 'tcx> EvalCtxt<'a, '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)] fn evaluate_canonical_goal( tcx: TyCtxt<'tcx>, diff --git a/compiler/rustc_trait_selection/src/solve/project_goals.rs b/compiler/rustc_trait_selection/src/solve/project_goals.rs index b583705ac43..30902c2bc45 100644 --- a/compiler/rustc_trait_selection/src/solve/project_goals.rs +++ b/compiler/rustc_trait_selection/src/solve/project_goals.rs @@ -28,8 +28,8 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { // To only compute normalization once for each projection we only // normalize if the expected term is an unconstrained inference variable. // - // 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 + // 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 // `U` and equate it with `u32`. This means that we don't need a separate // projection cache in the solver. if self.term_is_fully_unconstrained(goal) { |
