Apply EarlyBinder only to TraitRef in ImplTraitHeader

This commit is contained in:
Yoshitomo Nakanishi 2024-03-05 20:19:05 +01:00
parent 8c9a75b323
commit 9669934798
22 changed files with 74 additions and 82 deletions

View file

@ -250,9 +250,9 @@ pub struct ImplHeader<'tcx> {
pub predicates: Vec<Predicate<'tcx>>,
}
#[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable, TyEncodable, TyDecodable, HashStable)]
#[derive(Copy, Clone, Debug, TyEncodable, TyDecodable, HashStable)]
pub struct ImplTraitHeader<'tcx> {
pub trait_ref: ty::TraitRef<'tcx>,
pub trait_ref: ty::EarlyBinder<ty::TraitRef<'tcx>>,
pub polarity: ImplPolarity,
pub unsafety: hir::Unsafety,
}
@ -1624,12 +1624,15 @@ impl<'tcx> TyCtxt<'tcx> {
def_id1: DefId,
def_id2: DefId,
) -> Option<ImplOverlapKind> {
let impl1 = self.impl_trait_header(def_id1).unwrap().instantiate_identity();
let impl2 = self.impl_trait_header(def_id2).unwrap().instantiate_identity();
let impl1 = self.impl_trait_header(def_id1).unwrap();
let impl2 = self.impl_trait_header(def_id2).unwrap();
let trait_ref1 = impl1.trait_ref.skip_binder();
let trait_ref2 = impl2.trait_ref.skip_binder();
// If either trait impl references an error, they're allowed to overlap,
// as one of them essentially doesn't exist.
if impl1.references_error() || impl2.references_error() {
if trait_ref1.references_error() || trait_ref2.references_error() {
return Some(ImplOverlapKind::Permitted { marker: false });
}
@ -1650,7 +1653,7 @@ impl<'tcx> TyCtxt<'tcx> {
let is_marker_overlap = {
let is_marker_impl =
|trait_ref: TraitRef<'_>| -> bool { self.trait_def(trait_ref.def_id).is_marker };
is_marker_impl(impl1.trait_ref) && is_marker_impl(impl2.trait_ref)
is_marker_impl(trait_ref1) && is_marker_impl(trait_ref2)
};
if is_marker_overlap {