@@ -336,6 +336,7 @@ where
336336 GenericKind :: Opaque ( def_id, substs) ,
337337 def_id,
338338 substs,
339+ true ,
339340 |ty| match * ty. kind ( ) {
340341 ty:: Opaque ( def_id, substs) => ( def_id, substs) ,
341342 _ => bug ! ( "expected only projection types from env, not {:?}" , ty) ,
@@ -356,6 +357,7 @@ where
356357 GenericKind :: Projection ( projection_ty) ,
357358 projection_ty. item_def_id ,
358359 projection_ty. substs ,
360+ false ,
359361 |ty| match ty. kind ( ) {
360362 ty:: Projection ( projection_ty) => ( projection_ty. item_def_id , projection_ty. substs ) ,
361363 _ => bug ! ( "expected only projection types from env, not {:?}" , ty) ,
@@ -371,6 +373,7 @@ where
371373 generic : GenericKind < ' tcx > ,
372374 def_id : DefId ,
373375 substs : SubstsRef < ' tcx > ,
376+ is_opaque : bool ,
374377 filter : impl Fn ( Ty < ' tcx > ) -> ( DefId , SubstsRef < ' tcx > ) ,
375378 ) {
376379 // An optimization for a common case with opaque types.
@@ -437,7 +440,7 @@ where
437440 // inference variables, we use a verify constraint instead of adding
438441 // edges, which winds up enforcing the same condition.
439442 let needs_infer = substs. needs_infer ( ) ;
440- if approx_env_bounds. is_empty ( ) && trait_bounds. is_empty ( ) && needs_infer {
443+ if approx_env_bounds. is_empty ( ) && trait_bounds. is_empty ( ) && ( needs_infer || is_opaque ) {
441444 debug ! ( "no declared bounds" ) ;
442445
443446 self . substs_must_outlive ( substs, origin, region) ;
0 commit comments