about summary refs log tree commit diff
path: root/compiler/rustc_next_trait_solver/src/solve/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_next_trait_solver/src/solve/mod.rs')
-rw-r--r--compiler/rustc_next_trait_solver/src/solve/mod.rs52
1 files changed, 27 insertions, 25 deletions
diff --git a/compiler/rustc_next_trait_solver/src/solve/mod.rs b/compiler/rustc_next_trait_solver/src/solve/mod.rs
index aec9594b834..2feebe270a6 100644
--- a/compiler/rustc_next_trait_solver/src/solve/mod.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/mod.rs
@@ -29,6 +29,7 @@ use tracing::instrument;
 
 pub use self::eval_ctxt::{EvalCtxt, GenerateProofTree, SolverDelegateEvalExt};
 use crate::delegate::SolverDelegate;
+use crate::solve::assembly::Candidate;
 
 /// How many fixpoint iterations we should attempt inside of the solver before bailing
 /// with overflow.
@@ -244,50 +245,51 @@ where
     ///
     /// In this case we tend to flounder and return ambiguity by calling `[EvalCtxt::flounder]`.
     #[instrument(level = "trace", skip(self), ret)]
-    fn try_merge_responses(
+    fn try_merge_candidates(
         &mut self,
-        responses: &[CanonicalResponse<I>],
+        candidates: &[Candidate<I>],
     ) -> Option<CanonicalResponse<I>> {
-        if responses.is_empty() {
+        if candidates.is_empty() {
             return None;
         }
 
-        let one = responses[0];
-        if responses[1..].iter().all(|&resp| resp == one) {
+        let one: CanonicalResponse<I> = candidates[0].result;
+        if candidates[1..].iter().all(|candidate| candidate.result == one) {
             return Some(one);
         }
 
-        responses
+        candidates
             .iter()
-            .find(|response| {
-                response.value.certainty == Certainty::Yes
-                    && has_no_inference_or_external_constraints(**response)
+            .find(|candidate| {
+                candidate.result.value.certainty == Certainty::Yes
+                    && has_no_inference_or_external_constraints(candidate.result)
             })
-            .copied()
+            .map(|candidate| candidate.result)
     }
 
-    fn bail_with_ambiguity(&mut self, responses: &[CanonicalResponse<I>]) -> CanonicalResponse<I> {
-        debug_assert!(responses.len() > 1);
-        let maybe_cause = responses.iter().fold(MaybeCause::Ambiguity, |maybe_cause, response| {
-            // Pull down the certainty of `Certainty::Yes` to ambiguity when combining
-            // these responses, b/c we're combining more than one response and this we
-            // don't know which one applies.
-            let candidate = match response.value.certainty {
-                Certainty::Yes => MaybeCause::Ambiguity,
-                Certainty::Maybe(candidate) => candidate,
-            };
-            maybe_cause.or(candidate)
-        });
+    fn bail_with_ambiguity(&mut self, candidates: &[Candidate<I>]) -> CanonicalResponse<I> {
+        debug_assert!(candidates.len() > 1);
+        let maybe_cause =
+            candidates.iter().fold(MaybeCause::Ambiguity, |maybe_cause, candidates| {
+                // Pull down the certainty of `Certainty::Yes` to ambiguity when combining
+                // these responses, b/c we're combining more than one response and this we
+                // don't know which one applies.
+                let candidate = match candidates.result.value.certainty {
+                    Certainty::Yes => MaybeCause::Ambiguity,
+                    Certainty::Maybe(candidate) => candidate,
+                };
+                maybe_cause.or(candidate)
+            });
         self.make_ambiguous_response_no_constraints(maybe_cause)
     }
 
     /// If we fail to merge responses we flounder and return overflow or ambiguity.
     #[instrument(level = "trace", skip(self), ret)]
-    fn flounder(&mut self, responses: &[CanonicalResponse<I>]) -> QueryResult<I> {
-        if responses.is_empty() {
+    fn flounder(&mut self, candidates: &[Candidate<I>]) -> QueryResult<I> {
+        if candidates.is_empty() {
             return Err(NoSolution);
         } else {
-            Ok(self.bail_with_ambiguity(responses))
+            Ok(self.bail_with_ambiguity(candidates))
         }
     }