@@ -999,12 +999,29 @@ pub trait PrettyPrinter<'tcx>:
999
999
} ;
1000
1000
p ! ( print_value_path( instance. def_id( ) , instance. substs) ) ;
1001
1001
}
1002
- // For zsts just print their type as their value gives no extra information
1003
- ( Scalar :: Raw { size : 0 , .. } , _) => p ! ( print( ty) ) ,
1002
+ // For function type zsts just printing the type is enough
1003
+ ( Scalar :: Raw { size : 0 , .. } , ty:: FnDef ( ..) ) => p ! ( print( ty) ) ,
1004
+ // Empty tuples are frequently occurring, so don't print the fallback.
1005
+ ( Scalar :: Raw { size : 0 , .. } , ty:: Tuple ( ts) ) if ts. is_empty ( ) => p ! ( write( "()" ) ) ,
1006
+ // Zero element arrays have a trivial representation.
1007
+ (
1008
+ Scalar :: Raw { size : 0 , .. } ,
1009
+ ty:: Array (
1010
+ _,
1011
+ ty:: Const {
1012
+ val : ty:: ConstKind :: Value ( ConstValue :: Scalar ( Scalar :: Raw { data : 0 , .. } ) ) ,
1013
+ ..
1014
+ } ,
1015
+ ) ,
1016
+ ) => p ! ( write( "[]" ) ) ,
1004
1017
// Nontrivial types with scalar bit representation
1005
1018
( Scalar :: Raw { data, size } , _) => {
1006
1019
let print = |mut this : Self | {
1007
- write ! ( this, "transmute(0x{:01$x})" , data, size as usize * 2 ) ?;
1020
+ if size == 0 {
1021
+ write ! ( this, "transmute(())" ) ?;
1022
+ } else {
1023
+ write ! ( this, "transmute(0x{:01$x})" , data, size as usize * 2 ) ?;
1024
+ }
1008
1025
Ok ( this)
1009
1026
} ;
1010
1027
self = if print_ty {
0 commit comments