Rollup merge of #110514 - compiler-errors:remove-find_map_relevant_impl, r=b-naber

Remove `find_map_relevant_impl`

Fixes #108895
This commit is contained in:
Matthias Krüger
2023-04-24 07:53:24 +02:00
committed by GitHub
6 changed files with 168 additions and 156 deletions

View File

@@ -11,7 +11,7 @@ use hir::LangItem;
use rustc_hir as hir;
use rustc_infer::traits::ObligationCause;
use rustc_infer::traits::{Obligation, SelectionError, TraitObligation};
use rustc_middle::ty::fast_reject::{DeepRejectCtxt, TreatParams, TreatProjections};
use rustc_middle::ty::fast_reject::{DeepRejectCtxt, TreatParams};
use rustc_middle::ty::{self, Ty, TypeVisitableExt};
use crate::traits;
@@ -875,12 +875,24 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
ty::Adt(..) => {
// Find a custom `impl Drop` impl, if it exists
let relevant_impl = self.tcx().find_map_relevant_impl(
let mut relevant_impl = None;
self.tcx().for_each_relevant_impl(
self.tcx().require_lang_item(LangItem::Drop, None),
obligation.predicate.skip_binder().trait_ref.self_ty(),
TreatProjections::ForLookup,
Some,
|impl_def_id| {
if let Some(old_impl_def_id) = relevant_impl {
self.tcx()
.sess
.struct_span_err(
self.tcx().def_span(impl_def_id),
"multiple drop impls found",
)
.span_note(self.tcx().def_span(old_impl_def_id), "other impl here")
.delay_as_bug();
}
relevant_impl = Some(impl_def_id);
},
);
if let Some(impl_def_id) = relevant_impl {