Fix rebase
This commit is contained in:
parent
e29765250b
commit
d08ab945de
29 changed files with 120 additions and 200 deletions
|
@ -376,7 +376,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
|||
| ty::PredicateAtom::Subtype(_)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..) => {
|
||||
let (pred, _) = infcx.replace_bound_vars_with_placeholders(binder);
|
||||
let pred = infcx.replace_bound_vars_with_placeholders(binder);
|
||||
ProcessResult::Changed(mk_pending(vec![
|
||||
obligation.with(pred.to_predicate(self.selcx.tcx())),
|
||||
]))
|
||||
|
@ -673,7 +673,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
|||
Ok(Ok(None)) => {
|
||||
*stalled_on = trait_ref_infer_vars(
|
||||
self.selcx,
|
||||
project_obligation.predicate.to_poly_trait_ref(self.selcx.tcx()),
|
||||
project_obligation.predicate.to_poly_trait_ref(tcx),
|
||||
);
|
||||
ProcessResult::Unchanged
|
||||
}
|
||||
|
|
|
@ -59,7 +59,6 @@ pub use self::specialize::specialization_graph::FutureCompatOverlapErrorKind;
|
|||
pub use self::specialize::{specialization_graph, translate_substs, OverlapError};
|
||||
pub use self::structural_match::search_for_structural_match_violation;
|
||||
pub use self::structural_match::NonStructuralMatchTy;
|
||||
pub use self::util::subst_assoc_item_bound;
|
||||
pub use self::util::{elaborate_predicates, elaborate_trait_ref, elaborate_trait_refs};
|
||||
pub use self::util::{expand_trait_aliases, TraitAliasExpander};
|
||||
pub use self::util::{
|
||||
|
|
|
@ -38,7 +38,7 @@ use rustc_middle::ty::print::with_no_trimmed_paths;
|
|||
use rustc_middle::ty::relate::TypeRelation;
|
||||
use rustc_middle::ty::subst::{GenericArgKind, Subst, SubstsRef};
|
||||
use rustc_middle::ty::{self, PolyProjectionPredicate, ToPolyTraitRef, ToPredicate};
|
||||
use rustc_middle::ty::{Ty, TyCtxt, TypeFoldable};
|
||||
use rustc_middle::ty::{Ty, TyCtxt, TypeFoldable, WithConstness};
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
|
|
|
@ -6,13 +6,11 @@ use smallvec::SmallVec;
|
|||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::ty::subst::{GenericArg, Subst, SubstsRef};
|
||||
use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness};
|
||||
use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt, WithConstness};
|
||||
|
||||
use super::{Normalized, Obligation, ObligationCause, PredicateObligation, SelectionContext};
|
||||
pub use rustc_infer::traits::util::*;
|
||||
|
||||
use std::iter;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// `TraitAliasExpander` iterator
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -359,69 +357,6 @@ pub fn impl_item_is_final(tcx: TyCtxt<'_>, assoc_item: &ty::AssocItem) -> bool {
|
|||
assoc_item.defaultness.is_final() && tcx.impl_defaultness(assoc_item.container.id()).is_final()
|
||||
}
|
||||
|
||||
/// Map a bound from an associated item to apply to some other type.
|
||||
/// For example, given the following trait
|
||||
///
|
||||
/// trait X<A> { type Y<'a>: PartialEq<A> }
|
||||
///
|
||||
/// Say that we know that `<() as X<B>>::Y<'c> = i32` and we need to check that
|
||||
/// the `PartialEq` bound applies. We would then call this function with:
|
||||
///
|
||||
/// - `bound` = `<Self as X<A>>::Y<'a>: PartialEq`
|
||||
/// - `normalized_projection_ty` = `i32`
|
||||
/// - `assoc_item_substs` = `[(), B, 'c]`
|
||||
///
|
||||
/// This method would then return `i32: PartialEq<B>`.
|
||||
pub fn subst_assoc_item_bound<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
bound: ty::Predicate<'tcx>,
|
||||
normalized_projection_ty: Ty<'tcx>,
|
||||
assoc_item_substs: &[GenericArg<'tcx>],
|
||||
) -> ty::Predicate<'tcx> {
|
||||
// We're substituting these inside the closure passed to map_bound, so they
|
||||
// can't have escaping bound regions.
|
||||
assert!(!normalized_projection_ty.has_escaping_bound_vars());
|
||||
assert!(!assoc_item_substs.iter().all(|arg| arg.has_escaping_bound_vars()));
|
||||
|
||||
let translate_predicate_substs = move |predicate_substs: SubstsRef<'tcx>| {
|
||||
tcx.mk_substs(
|
||||
iter::once(normalized_projection_ty.into())
|
||||
.chain(predicate_substs[1..].iter().map(|s| s.subst(tcx, assoc_item_substs))),
|
||||
)
|
||||
};
|
||||
|
||||
match bound.kind() {
|
||||
ty::PredicateKind::Trait(poly_tr, c) => poly_tr
|
||||
.map_bound(|tr| {
|
||||
let trait_substs = translate_predicate_substs(tr.trait_ref.substs);
|
||||
ty::TraitRef { def_id: tr.def_id(), substs: trait_substs }
|
||||
})
|
||||
.with_constness(*c)
|
||||
.to_predicate(tcx),
|
||||
ty::PredicateKind::Projection(poly_projection) => poly_projection
|
||||
.map_bound(|projection| {
|
||||
let projection_substs = translate_predicate_substs(projection.projection_ty.substs);
|
||||
ty::ProjectionPredicate {
|
||||
projection_ty: ty::ProjectionTy {
|
||||
substs: projection_substs,
|
||||
item_def_id: projection.projection_ty.item_def_id,
|
||||
},
|
||||
ty: projection.ty.subst(tcx, assoc_item_substs),
|
||||
}
|
||||
})
|
||||
.to_predicate(tcx),
|
||||
ty::PredicateKind::TypeOutlives(poly_outlives) => poly_outlives
|
||||
.map_bound(|outlives| {
|
||||
ty::OutlivesPredicate(
|
||||
normalized_projection_ty,
|
||||
outlives.1.subst(tcx, assoc_item_substs),
|
||||
)
|
||||
})
|
||||
.to_predicate(tcx),
|
||||
_ => bug!("unexepected projection bound: `{:?}`", bound),
|
||||
}
|
||||
}
|
||||
|
||||
pub enum TupleArgumentsFlag {
|
||||
Yes,
|
||||
No,
|
||||
|
|
|
@ -391,7 +391,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
|||
cause.clone(),
|
||||
depth,
|
||||
param_env,
|
||||
ty::PredicateKind::WellFormed(arg).to_predicate(tcx),
|
||||
ty::PredicateAtom::WellFormed(arg).to_predicate(tcx),
|
||||
)
|
||||
}),
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue