@@ -978,7 +978,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
978
978
propagated_outlives_requirements : & mut Vec < ClosureOutlivesRequirement < ' tcx > > ,
979
979
) -> bool {
980
980
let tcx = infcx. tcx ;
981
- let TypeTest { generic_kind, lower_bound, span : blame_span, ref verify_bound } = * type_test;
981
+ let TypeTest { generic_kind, lower_bound, span : blame_span, verify_bound : _ } = * type_test;
982
982
983
983
let generic_ty = generic_kind. to_ty ( tcx) ;
984
984
let Some ( subject) = self . try_promote_type_test_subject ( infcx, generic_ty) else {
@@ -1016,25 +1016,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1016
1016
// For each region outlived by lower_bound find a non-local,
1017
1017
// universal region (it may be the same region) and add it to
1018
1018
// `ClosureOutlivesRequirement`.
1019
+ let mut found_outlived_universal_region = false ;
1019
1020
for ur in self . scc_values . universal_regions_outlived_by ( r_scc) {
1021
+ found_outlived_universal_region = true ;
1020
1022
debug ! ( "universal_region_outlived_by ur={:?}" , ur) ;
1021
- // Check whether we can already prove that the "subject" outlives `ur`.
1022
- // If so, we don't have to propagate this requirement to our caller.
1023
- //
1024
- // To continue the example from the function, if we are trying to promote
1025
- // a requirement that `T: 'X`, and we know that `'X = '1 + '2` (i.e., the union
1026
- // `'1` and `'2`), then in this loop `ur` will be `'1` (and `'2`). So here
1027
- // we check whether `T: '1` is something we *can* prove. If so, no need
1028
- // to propagate that requirement.
1029
- //
1030
- // This is needed because -- particularly in the case
1031
- // where `ur` is a local bound -- we are sometimes in a
1032
- // position to prove things that our caller cannot. See
1033
- // #53570 for an example.
1034
- if self . eval_verify_bound ( infcx, generic_ty, ur, & verify_bound) {
1035
- continue ;
1036
- }
1037
-
1038
1023
let non_local_ub = self . universal_region_relations . non_local_upper_bounds ( ur) ;
1039
1024
debug ! ( ?non_local_ub) ;
1040
1025
@@ -1056,6 +1041,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1056
1041
propagated_outlives_requirements. push ( requirement) ;
1057
1042
}
1058
1043
}
1044
+ // If we succeed to promote the subject, i.e. it only contains non-local regions,
1045
+ // and fail to prove the type test inside of the closure, the `lower_bound` has to
1046
+ // also be at least as large as some universal region, as the type test is otherwise
1047
+ // trivial.
1048
+ assert ! ( found_outlived_universal_region) ;
1059
1049
true
1060
1050
}
1061
1051
0 commit comments