@@ -336,6 +336,7 @@ where
336
336
GenericKind :: Opaque ( def_id, substs) ,
337
337
def_id,
338
338
substs,
339
+ true ,
339
340
|ty| match * ty. kind ( ) {
340
341
ty:: Opaque ( def_id, substs) => ( def_id, substs) ,
341
342
_ => bug ! ( "expected only projection types from env, not {:?}" , ty) ,
@@ -356,6 +357,7 @@ where
356
357
GenericKind :: Projection ( projection_ty) ,
357
358
projection_ty. item_def_id ,
358
359
projection_ty. substs ,
360
+ false ,
359
361
|ty| match ty. kind ( ) {
360
362
ty:: Projection ( projection_ty) => ( projection_ty. item_def_id , projection_ty. substs ) ,
361
363
_ => bug ! ( "expected only projection types from env, not {:?}" , ty) ,
@@ -371,6 +373,7 @@ where
371
373
generic : GenericKind < ' tcx > ,
372
374
def_id : DefId ,
373
375
substs : SubstsRef < ' tcx > ,
376
+ is_opaque : bool ,
374
377
filter : impl Fn ( Ty < ' tcx > ) -> ( DefId , SubstsRef < ' tcx > ) ,
375
378
) {
376
379
// An optimization for a common case with opaque types.
@@ -437,7 +440,7 @@ where
437
440
// inference variables, we use a verify constraint instead of adding
438
441
// edges, which winds up enforcing the same condition.
439
442
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 ) {
441
444
debug ! ( "no declared bounds" ) ;
442
445
443
446
self . substs_must_outlive ( substs, origin, region) ;
0 commit comments