@@ -2242,39 +2242,41 @@ impl<'tcx> Debug for Rvalue<'tcx> {
22422242 }
22432243
22442244 Aggregate ( ref kind, ref places) => {
2245- fn fmt_tuple ( fmt : & mut Formatter < ' _ > , places : & [ Operand < ' _ > ] ) -> fmt :: Result {
2246- let mut tuple_fmt = fmt. debug_tuple ( "" ) ;
2245+ let fmt_tuple = | fmt : & mut Formatter < ' _ > , name : & str | {
2246+ let mut tuple_fmt = fmt. debug_tuple ( name ) ;
22472247 for place in places {
22482248 tuple_fmt. field ( place) ;
22492249 }
22502250 tuple_fmt. finish ( )
2251- }
2251+ } ;
22522252
22532253 match * * kind {
22542254 AggregateKind :: Array ( _) => write ! ( fmt, "{:?}" , places) ,
22552255
2256- AggregateKind :: Tuple => match places. len ( ) {
2257- 0 => write ! ( fmt, "()" ) ,
2258- 1 => write ! ( fmt, "({:?},)" , places[ 0 ] ) ,
2259- _ => fmt_tuple ( fmt, places) ,
2260- } ,
2256+ AggregateKind :: Tuple => {
2257+ if places. is_empty ( ) {
2258+ write ! ( fmt, "()" )
2259+ } else {
2260+ fmt_tuple ( fmt, "" )
2261+ }
2262+ }
22612263
22622264 AggregateKind :: Adt ( adt_def, variant, substs, _user_ty, _) => {
22632265 let variant_def = & adt_def. variants [ variant] ;
22642266
2265- let f = & mut * fmt ;
2266- ty :: tls :: with ( |tcx| {
2267+ let name = ty :: tls :: with ( |tcx| {
2268+ let mut name = String :: new ( ) ;
22672269 let substs = tcx. lift ( & substs) . expect ( "could not lift for printing" ) ;
2268- FmtPrinter :: new ( tcx, f , Namespace :: ValueNS )
2270+ FmtPrinter :: new ( tcx, & mut name , Namespace :: ValueNS )
22692271 . print_def_path ( variant_def. def_id , substs) ?;
2270- Ok ( ( ) )
2272+ Ok ( name )
22712273 } ) ?;
22722274
22732275 match variant_def. ctor_kind {
2274- CtorKind :: Const => Ok ( ( ) ) ,
2275- CtorKind :: Fn => fmt_tuple ( fmt, places ) ,
2276+ CtorKind :: Const => fmt . write_str ( & name ) ,
2277+ CtorKind :: Fn => fmt_tuple ( fmt, & name ) ,
22762278 CtorKind :: Fictive => {
2277- let mut struct_fmt = fmt. debug_struct ( "" ) ;
2279+ let mut struct_fmt = fmt. debug_struct ( & name ) ;
22782280 for ( field, place) in variant_def. fields . iter ( ) . zip ( places) {
22792281 struct_fmt. field ( & field. ident . as_str ( ) , place) ;
22802282 }
0 commit comments