@@ -999,12 +999,29 @@ pub trait PrettyPrinter<'tcx>:
999999 } ;
10001000 p ! ( print_value_path( instance. def_id( ) , instance. substs) ) ;
10011001 }
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( "[]" ) ) ,
10041017 // Nontrivial types with scalar bit representation
10051018 ( Scalar :: Raw { data, size } , _) => {
10061019 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+ }
10081025 Ok ( this)
10091026 } ;
10101027 self = if print_ty {
0 commit comments