Skip to content

Commit 8f3aa6d

Browse files
Make auto object predicates more efficient
1 parent f7ed4f2 commit 8f3aa6d

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

compiler/rustc_trait_selection/src/solve/trait_goals.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub(super) enum CandidateSource {
4141
ObjectBound(usize),
4242
/// Implementation of `Send` or other explicitly listed *auto* traits for
4343
/// a `dyn Trait + Send + Sync`
44-
ObjectAutoBound(usize),
44+
ObjectAutoBound,
4545
/// A builtin implementation for some specific traits, used in cases
4646
/// where we cannot rely an ordinary library implementations.
4747
///
@@ -165,12 +165,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
165165
}
166166
}
167167

168-
for (idx, predicate) in object_bounds.iter().enumerate() {
169-
let ty::ExistentialPredicate::AutoTrait(def_id) = predicate.skip_binder() else { continue };
170-
if def_id != goal.predicate.def_id() {
171-
continue;
172-
}
173-
acx.try_insert_candidate(CandidateSource::ObjectAutoBound(idx), Certainty::Yes);
168+
if object_bounds.auto_traits().any(|def_id| def_id == goal.predicate.def_id()) {
169+
acx.try_insert_candidate(CandidateSource::ObjectAutoBound, Certainty::Yes);
174170
}
175171
}
176172
}
@@ -265,7 +261,7 @@ impl<'tcx> EvalCtxt<'tcx> {
265261
| (CandidateSource::ParamEnv(_), _)
266262
| (CandidateSource::AliasBound(_), _)
267263
| (CandidateSource::ObjectBound(_), _)
268-
| (CandidateSource::ObjectAutoBound(_), _)
264+
| (CandidateSource::ObjectAutoBound, _)
269265
| (CandidateSource::Builtin, _)
270266
| (CandidateSource::AutoImpl, _) => unimplemented!(),
271267
}

0 commit comments

Comments
 (0)