@@ -128,6 +128,16 @@ pub enum Constraint<'tcx> {
128
128
RegSubReg ( Region < ' tcx > , Region < ' tcx > ) ,
129
129
}
130
130
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
+
131
141
/// VerifyGenericBound(T, _, R, RS): The parameter type `T` (or
132
142
/// associated type) must outlive the region `R`. `T` is known to
133
143
/// outlive `RS`. Therefore verify that `R <= RS[i]` for some
@@ -324,6 +334,8 @@ impl TaintDirections {
324
334
}
325
335
}
326
336
337
+ pub struct ConstraintInfo { }
338
+
327
339
impl < ' tcx > RegionConstraintCollector < ' tcx > {
328
340
pub fn new ( ) -> Self {
329
341
Self :: default ( )
@@ -485,7 +497,8 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
485
497
) -> RegionVid {
486
498
let vid = self . var_infos . push ( RegionVariableInfo { origin, universe } ) ;
487
499
488
- let u_vid = self . unification_table
500
+ let u_vid = self
501
+ . unification_table
489
502
. new_key ( unify_key:: RegionVidKey { min_vid : vid } ) ;
490
503
assert_eq ! ( vid, u_vid) ;
491
504
if self . in_snapshot ( ) {
@@ -517,7 +530,8 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
517
530
518
531
assert ! ( self . in_snapshot( ) ) ;
519
532
520
- let constraints_to_kill: Vec < usize > = self . undo_log
533
+ let constraints_to_kill: Vec < usize > = self
534
+ . undo_log
521
535
. iter ( )
522
536
. enumerate ( )
523
537
. rev ( )
@@ -820,17 +834,18 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
820
834
. filter_map ( |& elt| match elt {
821
835
AddVar ( vid) => Some ( vid) ,
822
836
_ => None ,
823
- } )
824
- . collect ( )
837
+ } ) . collect ( )
825
838
}
826
839
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 > {
828
842
self . undo_log [ mark. length ..]
829
843
. 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 )
834
849
}
835
850
}
836
851
0 commit comments