@@ -16,7 +16,7 @@ use borrow_check::nll::type_check::free_region_relations::UniversalRegionRelatio
1616use borrow_check:: nll:: type_check:: Locations ;
1717use rustc:: hir:: def_id:: DefId ;
1818use rustc:: infer:: canonical:: QueryRegionConstraint ;
19- use rustc:: infer:: region_constraints:: { GenericKind , VarInfos } ;
19+ use rustc:: infer:: region_constraints:: { GenericKind , VarInfos , VerifyBound } ;
2020use rustc:: infer:: { InferCtxt , NLLRegionVariableOrigin , RegionVariableOrigin } ;
2121use rustc:: mir:: {
2222 ClosureOutlivesRequirement , ClosureOutlivesSubject , ClosureRegionRequirements , Local , Location ,
@@ -160,33 +160,7 @@ pub struct TypeTest<'tcx> {
160160
161161 /// A test which, if met by the region `'x`, proves that this type
162162 /// constraint is satisfied.
163- pub test : RegionTest ,
164- }
165-
166- /// A "test" that can be applied to some "subject region" `'x`. These are used to
167- /// describe type constraints. Tests do not presently affect the
168- /// region values that get inferred for each variable; they only
169- /// examine the results *after* inference. This means they can
170- /// conveniently include disjuction ("a or b must be true").
171- #[ derive( Clone , Debug ) ]
172- pub enum RegionTest {
173- /// The subject region `'x` must by outlived by the given region.
174- ///
175- /// This test comes from e.g. a where clause like `T: 'a`, which
176- /// implies that we know that `T: 'a`. Therefore, if we are trying
177- /// to prove that `T: 'x`, we can do so by showing that `'a: 'x`.
178- IsOutlivedBy ( RegionVid ) ,
179-
180- /// Any of the given tests are true.
181- ///
182- /// This test comes from e.g. a where clause like `T: 'a + 'b`,
183- /// which implies that we know that `T: 'a` and that `T:
184- /// 'b`. Therefore, if we are trying to prove that `T: 'x`, we can
185- /// do so by showing that `'a: 'x` *or* `'b: 'x`.
186- Any ( Vec < RegionTest > ) ,
187-
188- /// All of the given tests are true.
189- All ( Vec < RegionTest > ) ,
163+ pub verify_bound : VerifyBound < ' tcx > ,
190164}
191165
192166impl < ' tcx > RegionInferenceContext < ' tcx > {
@@ -571,7 +545,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
571545 for type_test in & self . type_tests {
572546 debug ! ( "check_type_test: {:?}" , type_test) ;
573547
574- if self . eval_region_test ( mir, type_test. lower_bound , & type_test. test ) {
548+ if self . eval_verify_bound ( mir, type_test. lower_bound , & type_test. verify_bound ) {
575549 continue ;
576550 }
577551
@@ -678,7 +652,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
678652 generic_kind,
679653 lower_bound,
680654 locations,
681- test : _,
655+ verify_bound : _,
682656 } = type_test;
683657
684658 let generic_ty = generic_kind. to_ty ( tcx) ;
@@ -705,7 +679,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
705679 // where `ur` is a local bound -- we are sometimes in a
706680 // position to prove things that our caller cannot. See
707681 // #53570 for an example.
708- if self . eval_region_test ( mir, ur, & type_test. test ) {
682+ if self . eval_verify_bound ( mir, ur, & type_test. verify_bound ) {
709683 continue ;
710684 }
711685
@@ -877,22 +851,32 @@ impl<'tcx> RegionInferenceContext<'tcx> {
877851
878852 /// Test if `test` is true when applied to `lower_bound` at
879853 /// `point`, and returns true or false.
880- fn eval_region_test ( & self , mir : & Mir < ' tcx > , lower_bound : RegionVid , test : & RegionTest ) -> bool {
854+ fn eval_verify_bound (
855+ & self ,
856+ mir : & Mir < ' tcx > ,
857+ lower_bound : RegionVid ,
858+ verify_bound : & VerifyBound < ' tcx > ,
859+ ) -> bool {
881860 debug ! (
882- "eval_region_test (lower_bound={:?}, test ={:?})" ,
883- lower_bound, test
861+ "eval_verify_bound (lower_bound={:?}, verify_bound ={:?})" ,
862+ lower_bound, verify_bound
884863 ) ;
885864
886- match test {
887- RegionTest :: IsOutlivedBy ( r) => self . eval_outlives ( mir, * r, lower_bound) ,
865+ match verify_bound {
866+ VerifyBound :: IfEq ( ..) => false , // FIXME
867+
868+ VerifyBound :: OutlivedBy ( r) => {
869+ let r_vid = self . to_region_vid ( r) ;
870+ self . eval_outlives ( mir, r_vid, lower_bound)
871+ }
888872
889- RegionTest :: Any ( tests ) => tests
873+ VerifyBound :: AnyBound ( verify_bounds ) => verify_bounds
890874 . iter ( )
891- . any ( |test | self . eval_region_test ( mir, lower_bound, test ) ) ,
875+ . any ( |verify_bound | self . eval_verify_bound ( mir, lower_bound, verify_bound ) ) ,
892876
893- RegionTest :: All ( tests ) => tests
877+ VerifyBound :: AllBounds ( verify_bounds ) => verify_bounds
894878 . iter ( )
895- . all ( |test | self . eval_region_test ( mir, lower_bound, test ) ) ,
879+ . all ( |verify_bound | self . eval_verify_bound ( mir, lower_bound, verify_bound ) ) ,
896880 }
897881 }
898882
0 commit comments