@@ -703,7 +703,7 @@ pub trait PrettyPrinter<'tcx>:
703
703
ty:: Error ( _) => p ! ( "[type error]" ) ,
704
704
ty:: Param ( ref param_ty) => p ! ( print( param_ty) ) ,
705
705
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 ) ?,
707
707
ty:: BoundTyKind :: Param ( _, s) => match self . should_print_verbose ( ) {
708
708
true if debruijn == ty:: INNERMOST => p ! ( write( "^{}" , s) ) ,
709
709
true => p ! ( write( "^{}_{}" , debruijn. index( ) , s) ) ,
@@ -741,7 +741,7 @@ pub trait PrettyPrinter<'tcx>:
741
741
}
742
742
ty:: Placeholder ( placeholder) => match placeholder. bound . kind {
743
743
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 ) ?;
745
745
}
746
746
ty:: BoundTyKind :: Param ( _, name) => p ! ( write( "{}" , name) ) ,
747
747
} ,
@@ -1164,30 +1164,6 @@ pub trait PrettyPrinter<'tcx>:
1164
1164
traits. entry ( trait_ref) . or_default ( ) . extend ( proj_ty) ;
1165
1165
}
1166
1166
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
-
1191
1167
fn ty_infer_name ( & self , _: ty:: TyVid ) -> Option < Symbol > {
1192
1168
None
1193
1169
}
@@ -1321,7 +1297,7 @@ pub trait PrettyPrinter<'tcx>:
1321
1297
define_scoped_cx ! ( self ) ;
1322
1298
1323
1299
if self . should_print_verbose ( ) {
1324
- p ! ( write( "Const( {:?}: {:?}) " , ct. kind ( ) , ct . ty ( ) ) ) ;
1300
+ p ! ( write( "{:?}" , ct) ) ;
1325
1301
return Ok ( self ) ;
1326
1302
}
1327
1303
@@ -1380,9 +1356,11 @@ pub trait PrettyPrinter<'tcx>:
1380
1356
}
1381
1357
1382
1358
ty:: ConstKind :: Bound ( debruijn, bound_var) => {
1383
- self . pretty_print_bound_var ( debruijn, bound_var) ?
1359
+ debug_bound_var ( & mut self , debruijn, bound_var) ?
1384
1360
}
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
+ } ,
1386
1364
// FIXME(generic_const_exprs):
1387
1365
// write out some legible representation of an abstract const?
1388
1366
ty:: ConstKind :: Expr ( _) => p ! ( "[const expr]" ) ,
@@ -3067,3 +3045,27 @@ pub struct OpaqueFnEntry<'tcx> {
3067
3045
fn_trait_ref : Option < ty:: PolyTraitRef < ' tcx > > ,
3068
3046
return_ty : Option < ty:: Binder < ' tcx , Term < ' tcx > > > ,
3069
3047
}
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