@@ -547,25 +547,34 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
547
547
) -> impl Iterator < Item = PredicateObligation < ' tcx > > + ' a + Captures < ' tcx > {
548
548
unsubstituted_region_constraints. iter ( ) . map ( move |& constraint| {
549
549
let predicate = substitute_value ( self . tcx , result_subst, constraint) ;
550
- let ty:: OutlivesPredicate ( k1, r2) = predicate. skip_binder ( ) ;
550
+ self . query_outlives_constraint_to_obligation ( predicate, cause. clone ( ) , param_env)
551
+ } )
552
+ }
551
553
552
- let atom = match k1. unpack ( ) {
553
- GenericArgKind :: Lifetime ( r1) => {
554
- ty:: PredicateKind :: RegionOutlives ( ty:: OutlivesPredicate ( r1, r2) )
555
- }
556
- GenericArgKind :: Type ( t1) => {
557
- ty:: PredicateKind :: TypeOutlives ( ty:: OutlivesPredicate ( t1, r2) )
558
- }
559
- GenericArgKind :: Const ( ..) => {
560
- // Consts cannot outlive one another, so we don't expect to
561
- // encounter this branch.
562
- span_bug ! ( cause. span, "unexpected const outlives {:?}" , constraint) ;
563
- }
564
- } ;
565
- let predicate = predicate. rebind ( atom) . to_predicate ( self . tcx ) ;
554
+ pub fn query_outlives_constraint_to_obligation (
555
+ & self ,
556
+ predicate : QueryOutlivesConstraint < ' tcx > ,
557
+ cause : ObligationCause < ' tcx > ,
558
+ param_env : ty:: ParamEnv < ' tcx > ,
559
+ ) -> Obligation < ' tcx , ty:: Predicate < ' tcx > > {
560
+ let ty:: OutlivesPredicate ( k1, r2) = predicate. skip_binder ( ) ;
566
561
567
- Obligation :: new ( cause. clone ( ) , param_env, predicate)
568
- } )
562
+ let atom = match k1. unpack ( ) {
563
+ GenericArgKind :: Lifetime ( r1) => {
564
+ ty:: PredicateKind :: RegionOutlives ( ty:: OutlivesPredicate ( r1, r2) )
565
+ }
566
+ GenericArgKind :: Type ( t1) => {
567
+ ty:: PredicateKind :: TypeOutlives ( ty:: OutlivesPredicate ( t1, r2) )
568
+ }
569
+ GenericArgKind :: Const ( ..) => {
570
+ // Consts cannot outlive one another, so we don't expect to
571
+ // encounter this branch.
572
+ span_bug ! ( cause. span, "unexpected const outlives {:?}" , predicate) ;
573
+ }
574
+ } ;
575
+ let predicate = predicate. rebind ( atom) . to_predicate ( self . tcx ) ;
576
+
577
+ Obligation :: new ( cause, param_env, predicate)
569
578
}
570
579
571
580
/// Given two sets of values for the same set of canonical variables, unify them.
0 commit comments