@@ -128,6 +128,16 @@ pub enum Constraint<'tcx> {
128128 RegSubReg ( Region < ' tcx > , Region < ' tcx > ) ,
129129}
130130
131+ impl Constraint < ' _ > {
132+ pub fn involves_placeholders ( & self ) -> bool {
133+ match self {
134+ Constraint :: VarSubVar ( _, _) => false ,
135+ Constraint :: VarSubReg ( _, r) | Constraint :: RegSubVar ( r, _) => r. is_placeholder ( ) ,
136+ Constraint :: RegSubReg ( r, s) => r. is_placeholder ( ) || s. is_placeholder ( ) ,
137+ }
138+ }
139+ }
140+
131141/// VerifyGenericBound(T, _, R, RS): The parameter type `T` (or
132142/// associated type) must outlive the region `R`. `T` is known to
133143/// outlive `RS`. Therefore verify that `R <= RS[i]` for some
@@ -324,6 +334,8 @@ impl TaintDirections {
324334 }
325335}
326336
337+ pub struct ConstraintInfo { }
338+
327339impl < ' tcx > RegionConstraintCollector < ' tcx > {
328340 pub fn new ( ) -> Self {
329341 Self :: default ( )
@@ -485,7 +497,8 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
485497 ) -> RegionVid {
486498 let vid = self . var_infos . push ( RegionVariableInfo { origin, universe } ) ;
487499
488- let u_vid = self . unification_table
500+ let u_vid = self
501+ . unification_table
489502 . new_key ( unify_key:: RegionVidKey { min_vid : vid } ) ;
490503 assert_eq ! ( vid, u_vid) ;
491504 if self . in_snapshot ( ) {
@@ -517,7 +530,8 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
517530
518531 assert ! ( self . in_snapshot( ) ) ;
519532
520- let constraints_to_kill: Vec < usize > = self . undo_log
533+ let constraints_to_kill: Vec < usize > = self
534+ . undo_log
521535 . iter ( )
522536 . enumerate ( )
523537 . rev ( )
@@ -820,17 +834,18 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
820834 . filter_map ( |& elt| match elt {
821835 AddVar ( vid) => Some ( vid) ,
822836 _ => None ,
823- } )
824- . collect ( )
837+ } ) . collect ( )
825838 }
826839
827- pub fn region_constraints_added_in_snapshot ( & self , mark : & RegionSnapshot ) -> bool {
840+ /// See [`RegionInference::region_constraints_added_in_snapshot`]
841+ pub fn region_constraints_added_in_snapshot ( & self , mark : & RegionSnapshot ) -> Option < bool > {
828842 self . undo_log [ mark. length ..]
829843 . iter ( )
830- . any ( |& elt| match elt {
831- AddConstraint ( _) => true ,
832- _ => false ,
833- } )
844+ . map ( |& elt| match elt {
845+ AddConstraint ( constraint) => Some ( constraint. involves_placeholders ( ) ) ,
846+ _ => None ,
847+ } ) . max ( )
848+ . unwrap_or ( None )
834849 }
835850}
836851
0 commit comments