@@ -42,7 +42,6 @@ use traits::{Obligation, ObligationCause, PredicateObligation};
4242use ty:: { self , CanonicalVar , Lift , Region , Slice , Ty , TyCtxt , TypeFlags } ;
4343use ty:: subst:: { Kind , UnpackedKind } ;
4444use ty:: fold:: { TypeFoldable , TypeFolder } ;
45- use util:: captures:: Captures ;
4645
4746use rustc_data_structures:: indexed_vec:: IndexVec ;
4847use rustc_data_structures:: fx:: FxHashMap ;
@@ -121,7 +120,7 @@ pub enum CanonicalTyVarKind {
121120#[ derive( Clone , Debug ) ]
122121pub struct QueryResult < ' tcx , R > {
123122 pub var_values : CanonicalVarValues < ' tcx > ,
124- pub region_constraints : QueryRegionConstraints < ' tcx > ,
123+ pub region_constraints : Vec < QueryRegionConstraint < ' tcx > > ,
125124 pub certainty : Certainty ,
126125 pub value : R ,
127126}
@@ -181,12 +180,7 @@ impl<'tcx, R> Canonical<'tcx, QueryResult<'tcx, R>> {
181180 }
182181}
183182
184- /// Subset of `RegionConstraintData` produced by trait query.
185- #[ derive( Clone , Debug , Default ) ]
186- pub struct QueryRegionConstraints < ' tcx > {
187- pub region_outlives : Vec < ( Region < ' tcx > , Region < ' tcx > ) > ,
188- pub ty_outlives : Vec < ( Ty < ' tcx > , Region < ' tcx > ) > ,
189- }
183+ pub type QueryRegionConstraint < ' tcx > = ty:: Binder < ty:: OutlivesPredicate < Kind < ' tcx > , Region < ' tcx > > > ;
190184
191185/// Trait implemented by values that can be canonicalized. It mainly
192186/// serves to identify the interning table we will use.
@@ -382,35 +376,29 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
382376 & ' a self ,
383377 cause : & ' a ObligationCause < ' tcx > ,
384378 param_env : ty:: ParamEnv < ' tcx > ,
385- unsubstituted_region_constraints : & ' a QueryRegionConstraints < ' tcx > ,
379+ unsubstituted_region_constraints : & ' a [ QueryRegionConstraint < ' tcx > ] ,
386380 result_subst : & ' a CanonicalVarValues < ' tcx > ,
387- ) -> impl Iterator < Item = PredicateObligation < ' tcx > > + Captures < ' gcx > + ' a {
388- let QueryRegionConstraints {
389- region_outlives,
390- ty_outlives,
391- } = unsubstituted_region_constraints;
392-
393- let region_obligations = region_outlives. iter ( ) . map ( move |( r1, r2) | {
394- let r1 = substitute_value ( self . tcx , result_subst, r1) ;
395- let r2 = substitute_value ( self . tcx , result_subst, r2) ;
396- Obligation :: new (
397- cause. clone ( ) ,
398- param_env,
399- ty:: Predicate :: RegionOutlives ( ty:: Binder ( ty:: OutlivesPredicate ( r1, r2) ) ) ,
400- )
401- } ) ;
402-
403- let ty_obligations = ty_outlives. iter ( ) . map ( move |( t1, r2) | {
404- let t1 = substitute_value ( self . tcx , result_subst, t1) ;
381+ ) -> impl Iterator < Item = PredicateObligation < ' tcx > > + ' a {
382+ Box :: new ( unsubstituted_region_constraints. iter ( ) . map ( move |constraint| {
383+ let ty:: OutlivesPredicate ( k1, r2) = constraint. skip_binder ( ) ; // restored below
384+ let k1 = substitute_value ( self . tcx , result_subst, k1) ;
405385 let r2 = substitute_value ( self . tcx , result_subst, r2) ;
406- Obligation :: new (
407- cause. clone ( ) ,
408- param_env,
409- ty:: Predicate :: TypeOutlives ( ty:: Binder ( ty:: OutlivesPredicate ( t1, r2) ) ) ,
410- )
411- } ) ;
412-
413- region_obligations. chain ( ty_obligations)
386+ match k1. unpack ( ) {
387+ UnpackedKind :: Lifetime ( r1) =>
388+ Obligation :: new (
389+ cause. clone ( ) ,
390+ param_env,
391+ ty:: Predicate :: RegionOutlives ( ty:: Binder ( ty:: OutlivesPredicate ( r1, r2) ) ) ,
392+ ) ,
393+
394+ UnpackedKind :: Type ( t1) =>
395+ Obligation :: new (
396+ cause. clone ( ) ,
397+ param_env,
398+ ty:: Predicate :: TypeOutlives ( ty:: Binder ( ty:: OutlivesPredicate ( t1, r2) ) ) ,
399+ ) ,
400+ }
401+ } ) ) as Box < dyn Iterator < Item = _ > >
414402 }
415403
416404 /// Given two sets of values for the same set of canonical variables, unify them.
@@ -913,19 +901,6 @@ BraceStructTypeFoldableImpl! {
913901 }
914902}
915903
916- BraceStructTypeFoldableImpl ! {
917- impl <' tcx> TypeFoldable <' tcx> for QueryRegionConstraints <' tcx> {
918- region_outlives, ty_outlives
919- }
920- }
921-
922- BraceStructLiftImpl ! {
923- impl <' a, ' tcx> Lift <' tcx> for QueryRegionConstraints <' a> {
924- type Lifted = QueryRegionConstraints <' tcx>;
925- region_outlives, ty_outlives
926- }
927- }
928-
929904BraceStructTypeFoldableImpl ! {
930905 impl <' tcx, R > TypeFoldable <' tcx> for QueryResult <' tcx, R > {
931906 var_values, region_constraints, certainty, value
0 commit comments