@@ -13,7 +13,7 @@ use std::iter;
1313use rustc_index:: { Idx , IndexVec } ;
1414use rustc_middle:: arena:: ArenaAllocatable ;
1515use rustc_middle:: bug;
16- use rustc_middle:: infer:: canonical:: CanonicalVarKind ;
16+ use rustc_middle:: infer:: canonical:: { CanonicalVarKind , QueryRegionConstraint } ;
1717use rustc_middle:: ty:: { self , BoundVar , GenericArg , GenericArgKind , Ty , TyCtxt , TypeFoldable } ;
1818use tracing:: { debug, instrument} ;
1919
@@ -188,7 +188,9 @@ impl<'tcx> InferCtxt<'tcx> {
188188 let InferOk { value : result_args, obligations } =
189189 self . query_response_instantiation ( cause, param_env, original_values, query_response) ?;
190190
191- for ( constraint, _category, vis) in & query_response. value . region_constraints . constraints {
191+ for QueryRegionConstraint { constraint, visible_for_leak_check : vis, .. } in
192+ & query_response. value . region_constraints . constraints
193+ {
192194 let constraint = instantiate_value ( self . tcx , & result_args, * constraint) ;
193195 match constraint {
194196 ty:: RegionConstraint :: Outlives ( predicate) => {
@@ -285,11 +287,12 @@ impl<'tcx> InferCtxt<'tcx> {
285287
286288 ( GenericArgKind :: Lifetime ( v_o) , GenericArgKind :: Lifetime ( v_r) ) => {
287289 if v_o != v_r {
288- output_query_region_constraints. constraints . push ( (
289- ty:: RegionEqPredicate ( v_o, v_r) . into ( ) ,
290- constraint_category,
291- ty:: VisibleForLeakCheck :: Yes ,
292- ) ) ;
290+ let constraint = QueryRegionConstraint {
291+ constraint : ty:: RegionEqPredicate ( v_o, v_r) . into ( ) ,
292+ category : constraint_category,
293+ visible_for_leak_check : ty:: VisibleForLeakCheck :: Yes ,
294+ } ;
295+ output_query_region_constraints. constraints . push ( constraint) ;
293296 }
294297 }
295298
@@ -321,7 +324,7 @@ impl<'tcx> InferCtxt<'tcx> {
321324 let r_c = instantiate_value ( self . tcx , & result_args, r_c) ;
322325
323326 // Screen out `'a: 'a` or `'a == 'a` cases.
324- if r_c. 0 . is_trivial ( ) { None } else { Some ( r_c) }
327+ if r_c. constraint . is_trivial ( ) { None } else { Some ( r_c) }
325328 } ) ,
326329 ) ;
327330
@@ -616,7 +619,7 @@ pub fn make_query_region_constraints<'tcx>(
616619
617620 debug ! ( ?constraints) ;
618621
619- let constraints: Vec < _ > = constraints
622+ let constraints: Vec < QueryRegionConstraint < ' tcx > > = constraints
620623 . iter ( )
621624 . map ( |( c, origin) | match c. kind {
622625 ConstraintKind :: VarSubVar
@@ -625,22 +628,30 @@ pub fn make_query_region_constraints<'tcx>(
625628 | ConstraintKind :: RegSubReg => {
626629 // Swap regions because we are going from sub (<=) to outlives (>=).
627630 let constraint = ty:: OutlivesPredicate ( c. sup . into ( ) , c. sub ) . into ( ) ;
628- ( constraint, origin. to_constraint_category ( ) , c. visible_for_leak_check )
631+ QueryRegionConstraint {
632+ constraint,
633+ category : origin. to_constraint_category ( ) ,
634+ visible_for_leak_check : c. visible_for_leak_check ,
635+ }
629636 }
630637
631638 ConstraintKind :: VarEqVar | ConstraintKind :: VarEqReg | ConstraintKind :: RegEqReg => {
632639 let constraint = ty:: RegionEqPredicate ( c. sup , c. sub ) . into ( ) ;
633- ( constraint, origin. to_constraint_category ( ) , c. visible_for_leak_check )
640+ QueryRegionConstraint {
641+ constraint,
642+ category : origin. to_constraint_category ( ) ,
643+ visible_for_leak_check : c. visible_for_leak_check ,
644+ }
634645 }
635646 } )
636647 . chain ( outlives_obligations. into_iter ( ) . map (
637648 |TypeOutlivesConstraint { sub_region, sup_type, origin } | {
638- (
639- ty:: OutlivesPredicate ( sup_type. into ( ) , sub_region) . into ( ) ,
640- origin. to_constraint_category ( ) ,
649+ QueryRegionConstraint {
650+ constraint : ty:: OutlivesPredicate ( sup_type. into ( ) , sub_region) . into ( ) ,
651+ category : origin. to_constraint_category ( ) ,
641652 // We don't do leak checks for type outlives
642- ty:: VisibleForLeakCheck :: Unreachable ,
643- )
653+ visible_for_leak_check : ty:: VisibleForLeakCheck :: Unreachable ,
654+ }
644655 } ,
645656 ) )
646657 . collect ( ) ;
0 commit comments