@@ -703,7 +703,7 @@ pub trait PrettyPrinter<'tcx>:
703703 ty:: Error ( _) => p ! ( "[type error]" ) ,
704704 ty:: Param ( ref param_ty) => p ! ( print( param_ty) ) ,
705705 ty:: Bound ( debruijn, bound_ty) => match bound_ty. kind {
706- ty:: BoundTyKind :: Anon => self . pretty_print_bound_var ( debruijn, bound_ty. var ) ?,
706+ ty:: BoundTyKind :: Anon => debug_bound_var ( & mut self , debruijn, bound_ty. var ) ?,
707707 ty:: BoundTyKind :: Param ( _, s) => match self . should_print_verbose ( ) {
708708 true if debruijn == ty:: INNERMOST => p ! ( write( "^{}" , s) ) ,
709709 true => p ! ( write( "^{}_{}" , debruijn. index( ) , s) ) ,
@@ -741,7 +741,7 @@ pub trait PrettyPrinter<'tcx>:
741741 }
742742 ty:: Placeholder ( placeholder) => match placeholder. bound . kind {
743743 ty:: BoundTyKind :: Anon => {
744- self . pretty_print_placeholder_var ( placeholder. universe , placeholder. bound . var ) ?
744+ debug_placeholder_var ( & mut self , placeholder. universe , placeholder. bound . var ) ?;
745745 }
746746 ty:: BoundTyKind :: Param ( _, name) => p ! ( write( "{}" , name) ) ,
747747 } ,
@@ -1164,30 +1164,6 @@ pub trait PrettyPrinter<'tcx>:
11641164 traits. entry ( trait_ref) . or_default ( ) . extend ( proj_ty) ;
11651165 }
11661166
1167- fn pretty_print_bound_var (
1168- & mut self ,
1169- debruijn : ty:: DebruijnIndex ,
1170- var : ty:: BoundVar ,
1171- ) -> Result < ( ) , Self :: Error > {
1172- if debruijn == ty:: INNERMOST {
1173- write ! ( self , "^{}" , var. index( ) )
1174- } else {
1175- write ! ( self , "^{}_{}" , debruijn. index( ) , var. index( ) )
1176- }
1177- }
1178-
1179- fn pretty_print_placeholder_var (
1180- & mut self ,
1181- ui : ty:: UniverseIndex ,
1182- var : ty:: BoundVar ,
1183- ) -> Result < ( ) , Self :: Error > {
1184- if ui == ty:: UniverseIndex :: ROOT {
1185- write ! ( self , "!{}" , var. index( ) )
1186- } else {
1187- write ! ( self , "!{}_{}" , ui. index( ) , var. index( ) )
1188- }
1189- }
1190-
11911167 fn ty_infer_name ( & self , _: ty:: TyVid ) -> Option < Symbol > {
11921168 None
11931169 }
@@ -1321,7 +1297,7 @@ pub trait PrettyPrinter<'tcx>:
13211297 define_scoped_cx ! ( self ) ;
13221298
13231299 if self . should_print_verbose ( ) {
1324- p ! ( write( "Const( {:?}: {:?}) " , ct. kind ( ) , ct . ty ( ) ) ) ;
1300+ p ! ( write( "{:?}" , ct) ) ;
13251301 return Ok ( self ) ;
13261302 }
13271303
@@ -1380,9 +1356,11 @@ pub trait PrettyPrinter<'tcx>:
13801356 }
13811357
13821358 ty:: ConstKind :: Bound ( debruijn, bound_var) => {
1383- self . pretty_print_bound_var ( debruijn, bound_var) ?
1359+ debug_bound_var ( & mut self , debruijn, bound_var) ?
13841360 }
1385- ty:: ConstKind :: Placeholder ( placeholder) => p ! ( write( "Placeholder({:?})" , placeholder) ) ,
1361+ ty:: ConstKind :: Placeholder ( placeholder) => {
1362+ debug_placeholder_var ( & mut self , placeholder. universe , placeholder. bound ) ?;
1363+ } ,
13861364 // FIXME(generic_const_exprs):
13871365 // write out some legible representation of an abstract const?
13881366 ty:: ConstKind :: Expr ( _) => p ! ( "[const expr]" ) ,
@@ -3067,3 +3045,27 @@ pub struct OpaqueFnEntry<'tcx> {
30673045 fn_trait_ref : Option < ty:: PolyTraitRef < ' tcx > > ,
30683046 return_ty : Option < ty:: Binder < ' tcx , Term < ' tcx > > > ,
30693047}
3048+
3049+ pub fn debug_bound_var < T : std:: fmt:: Write > (
3050+ fmt : & mut T ,
3051+ debruijn : ty:: DebruijnIndex ,
3052+ var : ty:: BoundVar ,
3053+ ) -> Result < ( ) , std:: fmt:: Error > {
3054+ if debruijn == ty:: INNERMOST {
3055+ write ! ( fmt, "^{}" , var. index( ) )
3056+ } else {
3057+ write ! ( fmt, "^{}_{}" , debruijn. index( ) , var. index( ) )
3058+ }
3059+ }
3060+
3061+ pub fn debug_placeholder_var < T : std:: fmt:: Write > (
3062+ fmt : & mut T ,
3063+ universe : ty:: UniverseIndex ,
3064+ bound : ty:: BoundVar ,
3065+ ) -> Result < ( ) , std:: fmt:: Error > {
3066+ if universe == ty:: UniverseIndex :: ROOT {
3067+ write ! ( fmt, "!{}" , bound. index( ) )
3068+ } else {
3069+ write ! ( fmt, "!{}_{}" , universe. index( ) , bound. index( ) )
3070+ }
3071+ }
0 commit comments