about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/solve/select.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_trait_selection/src/solve/select.rs')
-rw-r--r--compiler/rustc_trait_selection/src/solve/select.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/select.rs b/compiler/rustc_trait_selection/src/solve/select.rs
index 21812c8017d..09d00136f53 100644
--- a/compiler/rustc_trait_selection/src/solve/select.rs
+++ b/compiler/rustc_trait_selection/src/solve/select.rs
@@ -10,6 +10,7 @@ use rustc_infer::traits::{
 use rustc_macros::extension;
 use rustc_middle::{bug, span_bug};
 use rustc_span::Span;
+use thin_vec::ThinVec;
 
 use crate::solve::inspect::{self, ProofTreeInferCtxtExt};
 
@@ -147,7 +148,7 @@ fn to_selection<'tcx>(
     }
 
     let (nested, impl_args) = cand.instantiate_nested_goals_and_opt_impl_args(span);
-    let nested = nested
+    let mut nested: ThinVec<_> = nested
         .into_iter()
         .map(|nested| {
             Obligation::new(
@@ -159,6 +160,10 @@ fn to_selection<'tcx>(
         })
         .collect();
 
+    if let Ok(Certainty::Yes) = cand.result() {
+        nested.clear();
+    }
+
     Some(match cand.kind() {
         ProbeKind::TraitCandidate { source, result: _ } => match source {
             CandidateSource::Impl(impl_def_id) => {