Apply EarlyBinder
only to TraitRef
in ImplTraitHeader
This commit is contained in:
parent
8c9a75b323
commit
9669934798
22 changed files with 74 additions and 82 deletions
|
@ -177,8 +177,8 @@ impl EraseType for Option<mir::DestructuredConstant<'_>> {
|
|||
type Result = [u8; size_of::<Option<mir::DestructuredConstant<'static>>>()];
|
||||
}
|
||||
|
||||
impl EraseType for Option<ty::EarlyBinder<ty::ImplTraitHeader<'_>>> {
|
||||
type Result = [u8; size_of::<Option<ty::EarlyBinder<ty::ImplTraitHeader<'static>>>>()];
|
||||
impl EraseType for Option<ty::ImplTraitHeader<'_>> {
|
||||
type Result = [u8; size_of::<Option<ty::ImplTraitHeader<'static>>>()];
|
||||
}
|
||||
|
||||
impl EraseType for Option<ty::EarlyBinder<Ty<'_>>> {
|
||||
|
|
|
@ -840,7 +840,7 @@ rustc_queries! {
|
|||
|
||||
/// Given an `impl_id`, return the trait it implements along with some header information.
|
||||
/// Return `None` if this is an inherent impl.
|
||||
query impl_trait_header(impl_id: DefId) -> Option<ty::EarlyBinder<ty::ImplTraitHeader<'tcx>>> {
|
||||
query impl_trait_header(impl_id: DefId) -> Option<ty::ImplTraitHeader<'tcx>> {
|
||||
desc { |tcx| "computing trait implemented by `{}`", tcx.def_path_str(impl_id) }
|
||||
cache_on_disk_if { impl_id.is_local() }
|
||||
separate_provide_extern
|
||||
|
|
|
@ -2310,12 +2310,11 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
self,
|
||||
def_id: impl IntoQueryParam<DefId>,
|
||||
) -> Option<ty::EarlyBinder<ty::TraitRef<'tcx>>> {
|
||||
Some(self.impl_trait_header(def_id)?.map_bound(|h| h.trait_ref))
|
||||
Some(self.impl_trait_header(def_id)?.trait_ref)
|
||||
}
|
||||
|
||||
pub fn impl_polarity(self, def_id: impl IntoQueryParam<DefId>) -> ty::ImplPolarity {
|
||||
self.impl_trait_header(def_id)
|
||||
.map_or(ty::ImplPolarity::Positive, |h| h.skip_binder().polarity)
|
||||
self.impl_trait_header(def_id).map_or(ty::ImplPolarity::Positive, |h| h.polarity)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue