@@ -571,11 +571,15 @@ impl<'tcx> RegionInferenceContext<'tcx> {
571
571
}
572
572
}
573
573
574
- /// Returns `true` if all the elements in the value of `scc_b` are nameable
574
+ /// Returns `true` if all the placeholders in the value of `scc_b` are nameable
575
575
/// in `scc_a`. Used during constraint propagation, and only once
576
576
/// the value of `scc_b` has been computed.
577
- fn universe_compatible ( & self , scc_b : ConstraintSccIndex , scc_a : ConstraintSccIndex ) -> bool {
578
- self . scc_annotations [ scc_a] . universe_compatible_with ( self . scc_annotations [ scc_b] )
577
+ fn can_name_all_placeholders (
578
+ & self ,
579
+ scc_a : ConstraintSccIndex ,
580
+ scc_b : ConstraintSccIndex ,
581
+ ) -> bool {
582
+ self . scc_annotations [ scc_a] . can_name_all_placeholders ( self . scc_annotations [ scc_b] )
579
583
}
580
584
581
585
/// Once regions have been propagated, this method is used to see
@@ -964,16 +968,22 @@ impl<'tcx> RegionInferenceContext<'tcx> {
964
968
return true ;
965
969
}
966
970
971
+ let fr_static = self . universal_regions ( ) . fr_static ;
972
+
967
973
// If we are checking that `'sup: 'sub`, and `'sub` contains
968
974
// some placeholder that `'sup` cannot name, then this is only
969
975
// true if `'sup` outlives static.
970
- if !self . universe_compatible ( sub_region_scc, sup_region_scc) {
976
+ //
977
+ // Avoid infinite recursion if `sub_region` is already `'static`
978
+ if sub_region != fr_static
979
+ && !self . can_name_all_placeholders ( sup_region_scc, sub_region_scc)
980
+ {
971
981
debug ! (
972
982
"sub universe `{sub_region_scc:?}` is not nameable \
973
983
by super `{sup_region_scc:?}`, promoting to static",
974
984
) ;
975
985
976
- return self . eval_outlives ( sup_region, self . universal_regions ( ) . fr_static ) ;
986
+ return self . eval_outlives ( sup_region, fr_static) ;
977
987
}
978
988
979
989
// Both the `sub_region` and `sup_region` consist of the union
0 commit comments