@@ -712,16 +712,28 @@ impl<'tcx> RegionInferenceContext<'tcx> {
712712 * c_r = self . scc_representatives [ scc] ;
713713 }
714714
715- // The 'member region' in a member constraint is part of the
716- // hidden type, which must be in the root universe. Therefore,
717- // it cannot have any placeholders in its value.
718- assert ! ( self . scc_universes[ scc] == ty:: UniverseIndex :: ROOT ) ;
719- debug_assert ! (
720- self . scc_values. placeholders_contained_in( scc) . next( ) . is_none( ) ,
721- "scc {:?} in a member constraint has placeholder value: {:?}" ,
722- scc,
723- self . scc_values. region_value_str( scc) ,
724- ) ;
715+ // The 'member region' may have a placeholder region in its value.
716+ // Consider the inner opaque type `impl Sized` in:
717+ // `fn test() -> impl for<'a> Trait<'a, Ty = impl Sized + 'a>`.
718+ // Here choice_regions = ['static, Placeholder('a, U1)].
719+ if self . scc_universes [ scc] != ty:: UniverseIndex :: ROOT {
720+ let Some ( & choice) = choice_regions
721+ . iter ( )
722+ . find ( |& & choice| self . eval_equal ( choice, self . scc_representatives [ scc] ) )
723+ else {
724+ debug ! ( "failed higher-ranked member constraint" ) ;
725+ return false ;
726+ } ;
727+
728+ self . member_constraints_applied . push ( AppliedMemberConstraint {
729+ member_region_scc : scc,
730+ min_choice : choice,
731+ member_constraint_index,
732+ } ) ;
733+
734+ debug ! ( ?choice, "higher-ranked" ) ;
735+ return true ;
736+ }
725737
726738 // The existing value for `scc` is a lower-bound. This will
727739 // consist of some set `{P} + {LB}` of points `{P}` and
0 commit comments