@@ -571,11 +571,15 @@ impl<'tcx> RegionInferenceContext<'tcx> {
571571 }
572572 }
573573
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
575575 /// in `scc_a`. Used during constraint propagation, and only once
576576 /// 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] )
579583 }
580584
581585 /// Once regions have been propagated, this method is used to see
@@ -964,16 +968,22 @@ impl<'tcx> RegionInferenceContext<'tcx> {
964968 return true ;
965969 }
966970
971+ let fr_static = self . universal_regions ( ) . fr_static ;
972+
967973 // If we are checking that `'sup: 'sub`, and `'sub` contains
968974 // some placeholder that `'sup` cannot name, then this is only
969975 // 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+ {
971981 debug ! (
972982 "sub universe `{sub_region_scc:?}` is not nameable \
973983 by super `{sup_region_scc:?}`, promoting to static",
974984 ) ;
975985
976- return self . eval_outlives ( sup_region, self . universal_regions ( ) . fr_static ) ;
986+ return self . eval_outlives ( sup_region, fr_static) ;
977987 }
978988
979989 // Both the `sub_region` and `sup_region` consist of the union
0 commit comments