@@ -42,7 +42,6 @@ use traits::{Obligation, ObligationCause, PredicateObligation};
42
42
use ty:: { self , CanonicalVar , Lift , Region , Slice , Ty , TyCtxt , TypeFlags } ;
43
43
use ty:: subst:: { Kind , UnpackedKind } ;
44
44
use ty:: fold:: { TypeFoldable , TypeFolder } ;
45
- use util:: captures:: Captures ;
46
45
47
46
use rustc_data_structures:: indexed_vec:: IndexVec ;
48
47
use rustc_data_structures:: fx:: FxHashMap ;
@@ -121,7 +120,7 @@ pub enum CanonicalTyVarKind {
121
120
#[ derive( Clone , Debug ) ]
122
121
pub struct QueryResult < ' tcx , R > {
123
122
pub var_values : CanonicalVarValues < ' tcx > ,
124
- pub region_constraints : QueryRegionConstraints < ' tcx > ,
123
+ pub region_constraints : Vec < QueryRegionConstraint < ' tcx > > ,
125
124
pub certainty : Certainty ,
126
125
pub value : R ,
127
126
}
@@ -181,12 +180,7 @@ impl<'tcx, R> Canonical<'tcx, QueryResult<'tcx, R>> {
181
180
}
182
181
}
183
182
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 > > > ;
190
184
191
185
/// Trait implemented by values that can be canonicalized. It mainly
192
186
/// serves to identify the interning table we will use.
@@ -382,35 +376,29 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
382
376
& ' a self ,
383
377
cause : & ' a ObligationCause < ' tcx > ,
384
378
param_env : ty:: ParamEnv < ' tcx > ,
385
- unsubstituted_region_constraints : & ' a QueryRegionConstraints < ' tcx > ,
379
+ unsubstituted_region_constraints : & ' a [ QueryRegionConstraint < ' tcx > ] ,
386
380
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) ;
405
385
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 = _ > >
414
402
}
415
403
416
404
/// Given two sets of values for the same set of canonical variables, unify them.
@@ -913,19 +901,6 @@ BraceStructTypeFoldableImpl! {
913
901
}
914
902
}
915
903
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
-
929
904
BraceStructTypeFoldableImpl ! {
930
905
impl <' tcx, R > TypeFoldable <' tcx> for QueryResult <' tcx, R > {
931
906
var_values, region_constraints, certainty, value
0 commit comments