@@ -426,14 +426,15 @@ impl<'tcx> GenericPredicates<'tcx> {
426426 type Result = ControlFlow < ( ) > ;
427427 fn visit_region ( & mut self , r : Region < ' tcx > ) -> Self :: Result {
428428 match r. kind ( ) {
429- RegionKind :: ReEarlyParam ( _param) => ControlFlow :: Break ( ( ) ) ,
430- RegionKind :: ReBound ( ..)
431- | RegionKind :: ReLateParam ( _)
429+ RegionKind :: ReEarlyParam ( _)
432430 | RegionKind :: ReStatic
433431 | RegionKind :: ReVar ( _)
434432 | RegionKind :: RePlaceholder ( _)
435433 | RegionKind :: ReErased
436- | RegionKind :: ReError ( _) => ControlFlow :: Continue ( ( ) ) ,
434+ | RegionKind :: ReError ( _) => ControlFlow :: Break ( ( ) ) ,
435+ RegionKind :: ReBound ( ..) | RegionKind :: ReLateParam ( _) => {
436+ ControlFlow :: Continue ( ( ) )
437+ }
437438 }
438439 }
439440
@@ -454,10 +455,18 @@ impl<'tcx> GenericPredicates<'tcx> {
454455 // don't allow this impl to be used.
455456 self . predicates . iter ( ) . all ( |( clause, _) | {
456457 match clause. kind ( ) . skip_binder ( ) {
457- ClauseKind :: Trait ( _trait_predicate) => {
458- // FIXME(try_as_dyn): allow trait bounds that do not mention lifetimes.
459- // These bounds themselves are fine, as their impls either are fine or
460- // rejected by this very check when encountered.
458+ ClauseKind :: Trait ( trait_predicate) => {
459+ // In a `T: Trait`, if the rhs bound does not contain any generic params
460+ // or 'static lifetimes, then it cannot transitively cause such requirements,
461+ // considering we apply the fully-generic-for-reflection rules to any impls for
462+ // that trait, too.
463+ if matches ! ( trait_predicate. self_ty( ) . kind( ) , ty:: Param ( _) )
464+ && trait_predicate. trait_ref . args [ 1 ..]
465+ . iter ( )
466+ . all ( |arg| arg. visit_with ( & mut ParamChecker ) . is_continue ( ) )
467+ {
468+ return true ;
469+ }
461470 }
462471 ClauseKind :: RegionOutlives ( _)
463472 | ClauseKind :: TypeOutlives ( _)
0 commit comments