Apply EarlyBinder only to TraitRef in ImplTraitHeader
This commit is contained in:
@@ -1888,13 +1888,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
.tcx
|
||||
.all_impls(trait_pred.def_id())
|
||||
.filter_map(|def_id| {
|
||||
let imp = self.tcx.impl_trait_header(def_id).unwrap().skip_binder();
|
||||
let imp = self.tcx.impl_trait_header(def_id).unwrap();
|
||||
if imp.polarity == ty::ImplPolarity::Negative
|
||||
|| !self.tcx.is_user_visible_dep(def_id.krate)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
let imp = imp.trait_ref;
|
||||
let imp = imp.trait_ref.skip_binder();
|
||||
|
||||
self.fuzzy_match_tys(trait_pred.skip_binder().self_ty(), imp.self_ty(), false).map(
|
||||
|similarity| ImplCandidate { trait_ref: imp, similarity, impl_def_id: def_id },
|
||||
@@ -2078,12 +2078,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
.all_impls(def_id)
|
||||
// Ignore automatically derived impls and `!Trait` impls.
|
||||
.filter_map(|def_id| self.tcx.impl_trait_header(def_id))
|
||||
.map(ty::EarlyBinder::instantiate_identity)
|
||||
.filter(|header| {
|
||||
header.polarity != ty::ImplPolarity::Negative
|
||||
|| self.tcx.is_automatically_derived(def_id)
|
||||
.filter_map(|header| {
|
||||
(header.polarity != ty::ImplPolarity::Negative
|
||||
|| self.tcx.is_automatically_derived(def_id))
|
||||
.then(|| header.trait_ref.instantiate_identity())
|
||||
})
|
||||
.map(|header| header.trait_ref)
|
||||
.filter(|trait_ref| {
|
||||
let self_ty = trait_ref.self_ty();
|
||||
// Avoid mentioning type parameters.
|
||||
|
||||
@@ -562,7 +562,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
// and so forth that we need to.
|
||||
let impl_trait_header = self.tcx().impl_trait_header(impl_def_id).unwrap();
|
||||
if !drcx
|
||||
.args_may_unify(obligation_args, impl_trait_header.skip_binder().trait_ref.args)
|
||||
.args_may_unify(obligation_args, impl_trait_header.trait_ref.skip_binder().args)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -577,7 +577,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
if self.reject_fn_ptr_impls(
|
||||
impl_def_id,
|
||||
obligation,
|
||||
impl_trait_header.skip_binder().trait_ref.self_ty(),
|
||||
impl_trait_header.trait_ref.skip_binder().self_ty(),
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ use rustc_middle::ty::_match::MatchAgainstFreshVars;
|
||||
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
|
||||
use rustc_middle::ty::relate::TypeRelation;
|
||||
use rustc_middle::ty::GenericArgsRef;
|
||||
use rustc_middle::ty::{self, EarlyBinder, PolyProjectionPredicate, ToPolyTraitRef, ToPredicate};
|
||||
use rustc_middle::ty::{self, PolyProjectionPredicate, ToPolyTraitRef, ToPredicate};
|
||||
use rustc_middle::ty::{Ty, TyCtxt, TypeFoldable, TypeVisitableExt};
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::Symbol;
|
||||
@@ -2441,7 +2441,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||
fn match_impl(
|
||||
&mut self,
|
||||
impl_def_id: DefId,
|
||||
impl_trait_header: EarlyBinder<ty::ImplTraitHeader<'tcx>>,
|
||||
impl_trait_header: ty::ImplTraitHeader<'tcx>,
|
||||
obligation: &PolyTraitObligation<'tcx>,
|
||||
) -> Result<Normalized<'tcx, GenericArgsRef<'tcx>>, ()> {
|
||||
let placeholder_obligation =
|
||||
@@ -2450,8 +2450,8 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||
|
||||
let impl_args = self.infcx.fresh_args_for_item(obligation.cause.span, impl_def_id);
|
||||
|
||||
let impl_trait_header = impl_trait_header.instantiate(self.tcx(), impl_args);
|
||||
if impl_trait_header.references_error() {
|
||||
let trait_ref = impl_trait_header.trait_ref.instantiate(self.tcx(), impl_args);
|
||||
if trait_ref.references_error() {
|
||||
return Err(());
|
||||
}
|
||||
|
||||
@@ -2464,7 +2464,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||
obligation.param_env,
|
||||
obligation.cause.clone(),
|
||||
obligation.recursion_depth + 1,
|
||||
impl_trait_header.trait_ref,
|
||||
trait_ref,
|
||||
)
|
||||
});
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ pub(super) fn specializes(tcx: TyCtxt<'_>, (impl1_def_id, impl2_def_id): (DefId,
|
||||
}
|
||||
}
|
||||
|
||||
let impl1_trait_header = tcx.impl_trait_header(impl1_def_id).unwrap().instantiate_identity();
|
||||
let impl1_trait_header = tcx.impl_trait_header(impl1_def_id).unwrap();
|
||||
|
||||
// We determine whether there's a subset relationship by:
|
||||
//
|
||||
@@ -198,7 +198,7 @@ pub(super) fn specializes(tcx: TyCtxt<'_>, (impl1_def_id, impl2_def_id): (DefId,
|
||||
fulfill_implication(
|
||||
&infcx,
|
||||
penv,
|
||||
impl1_trait_header.trait_ref,
|
||||
impl1_trait_header.trait_ref.instantiate_identity(),
|
||||
impl1_def_id,
|
||||
impl2_def_id,
|
||||
|_, _| ObligationCause::dummy(),
|
||||
|
||||
Reference in New Issue
Block a user