@@ -16,7 +16,7 @@ use borrow_check::nll::type_check::free_region_relations::UniversalRegionRelatio
16
16
use borrow_check:: nll:: type_check:: Locations ;
17
17
use rustc:: hir:: def_id:: DefId ;
18
18
use rustc:: infer:: canonical:: QueryRegionConstraint ;
19
- use rustc:: infer:: region_constraints:: { GenericKind , VarInfos } ;
19
+ use rustc:: infer:: region_constraints:: { GenericKind , VarInfos , VerifyBound } ;
20
20
use rustc:: infer:: { InferCtxt , NLLRegionVariableOrigin , RegionVariableOrigin } ;
21
21
use rustc:: mir:: {
22
22
ClosureOutlivesRequirement , ClosureOutlivesSubject , ClosureRegionRequirements , Local , Location ,
@@ -160,33 +160,7 @@ pub struct TypeTest<'tcx> {
160
160
161
161
/// A test which, if met by the region `'x`, proves that this type
162
162
/// 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 > ,
190
164
}
191
165
192
166
impl < ' tcx > RegionInferenceContext < ' tcx > {
@@ -571,7 +545,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
571
545
for type_test in & self . type_tests {
572
546
debug ! ( "check_type_test: {:?}" , type_test) ;
573
547
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 ) {
575
549
continue ;
576
550
}
577
551
@@ -678,7 +652,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
678
652
generic_kind,
679
653
lower_bound,
680
654
locations,
681
- test : _,
655
+ verify_bound : _,
682
656
} = type_test;
683
657
684
658
let generic_ty = generic_kind. to_ty ( tcx) ;
@@ -705,7 +679,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
705
679
// where `ur` is a local bound -- we are sometimes in a
706
680
// position to prove things that our caller cannot. See
707
681
// #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 ) {
709
683
continue ;
710
684
}
711
685
@@ -877,22 +851,32 @@ impl<'tcx> RegionInferenceContext<'tcx> {
877
851
878
852
/// Test if `test` is true when applied to `lower_bound` at
879
853
/// `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 {
881
860
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
884
863
) ;
885
864
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
+ }
888
872
889
- RegionTest :: Any ( tests ) => tests
873
+ VerifyBound :: AnyBound ( verify_bounds ) => verify_bounds
890
874
. 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 ) ) ,
892
876
893
- RegionTest :: All ( tests ) => tests
877
+ VerifyBound :: AllBounds ( verify_bounds ) => verify_bounds
894
878
. 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 ) ) ,
896
880
}
897
881
}
898
882
0 commit comments