@@ -391,16 +391,18 @@ where
391
391
// Compute the bounds we can derive from the environment or trait
392
392
// definition. We know that the projection outlives all the
393
393
// regions in this list.
394
- let env_bounds = self . verify_bound . projection_declared_bounds ( projection_ty) ;
394
+ let mut declared_bounds = self . verify_bound
395
+ . projection_declared_bounds_from_env ( projection_ty) ;
395
396
396
- debug ! ( "projection_must_outlive: env_bounds={:?}" , env_bounds) ;
397
+ declared_bounds. extend (
398
+ self . verify_bound
399
+ . projection_declared_bounds_from_trait ( projection_ty) ,
400
+ ) ;
397
401
398
- // If we know that the projection outlives 'static, then we're
399
- // done here.
400
- if env_bounds. contains ( & & ty:: ReStatic ) {
401
- debug ! ( "projection_must_outlive: 'static as declared bound" ) ;
402
- return ;
403
- }
402
+ debug ! (
403
+ "projection_must_outlive: declared_bounds={:?}" ,
404
+ declared_bounds
405
+ ) ;
404
406
405
407
// If declared bounds list is empty, the only applicable rule is
406
408
// OutlivesProjectionComponent. If there are inference variables,
@@ -417,7 +419,7 @@ where
417
419
// inference variables, we use a verify constraint instead of adding
418
420
// edges, which winds up enforcing the same condition.
419
421
let needs_infer = projection_ty. needs_infer ( ) ;
420
- if env_bounds . is_empty ( ) && needs_infer {
422
+ if declared_bounds . is_empty ( ) && needs_infer {
421
423
debug ! ( "projection_must_outlive: no declared bounds" ) ;
422
424
423
425
for component_ty in projection_ty. substs . types ( ) {
@@ -440,16 +442,20 @@ where
440
442
// the requirement that `'b:'r`
441
443
// - OutlivesProjectionComponent: this would require `'b:'r` in addition to
442
444
// other conditions
443
- if !env_bounds. is_empty ( ) && env_bounds[ 1 ..] . iter ( ) . all ( |b| * b == env_bounds[ 0 ] ) {
444
- let unique_bound = env_bounds[ 0 ] ;
445
+ if !declared_bounds. is_empty ( )
446
+ && declared_bounds[ 1 ..]
447
+ . iter ( )
448
+ . all ( |b| * b == declared_bounds[ 0 ] )
449
+ {
450
+ let unique_bound = declared_bounds[ 0 ] ;
445
451
debug ! (
446
452
"projection_must_outlive: unique declared bound = {:?}" ,
447
453
unique_bound
448
454
) ;
449
455
if projection_ty
450
456
. substs
451
457
. regions ( )
452
- . any ( |r| env_bounds . contains ( & r) )
458
+ . any ( |r| declared_bounds . contains ( & r) )
453
459
{
454
460
debug ! ( "projection_must_outlive: unique declared bound appears in trait ref" ) ;
455
461
self . delegate
0 commit comments