@@ -20,7 +20,7 @@ use crate::ty::VarianceDiagInfo;
20
20
use crate :: type_check:: free_region_relations:: UniversalRegionRelations ;
21
21
use crate :: type_check:: { Locations , MirTypeckRegionConstraints } ;
22
22
use crate :: universal_regions:: UniversalRegions ;
23
- use crate :: { BorrowckInferCtxt , NllRegionVariableOrigin } ;
23
+ use crate :: { BorrowckInferCtxt , NllRegionVariableOrigin , bug } ;
24
24
25
25
/// A set of outlives constraints after rewriting to remove
26
26
/// higher-kinded constraints.
@@ -428,39 +428,33 @@ fn rewrite_placeholder_outlives<'tcx>(
428
428
// That constraint is annotated with some placeholder `unnameable` where
429
429
// `unnameable` is unnameable from `r` and there is a path in the constraint graph
430
430
// between them.
431
- //
432
- // There is one exception; if some other region in this SCC can't name `'r`, then
433
- // we pick the region with the smallest universe in the SCC, so that a path can
434
- // always start in `'r` to find a motivation that isn't cyclic.
435
- let blame_to = if annotation. representative . rvid ( ) == max_u_rvid {
436
- // Assertion: the region that lowered our universe is an existential one and we are a placeholder!
437
-
431
+ if annotation. representative . rvid ( ) != max_u_rvid {
432
+ // FIXME: if we can extract a useful blame span here, future error
433
+ // reporting and constraint search can be simplified.
434
+
435
+ added_constraints = true ;
436
+ outlives_constraints. push ( OutlivesConstraint {
437
+ sup : annotation. representative . rvid ( ) ,
438
+ sub : fr_static,
439
+ category : ConstraintCategory :: OutlivesUnnameablePlaceholder ( max_u_rvid) ,
440
+ locations : Locations :: All ( rustc_span:: DUMMY_SP ) ,
441
+ span : rustc_span:: DUMMY_SP ,
442
+ variance_info : VarianceDiagInfo :: None ,
443
+ from_closure : false ,
444
+ } ) ;
445
+ } else if !( annotation. reaches_existential_that_cannot_name_us ( ) . is_some ( )
446
+ || annotation. reaches_other_placeholder ( annotation. representative . rvid ( ) ) . is_some ( ) )
447
+ {
438
448
// The SCC's representative is not nameable from some region
439
- // that ends up in the SCC.
440
- let small_universed_rvid = annotation. max_nameable_universe . 1 ;
441
- debug ! (
442
- "{small_universed_rvid:?} lowered our universe to {:?}" ,
443
- annotation. max_nameable_universe( )
449
+ // that ends up in the SCC. This means there is nothing for us to do.
450
+ // However, this is only possible under circumstances that produce
451
+ // errors, so we make sure that we catch them here. Otherwise,
452
+ // there might actually be soundness issues!
453
+ bug ! (
454
+ "Universe of SCC {scc:?} should have been lowered by an existential or at least another placeholder but was lowered by {:?}, which is neither." ,
455
+ annotation. max_nameable_universe
444
456
) ;
445
- small_universed_rvid
446
- } else {
447
- // `max_u_rvid` is not nameable by the SCC's representative.
448
- max_u_rvid
449
457
} ;
450
-
451
- // FIXME: if we can extract a useful blame span here, future error
452
- // reporting and constraint search can be simplified.
453
-
454
- added_constraints = true ;
455
- outlives_constraints. push ( OutlivesConstraint {
456
- sup : annotation. representative . rvid ( ) ,
457
- sub : fr_static,
458
- category : ConstraintCategory :: OutlivesUnnameablePlaceholder ( blame_to) ,
459
- locations : Locations :: All ( rustc_span:: DUMMY_SP ) ,
460
- span : rustc_span:: DUMMY_SP ,
461
- variance_info : VarianceDiagInfo :: None ,
462
- from_closure : false ,
463
- } ) ;
464
458
}
465
459
added_constraints
466
460
}
0 commit comments