obligation.predicate.def_id(),
obligation.predicate.skip_binder().trait_ref.self_ty(),
|impl_def_id| {
+ // Before we create the substitutions and everything, first
+ // consider a "quick reject". This avoids creating more types
+ // and so forth that we need to.
+ let impl_trait_ref = self.tcx().bound_impl_trait_ref(impl_def_id).unwrap();
+ if self.fast_reject_trait_refs(obligation, &impl_trait_ref.0) {
+ return;
+ }
+
self.infcx.probe(|_| {
- if let Ok(_substs) = self.match_impl(impl_def_id, obligation) {
+ if let Ok(_substs) = self.match_impl(impl_def_id, impl_trait_ref, obligation) {
candidates.vec.push(ImplCandidate(impl_def_id));
}
});
if let Some(impl_def_id) = relevant_impl {
// Check that `impl Drop` is actually const, if there is a custom impl
- if self.tcx().impl_constness(impl_def_id) == hir::Constness::Const {
+ if self.tcx().constness(impl_def_id) == hir::Constness::Const {
candidates.vec.push(ConstDestructCandidate(Some(impl_def_id)));
}
} else {