diff options
| author | Michael Goulet <michael@errs.io> | 2025-06-02 18:00:37 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2025-06-05 21:18:58 +0000 |
| commit | dcf22aa7cb1bad0a759465ab1eba2e5bb4d13aef (patch) | |
| tree | 946ece455092d90bdf2840d949f02f4100f7ef18 | |
| parent | 076ec59ff1dcf538b9d3a0b8e0d7f4edd0559959 (diff) | |
| download | rust-dcf22aa7cb1bad0a759465ab1eba2e5bb4d13aef.tar.gz rust-dcf22aa7cb1bad0a759465ab1eba2e5bb4d13aef.zip | |
Clear nested candidates in select if certainty is yes
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/select.rs | 7 |
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) => { |
