@@ -325,8 +325,21 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
325325 }
326326 }
327327
328- debug ! ( "enforce_member_constraint: final least choice = {:?}" , least_choice) ;
329- if least_choice != member_lower_bound {
328+ // (#72087) Different `ty::Regions` can be known to be equal, for
329+ // example, we know that `'a` and `'static` are equal in a function
330+ // with a parameter of type `&'static &'a ()`.
331+ //
332+ // When we have two equal regions like this `expansion` will use
333+ // `lub_concrete_regions` to pick a canonical representative. The same
334+ // choice is needed here so that we don't end up in a cycle of
335+ // `expansion` changing the region one way and the code here changing
336+ // it back.
337+ let lub = self . lub_concrete_regions ( least_choice, member_lower_bound) ;
338+ debug ! (
339+ "enforce_member_constraint: final least choice = {:?}\n lub = {:?}" ,
340+ least_choice, lub
341+ ) ;
342+ if lub != member_lower_bound {
330343 * var_values. value_mut ( member_vid) = VarValue :: Value ( least_choice) ;
331344 true
332345 } else {
@@ -578,8 +591,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
578591 self . tcx ( ) . mk_region ( ReScope ( lub) )
579592 }
580593
581- ( & ReEarlyBound ( _) , & ReEarlyBound ( _) | & ReFree ( _) )
582- | ( & ReFree ( _) , & ReEarlyBound ( _) | & ReFree ( _) ) => {
594+ ( & ReEarlyBound ( _) | & ReFree ( _) , & ReEarlyBound ( _) | & ReFree ( _) ) => {
583595 self . region_rels . lub_free_regions ( a, b)
584596 }
585597
0 commit comments