@@ -433,34 +433,44 @@ fn rewrite_placeholder_outlives<'tcx>(
433433
434434 let annotation = annotations[ scc] ;
435435
436- let Some ( ( max_u, max_u_rvid) ) = annotation. unnameable_placeholder ( ) else {
436+ let Some ( ( unnameable_u, unnameable_placeholder) ) = annotation. unnameable_placeholder ( )
437+ else {
437438 continue ;
438439 } ;
439440
440441 debug ! (
441- "Placeholder universe {max_u :?} is too large for its SCC, represented by {:?}" ,
442+ "Placeholder {unnameable_placeholder :?} with universe {unnameable_u:?} unnameable from {scc:?} represented by {:?}" ,
442443 annotation. representative
443444 ) ;
444445
445- // We only add one `r: 'static` constraint per SCC, where `r` is the SCC representative.
446- // That constraint is annotated with some placeholder `unnameable` where
447- // `unnameable` is unnameable from `r` and there is a path in the constraint graph
448- // between them.
449- if annotation. representative . rvid ( ) != max_u_rvid {
450- // FIXME: if we can extract a useful blame span here, future error
451- // reporting and constraint search can be simplified.
452-
453- added_constraints = true ;
454- outlives_constraints. push ( OutlivesConstraint {
455- sup : annotation. representative . rvid ( ) ,
456- sub : fr_static,
457- category : ConstraintCategory :: OutlivesUnnameablePlaceholder ( max_u_rvid) ,
458- locations : Locations :: All ( rustc_span:: DUMMY_SP ) ,
459- span : rustc_span:: DUMMY_SP ,
460- variance_info : VarianceDiagInfo :: None ,
461- from_closure : false ,
462- } ) ;
446+ let representative_rvid = annotation. representative . rvid ( ) ;
447+
448+ // If we got here, our representative is a placeholder and it reaches some
449+ // region that can't name it. That's a separate error!
450+ if representative_rvid == unnameable_placeholder {
451+ debug ! (
452+ "No need to add constraints for a placeholder reaching an existential that can't name it; that's a separate error."
453+ ) ;
454+ assert ! (
455+ matches!( annotation. representative, Representative :: Placeholder ( _) ) ,
456+ "Representative wasn't a placeholder, which should not be possible!"
457+ ) ;
458+ continue ;
463459 }
460+
461+ // FIXME: if we can extract a useful blame span here, future error
462+ // reporting and constraint search can be simplified.
463+
464+ added_constraints = true ;
465+ outlives_constraints. push ( OutlivesConstraint {
466+ sup : representative_rvid,
467+ sub : fr_static,
468+ category : ConstraintCategory :: OutlivesUnnameablePlaceholder ( unnameable_placeholder) ,
469+ locations : Locations :: All ( rustc_span:: DUMMY_SP ) ,
470+ span : rustc_span:: DUMMY_SP ,
471+ variance_info : VarianceDiagInfo :: None ,
472+ from_closure : false ,
473+ } ) ;
464474 }
465475 added_constraints
466476}
0 commit comments