@@ -685,29 +685,30 @@ pub trait PrettyPrinter<'tcx>:
685685 }
686686 ty:: FnPtr ( ref bare_fn) => p ! ( print( bare_fn) ) ,
687687 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+
689693 if let ty:: TyVar ( ty_vid) = infer_ty {
690694 if let Some ( name) = self . ty_infer_name ( ty_vid) {
691695 p ! ( write( "{}" , name) )
692696 } else {
693- if verbose {
694- p ! ( write( "{:?}" , infer_ty) )
695- } else {
696- p ! ( write( "{}" , infer_ty) )
697- }
697+ p ! ( write( "{}" , infer_ty) )
698698 }
699699 } else {
700- if verbose { p ! ( write( "{:? }" , infer_ty) ) } else { p ! ( write ( "{}" , infer_ty ) ) }
700+ p ! ( write( "{}" , infer_ty) )
701701 }
702702 }
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 => 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+ }
707709 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}" ) ) ,
711712 } ,
712713 } ,
713714 ty:: Adt ( def, substs) => {
@@ -740,10 +741,11 @@ pub trait PrettyPrinter<'tcx>:
740741 }
741742 }
742743 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+ } ,
747749 } ,
748750 ty:: Alias ( ty:: Opaque , ty:: AliasTy { def_id, substs, .. } ) => {
749751 // We use verbose printing in 'NO_QUERIES' mode, to
@@ -1372,11 +1374,9 @@ pub trait PrettyPrinter<'tcx>:
13721374 }
13731375
13741376 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) ?
13761378 }
1377- ty:: ConstKind :: Placeholder ( placeholder) => {
1378- debug_placeholder_var ( & mut self , placeholder. universe , placeholder. bound ) ?;
1379- } ,
1379+ ty:: ConstKind :: Placeholder ( placeholder) => p ! ( write( "{placeholder:?}" ) ) ,
13801380 // FIXME(generic_const_exprs):
13811381 // write out some legible representation of an abstract const?
13821382 ty:: ConstKind :: Expr ( _) => p ! ( "[const expr]" ) ,
@@ -3065,27 +3065,3 @@ pub struct OpaqueFnEntry<'tcx> {
30653065 fn_trait_ref : Option < ty:: PolyTraitRef < ' tcx > > ,
30663066 return_ty : Option < ty:: Binder < ' tcx , Term < ' tcx > > > ,
30673067}
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