Skip to content

Commit 76e8333

Browse files
committedJul 27, 2020
Auto merge of #73503 - lcnr:forall-predicate-what-and-why-2, r=nikomatsakis
convert higher ranked `Predicate`s to `PredicateKind::ForAll` implements step 2 of rust-lang/compiler-team#285 r? @nikomatsakis
2 parents efc02b0 + 602ef6b commit 76e8333

File tree

61 files changed

+1268
-1150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1268
-1150
lines changed
 

‎src/librustc_infer/infer/canonical/query_response.rs

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -525,28 +525,25 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
525525
result_subst: &'a CanonicalVarValues<'tcx>,
526526
) -> impl Iterator<Item = PredicateObligation<'tcx>> + 'a + Captures<'tcx> {
527527
unsubstituted_region_constraints.iter().map(move |constraint| {
528-
let constraint = substitute_value(self.tcx, result_subst, constraint);
529-
let ty::OutlivesPredicate(k1, r2) = constraint.skip_binder(); // restored below
528+
let ty::OutlivesPredicate(k1, r2) =
529+
substitute_value(self.tcx, result_subst, constraint).skip_binder();
530530

531-
Obligation::new(
532-
cause.clone(),
533-
param_env,
534-
match k1.unpack() {
535-
GenericArgKind::Lifetime(r1) => ty::PredicateKind::RegionOutlives(
536-
ty::Binder::bind(ty::OutlivesPredicate(r1, r2)),
537-
)
538-
.to_predicate(self.tcx),
539-
GenericArgKind::Type(t1) => ty::PredicateKind::TypeOutlives(ty::Binder::bind(
540-
ty::OutlivesPredicate(t1, r2),
541-
))
542-
.to_predicate(self.tcx),
543-
GenericArgKind::Const(..) => {
544-
// Consts cannot outlive one another, so we don't expect to
545-
// ecounter this branch.
546-
span_bug!(cause.span, "unexpected const outlives {:?}", constraint);
547-
}
548-
},
549-
)
531+
let predicate = match k1.unpack() {
532+
GenericArgKind::Lifetime(r1) => {
533+
ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(r1, r2))
534+
}
535+
GenericArgKind::Type(t1) => {
536+
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(t1, r2))
537+
}
538+
GenericArgKind::Const(..) => {
539+
// Consts cannot outlive one another, so we don't expect to
540+
// encounter this branch.
541+
span_bug!(cause.span, "unexpected const outlives {:?}", constraint);
542+
}
543+
}
544+
.potentially_quantified(self.tcx, ty::PredicateKind::ForAll);
545+
546+
Obligation::new(cause.clone(), param_env, predicate)
550547
})
551548
}
552549

@@ -666,10 +663,8 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
666663
self.obligations.push(Obligation {
667664
cause: self.cause.clone(),
668665
param_env: self.param_env,
669-
predicate: ty::PredicateKind::RegionOutlives(ty::Binder::dummy(ty::OutlivesPredicate(
670-
sup, sub,
671-
)))
672-
.to_predicate(self.infcx.tcx),
666+
predicate: ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(sup, sub))
667+
.to_predicate(self.infcx.tcx),
673668
recursion_depth: 0,
674669
});
675670
}

‎src/librustc_infer/infer/combine.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
308308
self.obligations.push(Obligation::new(
309309
self.trace.cause.clone(),
310310
self.param_env,
311-
ty::PredicateKind::WellFormed(b_ty.into()).to_predicate(self.infcx.tcx),
311+
ty::PredicateAtom::WellFormed(b_ty.into()).to_predicate(self.infcx.tcx),
312312
));
313313
}
314314

@@ -400,9 +400,9 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
400400
b: &'tcx ty::Const<'tcx>,
401401
) {
402402
let predicate = if a_is_expected {
403-
ty::PredicateKind::ConstEquate(a, b)
403+
ty::PredicateAtom::ConstEquate(a, b)
404404
} else {
405-
ty::PredicateKind::ConstEquate(b, a)
405+
ty::PredicateAtom::ConstEquate(b, a)
406406
};
407407
self.obligations.push(Obligation::new(
408408
self.trace.cause.clone(),

0 commit comments

Comments
 (0)