@@ -858,16 +858,23 @@ pub trait PrettyPrinter<'tcx>:
858858
859859 macro_rules! print_underscore {
860860 ( ) => { {
861- p!( write( "_" ) ) ;
862861 if print_ty {
863- p!( write( ": " ) , print( ct. ty) ) ;
862+ self = self . typed_value(
863+ |mut this| {
864+ write!( this, "_" ) ?;
865+ Ok ( this)
866+ } ,
867+ |this| this. print_type( ct. ty) ,
868+ ": " ,
869+ ) ?;
870+ } else {
871+ write!( self , "_" ) ?;
864872 }
865873 } } ;
866874 }
867875
868- match ( ct. val , & ct. ty . kind ) {
869- ( _, ty:: FnDef ( did, substs) ) => p ! ( print_value_path( * did, substs) ) ,
870- ( ty:: ConstKind :: Unevaluated ( did, substs, promoted) , _) => {
876+ match ct. val {
877+ ty:: ConstKind :: Unevaluated ( did, substs, promoted) => {
871878 if let Some ( promoted) = promoted {
872879 p ! ( print_value_path( did, substs) ) ;
873880 p ! ( write( "::{:?}" , promoted) ) ;
@@ -892,17 +899,25 @@ pub trait PrettyPrinter<'tcx>:
892899 }
893900 }
894901 }
895- ( ty:: ConstKind :: Infer ( ..) , _ ) => print_underscore ! ( ) ,
896- ( ty:: ConstKind :: Param ( ParamConst { name, .. } ) , _ ) => p ! ( write( "{}" , name) ) ,
897- ( ty:: ConstKind :: Value ( value) , _ ) => {
902+ ty:: ConstKind :: Infer ( ..) => print_underscore ! ( ) ,
903+ ty:: ConstKind :: Param ( ParamConst { name, .. } ) => p ! ( write( "{}" , name) ) ,
904+ ty:: ConstKind :: Value ( value) => {
898905 return self . pretty_print_const_value ( value, ct. ty , print_ty) ;
899906 }
900907
901- _ => {
908+ ty :: ConstKind :: Bound ( .. ) | ty :: ConstKind :: Placeholder ( _ ) => {
902909 // fallback
903- p ! ( write( "{:?}" , ct. val) ) ;
904910 if print_ty {
905- p ! ( write( ": " ) , print( ct. ty) ) ;
911+ self = self . typed_value (
912+ |mut this| {
913+ write ! ( this, "{:?}" , ct. val) ?;
914+ Ok ( this)
915+ } ,
916+ |this| this. print_type ( ct. ty ) ,
917+ ": " ,
918+ ) ?;
919+ } else {
920+ p ! ( write( "{:?}" , ct. val) ) ;
906921 }
907922 }
908923 } ;
0 commit comments