@@ -442,11 +442,41 @@ impl<'tcx> fmt::Display for traits::WhereClause<'tcx> {
442442 fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
443443 use traits:: WhereClause :: * ;
444444
445+ // Bypass ppaux because it does not print out anonymous regions.
446+ fn write_region_name < ' tcx > (
447+ r : ty:: Region < ' tcx > ,
448+ fmt : & mut fmt:: Formatter < ' _ >
449+ ) -> fmt:: Result {
450+ match r {
451+ ty:: ReLateBound ( index, br) => match br {
452+ ty:: BoundRegion :: BrNamed ( _, name) => write ! ( fmt, "{}" , name) ,
453+ ty:: BoundRegion :: BrAnon ( var) => {
454+ if * index == ty:: INNERMOST {
455+ write ! ( fmt, "'^{}" , var)
456+ } else {
457+ write ! ( fmt, "'^{}_{}" , index. index( ) , var)
458+ }
459+ }
460+ _ => write ! ( fmt, "'_" ) ,
461+ }
462+
463+ _ => write ! ( fmt, "{}" , r) ,
464+ }
465+ }
466+
445467 match self {
446468 Implemented ( trait_ref) => write ! ( fmt, "Implemented({})" , trait_ref) ,
447469 ProjectionEq ( projection) => write ! ( fmt, "ProjectionEq({})" , projection) ,
448- RegionOutlives ( predicate) => write ! ( fmt, "RegionOutlives({})" , predicate) ,
449- TypeOutlives ( predicate) => write ! ( fmt, "TypeOutlives({})" , predicate) ,
470+ RegionOutlives ( predicate) => {
471+ write ! ( fmt, "RegionOutlives({}: " , predicate. 0 ) ?;
472+ write_region_name ( predicate. 1 , fmt) ?;
473+ write ! ( fmt, ")" )
474+ }
475+ TypeOutlives ( predicate) => {
476+ write ! ( fmt, "TypeOutlives({}: " , predicate. 0 ) ?;
477+ write_region_name ( predicate. 1 , fmt) ?;
478+ write ! ( fmt, ")" )
479+ }
450480 }
451481 }
452482}
@@ -567,7 +597,7 @@ impl<'tcx> TypeVisitor<'tcx> for BoundNamesCollector {
567597 match bound_ty. kind {
568598 ty:: BoundTyKind :: Param ( name) => name,
569599 ty:: BoundTyKind :: Anon => Symbol :: intern (
570- & format ! ( "? {}" , bound_ty. var. as_u32( ) )
600+ & format ! ( "^ {}" , bound_ty. var. as_u32( ) )
571601 ) . as_interned_str ( ) ,
572602 }
573603 ) ;
@@ -591,7 +621,7 @@ impl<'tcx> TypeVisitor<'tcx> for BoundNamesCollector {
591621
592622 ty:: BoundRegion :: BrAnon ( var) => {
593623 self . regions . insert ( Symbol :: intern (
594- & format ! ( "?' {}" , var)
624+ & format ! ( "'^ {}" , var)
595625 ) . as_interned_str ( ) ) ;
596626 }
597627
0 commit comments