@@ -685,29 +685,30 @@ pub trait PrettyPrinter<'tcx>:
685
685
}
686
686
ty:: FnPtr ( ref bare_fn) => p ! ( print( bare_fn) ) ,
687
687
ty:: Infer ( infer_ty) => {
688
- let verbose = self . should_print_verbose ( ) ;
688
+ if self . should_print_verbose ( ) {
689
+ p ! ( write( "{:?}" , ty. kind( ) ) ) ;
690
+ return Ok ( self ) ;
691
+ }
692
+
689
693
if let ty:: TyVar ( ty_vid) = infer_ty {
690
694
if let Some ( name) = self . ty_infer_name ( ty_vid) {
691
695
p ! ( write( "{}" , name) )
692
696
} else {
693
- if verbose {
694
- p ! ( write( "{:?}" , infer_ty) )
695
- } else {
696
- p ! ( write( "{}" , infer_ty) )
697
- }
697
+ p ! ( write( "{}" , infer_ty) )
698
698
}
699
699
} else {
700
- if verbose { p ! ( write( "{:? }" , infer_ty) ) } else { p ! ( write ( "{}" , infer_ty ) ) }
700
+ p ! ( write( "{}" , infer_ty) )
701
701
}
702
702
}
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 => debug_bound_var ( & mut self , debruijn, bound_ty. var ) ?,
706
+ ty:: BoundTyKind :: Anon => {
707
+ rustc_type_ir:: debug_bound_var ( & mut self , debruijn, bound_ty. var ) ?
708
+ }
707
709
ty:: BoundTyKind :: Param ( _, s) => match self . should_print_verbose ( ) {
708
- true if debruijn == ty:: INNERMOST => p ! ( write( "^{}" , s) ) ,
709
- true => p ! ( write( "^{}_{}" , debruijn. index( ) , s) ) ,
710
- false => p ! ( write( "{}" , s) ) ,
710
+ true => p ! ( write( "{:?}" , ty. kind( ) ) ) ,
711
+ false => p ! ( write( "{s}" ) ) ,
711
712
} ,
712
713
} ,
713
714
ty:: Adt ( def, substs) => {
@@ -740,10 +741,11 @@ pub trait PrettyPrinter<'tcx>:
740
741
}
741
742
}
742
743
ty:: Placeholder ( placeholder) => match placeholder. bound . kind {
743
- ty:: BoundTyKind :: Anon => {
744
- debug_placeholder_var ( & mut self , placeholder. universe , placeholder. bound . var ) ?;
745
- }
746
- ty:: BoundTyKind :: Param ( _, name) => p ! ( write( "{}" , name) ) ,
744
+ ty:: BoundTyKind :: Anon => p ! ( write( "{placeholder:?}" ) ) ,
745
+ ty:: BoundTyKind :: Param ( _, name) => match self . should_print_verbose ( ) {
746
+ true => p ! ( write( "{:?}" , ty. kind( ) ) ) ,
747
+ false => p ! ( write( "{name}" ) ) ,
748
+ } ,
747
749
} ,
748
750
ty:: Alias ( ty:: Opaque , ty:: AliasTy { def_id, substs, .. } ) => {
749
751
// We use verbose printing in 'NO_QUERIES' mode, to
@@ -1372,11 +1374,9 @@ pub trait PrettyPrinter<'tcx>:
1372
1374
}
1373
1375
1374
1376
ty:: ConstKind :: Bound ( debruijn, bound_var) => {
1375
- debug_bound_var ( & mut self , debruijn, bound_var) ?
1377
+ rustc_type_ir :: debug_bound_var ( & mut self , debruijn, bound_var) ?
1376
1378
}
1377
- ty:: ConstKind :: Placeholder ( placeholder) => {
1378
- debug_placeholder_var ( & mut self , placeholder. universe , placeholder. bound ) ?;
1379
- } ,
1379
+ ty:: ConstKind :: Placeholder ( placeholder) => p ! ( write( "{placeholder:?}" ) ) ,
1380
1380
// FIXME(generic_const_exprs):
1381
1381
// write out some legible representation of an abstract const?
1382
1382
ty:: ConstKind :: Expr ( _) => p ! ( "[const expr]" ) ,
@@ -3065,27 +3065,3 @@ pub struct OpaqueFnEntry<'tcx> {
3065
3065
fn_trait_ref : Option < ty:: PolyTraitRef < ' tcx > > ,
3066
3066
return_ty : Option < ty:: Binder < ' tcx , Term < ' tcx > > > ,
3067
3067
}
3068
-
3069
- pub fn debug_bound_var < T : std:: fmt:: Write > (
3070
- fmt : & mut T ,
3071
- debruijn : ty:: DebruijnIndex ,
3072
- var : ty:: BoundVar ,
3073
- ) -> Result < ( ) , std:: fmt:: Error > {
3074
- if debruijn == ty:: INNERMOST {
3075
- write ! ( fmt, "^{}" , var. index( ) )
3076
- } else {
3077
- write ! ( fmt, "^{}_{}" , debruijn. index( ) , var. index( ) )
3078
- }
3079
- }
3080
-
3081
- pub fn debug_placeholder_var < T : std:: fmt:: Write > (
3082
- fmt : & mut T ,
3083
- universe : ty:: UniverseIndex ,
3084
- bound : ty:: BoundVar ,
3085
- ) -> Result < ( ) , std:: fmt:: Error > {
3086
- if universe == ty:: UniverseIndex :: ROOT {
3087
- write ! ( fmt, "!{}" , bound. index( ) )
3088
- } else {
3089
- write ! ( fmt, "!{}_{}" , universe. index( ) , bound. index( ) )
3090
- }
3091
- }
0 commit comments