Make P parameter explicit
This commit is contained in:
parent
11ec3eca74
commit
412dc28d6a
14 changed files with 62 additions and 49 deletions
|
@ -115,7 +115,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
|
|
||||||
pub(super) fn prove_predicates(
|
pub(super) fn prove_predicates(
|
||||||
&mut self,
|
&mut self,
|
||||||
predicates: impl IntoIterator<Item: Upcast<'tcx> + std::fmt::Debug>,
|
predicates: impl IntoIterator<Item: Upcast<'tcx, ty::Predicate<'tcx>> + std::fmt::Debug>,
|
||||||
locations: Locations,
|
locations: Locations,
|
||||||
category: ConstraintCategory<'tcx>,
|
category: ConstraintCategory<'tcx>,
|
||||||
) {
|
) {
|
||||||
|
@ -127,7 +127,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
#[instrument(skip(self), level = "debug")]
|
#[instrument(skip(self), level = "debug")]
|
||||||
pub(super) fn prove_predicate(
|
pub(super) fn prove_predicate(
|
||||||
&mut self,
|
&mut self,
|
||||||
predicate: impl Upcast<'tcx> + std::fmt::Debug,
|
predicate: impl Upcast<'tcx, ty::Predicate<'tcx>> + std::fmt::Debug,
|
||||||
locations: Locations,
|
locations: Locations,
|
||||||
category: ConstraintCategory<'tcx>,
|
category: ConstraintCategory<'tcx>,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -546,7 +546,10 @@ impl<'bccx, 'tcx> ObligationEmittingRelation<'tcx> for NllTypeRelating<'_, 'bccx
|
||||||
self.type_checker.param_env
|
self.type_checker.param_env
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::Upcast<'tcx>>) {
|
fn register_predicates(
|
||||||
|
&mut self,
|
||||||
|
obligations: impl IntoIterator<Item: ty::Upcast<'tcx, ty::Predicate<'tcx>>>,
|
||||||
|
) {
|
||||||
self.register_obligations(
|
self.register_obligations(
|
||||||
obligations
|
obligations
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
|
@ -40,11 +40,13 @@ pub(super) fn predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredic
|
||||||
// `tcx.def_span(def_id);`
|
// `tcx.def_span(def_id);`
|
||||||
let span = DUMMY_SP;
|
let span = DUMMY_SP;
|
||||||
|
|
||||||
result.predicates =
|
result.predicates = tcx.arena.alloc_from_iter(
|
||||||
tcx.arena.alloc_from_iter(result.predicates.iter().copied().chain(std::iter::once((
|
result
|
||||||
ty::TraitRef::identity(tcx, def_id).upcast(tcx),
|
.predicates
|
||||||
span,
|
.iter()
|
||||||
))));
|
.copied()
|
||||||
|
.chain(std::iter::once((ty::TraitRef::identity(tcx, def_id).upcast(tcx), span))),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
debug!("predicates_of(def_id={:?}) = {:?}", def_id, result);
|
debug!("predicates_of(def_id={:?}) = {:?}", def_id, result);
|
||||||
result
|
result
|
||||||
|
@ -196,10 +198,8 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
|
||||||
.no_bound_vars()
|
.no_bound_vars()
|
||||||
.expect("const parameters cannot be generic");
|
.expect("const parameters cannot be generic");
|
||||||
let ct = icx.lowerer().lower_const_param(param.hir_id, ct_ty);
|
let ct = icx.lowerer().lower_const_param(param.hir_id, ct_ty);
|
||||||
predicates.insert((
|
predicates
|
||||||
ty::ClauseKind::ConstArgHasType(ct, ct_ty).upcast(tcx),
|
.insert((ty::ClauseKind::ConstArgHasType(ct, ct_ty).upcast(tcx), param.span));
|
||||||
param.span,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,8 +257,8 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let pred = ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(r1, r2))
|
let pred =
|
||||||
.upcast(tcx);
|
ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(r1, r2)).upcast(tcx);
|
||||||
(pred, span)
|
(pred, span)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
@ -354,8 +354,7 @@ fn const_evaluatable_predicates_of(
|
||||||
let ct = ty::Const::from_anon_const(self.tcx, c.def_id);
|
let ct = ty::Const::from_anon_const(self.tcx, c.def_id);
|
||||||
if let ty::ConstKind::Unevaluated(_) = ct.kind() {
|
if let ty::ConstKind::Unevaluated(_) = ct.kind() {
|
||||||
let span = self.tcx.def_span(c.def_id);
|
let span = self.tcx.def_span(c.def_id);
|
||||||
self.preds
|
self.preds.insert((ty::ClauseKind::ConstEvaluatable(ct).upcast(self.tcx), span));
|
||||||
.insert((ty::ClauseKind::ConstEvaluatable(ct).upcast(self.tcx), span));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -337,7 +337,10 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
|
||||||
self.obligations.extend(obligations);
|
self.obligations.extend(obligations);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn register_predicates(&mut self, obligations: impl IntoIterator<Item: Upcast<'tcx>>) {
|
pub fn register_predicates(
|
||||||
|
&mut self,
|
||||||
|
obligations: impl IntoIterator<Item: Upcast<'tcx, ty::Predicate<'tcx>>>,
|
||||||
|
) {
|
||||||
self.obligations.extend(obligations.into_iter().map(|to_pred| {
|
self.obligations.extend(obligations.into_iter().map(|to_pred| {
|
||||||
Obligation::new(self.infcx.tcx, self.trace.cause.clone(), self.param_env, to_pred)
|
Obligation::new(self.infcx.tcx, self.trace.cause.clone(), self.param_env, to_pred)
|
||||||
}))
|
}))
|
||||||
|
@ -360,7 +363,10 @@ pub trait ObligationEmittingRelation<'tcx>: TypeRelation<'tcx> {
|
||||||
/// Register predicates that must hold in order for this relation to hold. Uses
|
/// Register predicates that must hold in order for this relation to hold. Uses
|
||||||
/// a default obligation cause, [`ObligationEmittingRelation::register_obligations`] should
|
/// a default obligation cause, [`ObligationEmittingRelation::register_obligations`] should
|
||||||
/// be used if control over the obligation causes is required.
|
/// be used if control over the obligation causes is required.
|
||||||
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: Upcast<'tcx>>);
|
fn register_predicates(
|
||||||
|
&mut self,
|
||||||
|
obligations: impl IntoIterator<Item: Upcast<'tcx, ty::Predicate<'tcx>>>,
|
||||||
|
);
|
||||||
|
|
||||||
/// Register `AliasRelate` obligation(s) that both types must be related to each other.
|
/// Register `AliasRelate` obligation(s) that both types must be related to each other.
|
||||||
fn register_type_relate_obligation(&mut self, a: Ty<'tcx>, b: Ty<'tcx>);
|
fn register_type_relate_obligation(&mut self, a: Ty<'tcx>, b: Ty<'tcx>);
|
||||||
|
|
|
@ -140,7 +140,10 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for Glb<'_, '_, 'tcx> {
|
||||||
self.fields.param_env
|
self.fields.param_env
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::Upcast<'tcx>>) {
|
fn register_predicates(
|
||||||
|
&mut self,
|
||||||
|
obligations: impl IntoIterator<Item: ty::Upcast<'tcx, ty::Predicate<'tcx>>>,
|
||||||
|
) {
|
||||||
self.fields.register_predicates(obligations);
|
self.fields.register_predicates(obligations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,10 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for Lub<'_, '_, 'tcx> {
|
||||||
self.fields.param_env
|
self.fields.param_env
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::Upcast<'tcx>>) {
|
fn register_predicates(
|
||||||
|
&mut self,
|
||||||
|
obligations: impl IntoIterator<Item: ty::Upcast<'tcx, ty::Predicate<'tcx>>>,
|
||||||
|
) {
|
||||||
self.fields.register_predicates(obligations);
|
self.fields.register_predicates(obligations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -312,7 +312,10 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for TypeRelating<'_, '_, 'tcx> {
|
||||||
self.structurally_relate_aliases
|
self.structurally_relate_aliases
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::Upcast<'tcx>>) {
|
fn register_predicates(
|
||||||
|
&mut self,
|
||||||
|
obligations: impl IntoIterator<Item: ty::Upcast<'tcx, ty::Predicate<'tcx>>>,
|
||||||
|
) {
|
||||||
self.fields.register_predicates(obligations);
|
self.fields.register_predicates(obligations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -357,9 +357,7 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map(|clause| {
|
.map(|clause| elaboratable.child(bound_clause.rebind(clause).upcast(tcx))),
|
||||||
elaboratable.child(bound_clause.rebind(clause).upcast(tcx))
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ty::ClauseKind::RegionOutlives(..) => {
|
ty::ClauseKind::RegionOutlives(..) => {
|
||||||
|
|
|
@ -544,8 +544,8 @@ impl<'tcx> ToPolyTraitRef<'tcx> for PolyTraitPredicate<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Upcast<'tcx, P = Predicate<'tcx>> {
|
pub trait Upcast<'tcx, T> {
|
||||||
fn upcast(self, tcx: TyCtxt<'tcx>) -> P;
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> T;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, T> Upcast<'tcx, T> for T {
|
impl<'tcx, T> Upcast<'tcx, T> for T {
|
||||||
|
@ -554,35 +554,35 @@ impl<'tcx, T> Upcast<'tcx, T> for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Upcast<'tcx> for PredicateKind<'tcx> {
|
impl<'tcx> Upcast<'tcx, ty::Predicate<'tcx>> for PredicateKind<'tcx> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
ty::Binder::dummy(self).upcast(tcx)
|
ty::Binder::dummy(self).upcast(tcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Upcast<'tcx> for Binder<'tcx, PredicateKind<'tcx>> {
|
impl<'tcx> Upcast<'tcx, ty::Predicate<'tcx>> for Binder<'tcx, PredicateKind<'tcx>> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
tcx.mk_predicate(self)
|
tcx.mk_predicate(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Upcast<'tcx> for ClauseKind<'tcx> {
|
impl<'tcx> Upcast<'tcx, ty::Predicate<'tcx>> for ClauseKind<'tcx> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
tcx.mk_predicate(ty::Binder::dummy(ty::PredicateKind::Clause(self)))
|
tcx.mk_predicate(ty::Binder::dummy(ty::PredicateKind::Clause(self)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Upcast<'tcx> for Binder<'tcx, ClauseKind<'tcx>> {
|
impl<'tcx> Upcast<'tcx, ty::Predicate<'tcx>> for Binder<'tcx, ClauseKind<'tcx>> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
tcx.mk_predicate(self.map_bound(ty::PredicateKind::Clause))
|
tcx.mk_predicate(self.map_bound(ty::PredicateKind::Clause))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Upcast<'tcx> for Clause<'tcx> {
|
impl<'tcx> Upcast<'tcx, ty::Predicate<'tcx>> for Clause<'tcx> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn upcast(self, _tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn upcast(self, _tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
self.as_predicate()
|
self.as_predicate()
|
||||||
|
@ -603,7 +603,7 @@ impl<'tcx> Upcast<'tcx, Clause<'tcx>> for Binder<'tcx, ClauseKind<'tcx>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Upcast<'tcx> for TraitRef<'tcx> {
|
impl<'tcx> Upcast<'tcx, ty::Predicate<'tcx>> for TraitRef<'tcx> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
ty::Binder::dummy(self).upcast(tcx)
|
ty::Binder::dummy(self).upcast(tcx)
|
||||||
|
@ -625,7 +625,7 @@ impl<'tcx> Upcast<'tcx, Clause<'tcx>> for TraitRef<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Upcast<'tcx> for Binder<'tcx, TraitRef<'tcx>> {
|
impl<'tcx> Upcast<'tcx, ty::Predicate<'tcx>> for Binder<'tcx, TraitRef<'tcx>> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
let pred: PolyTraitPredicate<'tcx> = self.upcast(tcx);
|
let pred: PolyTraitPredicate<'tcx> = self.upcast(tcx);
|
||||||
|
@ -651,13 +651,13 @@ impl<'tcx> Upcast<'tcx, PolyTraitPredicate<'tcx>> for Binder<'tcx, TraitRef<'tcx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Upcast<'tcx> for TraitPredicate<'tcx> {
|
impl<'tcx> Upcast<'tcx, ty::Predicate<'tcx>> for TraitPredicate<'tcx> {
|
||||||
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
PredicateKind::Clause(ClauseKind::Trait(self)).upcast(tcx)
|
PredicateKind::Clause(ClauseKind::Trait(self)).upcast(tcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Upcast<'tcx> for PolyTraitPredicate<'tcx> {
|
impl<'tcx> Upcast<'tcx, ty::Predicate<'tcx>> for PolyTraitPredicate<'tcx> {
|
||||||
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
self.map_bound(|p| PredicateKind::Clause(ClauseKind::Trait(p))).upcast(tcx)
|
self.map_bound(|p| PredicateKind::Clause(ClauseKind::Trait(p))).upcast(tcx)
|
||||||
}
|
}
|
||||||
|
@ -677,25 +677,25 @@ impl<'tcx> Upcast<'tcx, Clause<'tcx>> for PolyTraitPredicate<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Upcast<'tcx> for PolyRegionOutlivesPredicate<'tcx> {
|
impl<'tcx> Upcast<'tcx, ty::Predicate<'tcx>> for PolyRegionOutlivesPredicate<'tcx> {
|
||||||
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
self.map_bound(|p| PredicateKind::Clause(ClauseKind::RegionOutlives(p))).upcast(tcx)
|
self.map_bound(|p| PredicateKind::Clause(ClauseKind::RegionOutlives(p))).upcast(tcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Upcast<'tcx> for OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>> {
|
impl<'tcx> Upcast<'tcx, ty::Predicate<'tcx>> for OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>> {
|
||||||
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
ty::Binder::dummy(PredicateKind::Clause(ClauseKind::TypeOutlives(self))).upcast(tcx)
|
ty::Binder::dummy(PredicateKind::Clause(ClauseKind::TypeOutlives(self))).upcast(tcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Upcast<'tcx> for ProjectionPredicate<'tcx> {
|
impl<'tcx> Upcast<'tcx, ty::Predicate<'tcx>> for ProjectionPredicate<'tcx> {
|
||||||
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
ty::Binder::dummy(PredicateKind::Clause(ClauseKind::Projection(self))).upcast(tcx)
|
ty::Binder::dummy(PredicateKind::Clause(ClauseKind::Projection(self))).upcast(tcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Upcast<'tcx> for PolyProjectionPredicate<'tcx> {
|
impl<'tcx> Upcast<'tcx, ty::Predicate<'tcx>> for PolyProjectionPredicate<'tcx> {
|
||||||
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
self.map_bound(|p| PredicateKind::Clause(ClauseKind::Projection(p))).upcast(tcx)
|
self.map_bound(|p| PredicateKind::Clause(ClauseKind::Projection(p))).upcast(tcx)
|
||||||
}
|
}
|
||||||
|
@ -715,7 +715,7 @@ impl<'tcx> Upcast<'tcx, Clause<'tcx>> for PolyProjectionPredicate<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Upcast<'tcx> for NormalizesTo<'tcx> {
|
impl<'tcx> Upcast<'tcx, ty::Predicate<'tcx>> for NormalizesTo<'tcx> {
|
||||||
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn upcast(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
PredicateKind::NormalizesTo(self).upcast(tcx)
|
PredicateKind::NormalizesTo(self).upcast(tcx)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2703,7 +2703,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
obligated_types: &mut Vec<Ty<'tcx>>,
|
obligated_types: &mut Vec<Ty<'tcx>>,
|
||||||
seen_requirements: &mut FxHashSet<DefId>,
|
seen_requirements: &mut FxHashSet<DefId>,
|
||||||
) where
|
) where
|
||||||
T: Upcast<'tcx>,
|
T: Upcast<'tcx, ty::Predicate<'tcx>>,
|
||||||
{
|
{
|
||||||
let mut long_ty_file = None;
|
let mut long_ty_file = None;
|
||||||
|
|
||||||
|
|
|
@ -302,7 +302,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
suggest_increasing_limit: bool,
|
suggest_increasing_limit: bool,
|
||||||
) -> !
|
) -> !
|
||||||
where
|
where
|
||||||
T: Upcast<'tcx> + Clone,
|
T: Upcast<'tcx, ty::Predicate<'tcx>> + Clone,
|
||||||
{
|
{
|
||||||
let predicate = obligation.predicate.clone().upcast(self.tcx);
|
let predicate = obligation.predicate.clone().upcast(self.tcx);
|
||||||
let predicate = self.resolve_vars_if_possible(predicate);
|
let predicate = self.resolve_vars_if_possible(predicate);
|
||||||
|
|
|
@ -142,7 +142,7 @@ pub fn type_known_to_meet_bound_modulo_regions<'tcx>(
|
||||||
fn pred_known_to_hold_modulo_regions<'tcx>(
|
fn pred_known_to_hold_modulo_regions<'tcx>(
|
||||||
infcx: &InferCtxt<'tcx>,
|
infcx: &InferCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
pred: impl Upcast<'tcx>,
|
pred: impl Upcast<'tcx, ty::Predicate<'tcx>>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let obligation = Obligation::new(infcx.tcx, ObligationCause::dummy(), param_env, pred);
|
let obligation = Obligation::new(infcx.tcx, ObligationCause::dummy(), param_env, pred);
|
||||||
|
|
||||||
|
|
|
@ -752,8 +752,7 @@ fn receiver_is_dispatchable<'tcx>(
|
||||||
|
|
||||||
// Self: Unsize<U>
|
// Self: Unsize<U>
|
||||||
let unsize_predicate =
|
let unsize_predicate =
|
||||||
ty::TraitRef::new(tcx, unsize_did, [tcx.types.self_param, unsized_self_ty])
|
ty::TraitRef::new(tcx, unsize_did, [tcx.types.self_param, unsized_self_ty]).upcast(tcx);
|
||||||
.upcast(tcx);
|
|
||||||
|
|
||||||
// U: Trait<Arg1, ..., ArgN>
|
// U: Trait<Arg1, ..., ArgN>
|
||||||
let trait_predicate = {
|
let trait_predicate = {
|
||||||
|
|
|
@ -739,8 +739,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
// stack would be `T: Auto`.
|
// stack would be `T: Auto`.
|
||||||
let cycle = stack.iter().take_while(|s| s.depth > stack_arg.1);
|
let cycle = stack.iter().take_while(|s| s.depth > stack_arg.1);
|
||||||
let tcx = self.tcx();
|
let tcx = self.tcx();
|
||||||
let cycle =
|
let cycle = cycle.map(|stack| stack.obligation.predicate.upcast(tcx));
|
||||||
cycle.map(|stack| stack.obligation.predicate.upcast(tcx));
|
|
||||||
if self.coinductive_match(cycle) {
|
if self.coinductive_match(cycle) {
|
||||||
stack.update_reached_depth(stack_arg.1);
|
stack.update_reached_depth(stack_arg.1);
|
||||||
return Ok(EvaluatedToOk);
|
return Ok(EvaluatedToOk);
|
||||||
|
@ -1379,7 +1378,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
error_obligation: &Obligation<'tcx, T>,
|
error_obligation: &Obligation<'tcx, T>,
|
||||||
) -> Result<(), OverflowError>
|
) -> Result<(), OverflowError>
|
||||||
where
|
where
|
||||||
T: Upcast<'tcx> + Clone,
|
T: Upcast<'tcx, ty::Predicate<'tcx>> + Clone,
|
||||||
{
|
{
|
||||||
if !self.infcx.tcx.recursion_limit().value_within_limit(depth) {
|
if !self.infcx.tcx.recursion_limit().value_within_limit(depth) {
|
||||||
match self.query_mode {
|
match self.query_mode {
|
||||||
|
@ -1408,7 +1407,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
error_obligation: &Obligation<'tcx, V>,
|
error_obligation: &Obligation<'tcx, V>,
|
||||||
) -> Result<(), OverflowError>
|
) -> Result<(), OverflowError>
|
||||||
where
|
where
|
||||||
V: Upcast<'tcx> + Clone,
|
V: Upcast<'tcx, ty::Predicate<'tcx>> + Clone,
|
||||||
{
|
{
|
||||||
self.check_recursion_depth(obligation.recursion_depth, error_obligation)
|
self.check_recursion_depth(obligation.recursion_depth, error_obligation)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue