Skip to content

Commit c60b339

Browse files
Auto merge of #141927 - compiler-errors:perf-select, r=<try>
[PERF] Clear nested candidates in select if certainty is yes r? `@ghost`
2 parents 2398bd6 + 47dbfcd commit c60b339

File tree

1 file changed

+6
-1
lines changed
  • compiler/rustc_trait_selection/src/solve

1 file changed

+6
-1
lines changed

compiler/rustc_trait_selection/src/solve/select.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use rustc_infer::traits::{
1010
use rustc_macros::extension;
1111
use rustc_middle::{bug, span_bug};
1212
use rustc_span::Span;
13+
use thin_vec::ThinVec;
1314

1415
use crate::solve::inspect::{self, ProofTreeInferCtxtExt};
1516

@@ -147,7 +148,7 @@ fn to_selection<'tcx>(
147148
}
148149

149150
let (nested, impl_args) = cand.instantiate_nested_goals_and_opt_impl_args(span);
150-
let nested = nested
151+
let mut nested: ThinVec<_> = nested
151152
.into_iter()
152153
.map(|nested| {
153154
Obligation::new(
@@ -159,6 +160,10 @@ fn to_selection<'tcx>(
159160
})
160161
.collect();
161162

163+
if let Ok(Certainty::Yes) = cand.result() {
164+
nested.clear();
165+
}
166+
162167
Some(match cand.kind() {
163168
ProbeKind::TraitCandidate { source, result: _ } => match source {
164169
CandidateSource::Impl(impl_def_id) => {

0 commit comments

Comments
 (0)