instantiate_own doesn't need to return a pair of vectors
This commit is contained in:
parent
fc11ee02ee
commit
91fd862df0
6 changed files with 39 additions and 27 deletions
|
@ -209,9 +209,11 @@ fn compare_method_predicate_entailment<'tcx>(
|
||||||
//
|
//
|
||||||
// We then register the obligations from the impl_m and check to see
|
// We then register the obligations from the impl_m and check to see
|
||||||
// if all constraints hold.
|
// if all constraints hold.
|
||||||
hybrid_preds
|
hybrid_preds.predicates.extend(
|
||||||
.predicates
|
trait_m_predicates
|
||||||
.extend(trait_m_predicates.instantiate_own(tcx, trait_to_placeholder_substs).predicates);
|
.instantiate_own(tcx, trait_to_placeholder_substs)
|
||||||
|
.map(|(predicate, _)| predicate),
|
||||||
|
);
|
||||||
|
|
||||||
// Construct trait parameter environment and then shift it into the placeholder viewpoint.
|
// Construct trait parameter environment and then shift it into the placeholder viewpoint.
|
||||||
// The key step here is to update the caller_bounds's predicates to be
|
// The key step here is to update the caller_bounds's predicates to be
|
||||||
|
@ -230,7 +232,7 @@ fn compare_method_predicate_entailment<'tcx>(
|
||||||
debug!("compare_impl_method: caller_bounds={:?}", param_env.caller_bounds());
|
debug!("compare_impl_method: caller_bounds={:?}", param_env.caller_bounds());
|
||||||
|
|
||||||
let impl_m_own_bounds = impl_m_predicates.instantiate_own(tcx, impl_to_placeholder_substs);
|
let impl_m_own_bounds = impl_m_predicates.instantiate_own(tcx, impl_to_placeholder_substs);
|
||||||
for (predicate, span) in iter::zip(impl_m_own_bounds.predicates, impl_m_own_bounds.spans) {
|
for (predicate, span) in impl_m_own_bounds {
|
||||||
let normalize_cause = traits::ObligationCause::misc(span, impl_m_hir_id);
|
let normalize_cause = traits::ObligationCause::misc(span, impl_m_hir_id);
|
||||||
let predicate = ocx.normalize(&normalize_cause, param_env, predicate);
|
let predicate = ocx.normalize(&normalize_cause, param_env, predicate);
|
||||||
|
|
||||||
|
@ -1828,8 +1830,7 @@ fn compare_type_predicate_entailment<'tcx>(
|
||||||
check_region_bounds_on_impl_item(tcx, impl_ty, trait_ty, false)?;
|
check_region_bounds_on_impl_item(tcx, impl_ty, trait_ty, false)?;
|
||||||
|
|
||||||
let impl_ty_own_bounds = impl_ty_predicates.instantiate_own(tcx, impl_substs);
|
let impl_ty_own_bounds = impl_ty_predicates.instantiate_own(tcx, impl_substs);
|
||||||
|
if impl_ty_own_bounds.len() == 0 {
|
||||||
if impl_ty_own_bounds.is_empty() {
|
|
||||||
// Nothing to check.
|
// Nothing to check.
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
@ -1844,9 +1845,11 @@ fn compare_type_predicate_entailment<'tcx>(
|
||||||
// associated type in the trait are assumed.
|
// associated type in the trait are assumed.
|
||||||
let impl_predicates = tcx.predicates_of(impl_ty_predicates.parent.unwrap());
|
let impl_predicates = tcx.predicates_of(impl_ty_predicates.parent.unwrap());
|
||||||
let mut hybrid_preds = impl_predicates.instantiate_identity(tcx);
|
let mut hybrid_preds = impl_predicates.instantiate_identity(tcx);
|
||||||
hybrid_preds
|
hybrid_preds.predicates.extend(
|
||||||
.predicates
|
trait_ty_predicates
|
||||||
.extend(trait_ty_predicates.instantiate_own(tcx, trait_to_impl_substs).predicates);
|
.instantiate_own(tcx, trait_to_impl_substs)
|
||||||
|
.map(|(predicate, _)| predicate),
|
||||||
|
);
|
||||||
|
|
||||||
debug!("compare_type_predicate_entailment: bounds={:?}", hybrid_preds);
|
debug!("compare_type_predicate_entailment: bounds={:?}", hybrid_preds);
|
||||||
|
|
||||||
|
@ -1862,9 +1865,7 @@ fn compare_type_predicate_entailment<'tcx>(
|
||||||
|
|
||||||
debug!("compare_type_predicate_entailment: caller_bounds={:?}", param_env.caller_bounds());
|
debug!("compare_type_predicate_entailment: caller_bounds={:?}", param_env.caller_bounds());
|
||||||
|
|
||||||
assert_eq!(impl_ty_own_bounds.predicates.len(), impl_ty_own_bounds.spans.len());
|
for (predicate, span) in impl_ty_own_bounds {
|
||||||
for (span, predicate) in std::iter::zip(impl_ty_own_bounds.spans, impl_ty_own_bounds.predicates)
|
|
||||||
{
|
|
||||||
let cause = ObligationCause::misc(span, impl_ty_hir_id);
|
let cause = ObligationCause::misc(span, impl_ty_hir_id);
|
||||||
let predicate = ocx.normalize(&cause, param_env, predicate);
|
let predicate = ocx.normalize(&cause, param_env, predicate);
|
||||||
|
|
||||||
|
|
|
@ -341,15 +341,9 @@ impl<'tcx> GenericPredicates<'tcx> {
|
||||||
&self,
|
&self,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
substs: SubstsRef<'tcx>,
|
substs: SubstsRef<'tcx>,
|
||||||
) -> InstantiatedPredicates<'tcx> {
|
) -> impl Iterator<Item = (Predicate<'tcx>, Span)> + DoubleEndedIterator + ExactSizeIterator
|
||||||
InstantiatedPredicates {
|
{
|
||||||
predicates: self
|
EarlyBinder(self.predicates).subst_iter_copied(tcx, substs)
|
||||||
.predicates
|
|
||||||
.iter()
|
|
||||||
.map(|(p, _)| EarlyBinder(*p).subst(tcx, substs))
|
|
||||||
.collect(),
|
|
||||||
spans: self.predicates.iter().map(|(_, sp)| *sp).collect(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "debug", skip(self, tcx))]
|
#[instrument(level = "debug", skip(self, tcx))]
|
||||||
|
|
|
@ -639,6 +639,13 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'tcx, I: IntoIterator> ExactSizeIterator for SubstIter<'_, 'tcx, I>
|
||||||
|
where
|
||||||
|
I::IntoIter: ExactSizeIterator,
|
||||||
|
I::Item: TypeFoldable<'tcx>,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
impl<'tcx, 's, I: IntoIterator> EarlyBinder<I>
|
impl<'tcx, 's, I: IntoIterator> EarlyBinder<I>
|
||||||
where
|
where
|
||||||
I::Item: Deref,
|
I::Item: Deref,
|
||||||
|
@ -686,6 +693,14 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'tcx, I: IntoIterator> ExactSizeIterator for SubstIterCopied<'_, 'tcx, I>
|
||||||
|
where
|
||||||
|
I::IntoIter: ExactSizeIterator,
|
||||||
|
I::Item: Deref,
|
||||||
|
<I::Item as Deref>::Target: Copy + TypeFoldable<'tcx>,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
pub struct EarlyBinderIter<T> {
|
pub struct EarlyBinderIter<T> {
|
||||||
t: T,
|
t: T,
|
||||||
}
|
}
|
||||||
|
|
|
@ -2303,10 +2303,10 @@ fn assoc_ty_own_obligations<'cx, 'tcx>(
|
||||||
nested: &mut Vec<PredicateObligation<'tcx>>,
|
nested: &mut Vec<PredicateObligation<'tcx>>,
|
||||||
) {
|
) {
|
||||||
let tcx = selcx.tcx();
|
let tcx = selcx.tcx();
|
||||||
let own = tcx
|
let predicates = tcx
|
||||||
.predicates_of(obligation.predicate.def_id)
|
.predicates_of(obligation.predicate.def_id)
|
||||||
.instantiate_own(tcx, obligation.predicate.substs);
|
.instantiate_own(tcx, obligation.predicate.substs);
|
||||||
for (predicate, span) in std::iter::zip(own.predicates, own.spans) {
|
for (predicate, span) in predicates {
|
||||||
let normalized = normalize_with_depth_to(
|
let normalized = normalize_with_depth_to(
|
||||||
selcx,
|
selcx,
|
||||||
obligation.param_env,
|
obligation.param_env,
|
||||||
|
|
|
@ -185,9 +185,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
})?);
|
})?);
|
||||||
|
|
||||||
if let ty::Alias(ty::Projection, ..) = placeholder_self_ty.kind() {
|
if let ty::Alias(ty::Projection, ..) = placeholder_self_ty.kind() {
|
||||||
let predicates = tcx.predicates_of(def_id).instantiate_own(tcx, substs).predicates;
|
let predicates = tcx.predicates_of(def_id).instantiate_own(tcx, substs);
|
||||||
debug!(?predicates, "projection predicates");
|
for (predicate, _) in predicates {
|
||||||
for predicate in predicates {
|
|
||||||
let normalized = normalize_with_depth_to(
|
let normalized = normalize_with_depth_to(
|
||||||
self,
|
self,
|
||||||
obligation.param_env,
|
obligation.param_env,
|
||||||
|
|
|
@ -261,7 +261,10 @@ fn vtable_entries<'tcx>(
|
||||||
// Note that this method could then never be called, so we
|
// Note that this method could then never be called, so we
|
||||||
// do not want to try and codegen it, in that case (see #23435).
|
// do not want to try and codegen it, in that case (see #23435).
|
||||||
let predicates = tcx.predicates_of(def_id).instantiate_own(tcx, substs);
|
let predicates = tcx.predicates_of(def_id).instantiate_own(tcx, substs);
|
||||||
if impossible_predicates(tcx, predicates.predicates) {
|
if impossible_predicates(
|
||||||
|
tcx,
|
||||||
|
predicates.map(|(predicate, _)| predicate).collect(),
|
||||||
|
) {
|
||||||
debug!("vtable_entries: predicates do not hold");
|
debug!("vtable_entries: predicates do not hold");
|
||||||
return VtblEntry::Vacant;
|
return VtblEntry::Vacant;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue