@@ -596,13 +596,17 @@ fn write_mir_sig(
596596
597597 trace ! ( "write_mir_sig: {:?}" , src. instance) ;
598598 let descr = tcx. describe_def ( src. def_id ( ) ) ;
599+ let is_function = match descr {
600+ Some ( Def :: Fn ( _) ) | Some ( Def :: Method ( _) ) | Some ( Def :: StructCtor ( ..) ) => true ,
601+ _ => tcx. is_closure ( src. def_id ( ) ) ,
602+ } ;
599603 match ( descr, src. promoted ) {
600604 ( _, Some ( i) ) => write ! ( w, "{:?} in " , i) ?,
601- ( Some ( Def :: Fn ( _) ) , _) | ( Some ( Def :: Method ( _) ) , _) => write ! ( w, "fn " ) ?,
602605 ( Some ( Def :: StructCtor ( ..) ) , _) => write ! ( w, "struct " ) ?,
603606 ( Some ( Def :: Const ( _) ) , _) => write ! ( w, "const " ) ?,
604607 ( Some ( Def :: Static ( _, /*is_mutbl*/ false ) ) , _) => write ! ( w, "static " ) ?,
605608 ( Some ( Def :: Static ( _, /*is_mutbl*/ true ) ) , _) => write ! ( w, "static mut " ) ?,
609+ ( _, _) if is_function => write ! ( w, "fn " ) ?,
606610 ( None , _) => { } , // things like anon const, not an item
607611 _ => bug ! ( "Unexpected def description {:?}" , descr) ,
608612 }
@@ -612,27 +616,21 @@ fn write_mir_sig(
612616 write ! ( w, "{}" , tcx. item_path_str( src. def_id( ) ) )
613617 } ) ?;
614618
615- match ( descr, src. promoted ) {
616- ( Some ( Def :: Fn ( _) ) , None ) |
617- ( Some ( Def :: Method ( _) ) , None ) |
618- ( Some ( Def :: StructCtor ( ..) ) , None ) =>
619- {
620- write ! ( w, "(" ) ?;
621-
622- // fn argument types.
623- for ( i, arg) in mir. args_iter ( ) . enumerate ( ) {
624- if i != 0 {
625- write ! ( w, ", " ) ?;
626- }
627- write ! ( w, "{:?}: {}" , Place :: Local ( arg) , mir. local_decls[ arg] . ty) ?;
628- }
619+ if src. promoted . is_none ( ) && is_function {
620+ write ! ( w, "(" ) ?;
629621
630- write ! ( w, ") -> {}" , mir. return_ty( ) ) ?;
631- }
632- _ => {
633- assert_eq ! ( mir. arg_count, 0 ) ;
634- write ! ( w, ": {} =" , mir. return_ty( ) ) ?;
622+ // fn argument types.
623+ for ( i, arg) in mir. args_iter ( ) . enumerate ( ) {
624+ if i != 0 {
625+ write ! ( w, ", " ) ?;
626+ }
627+ write ! ( w, "{:?}: {}" , Place :: Local ( arg) , mir. local_decls[ arg] . ty) ?;
635628 }
629+
630+ write ! ( w, ") -> {}" , mir. return_ty( ) ) ?;
631+ } else {
632+ assert_eq ! ( mir. arg_count, 0 ) ;
633+ write ! ( w, ": {} =" , mir. return_ty( ) ) ?;
636634 }
637635
638636 if let Some ( yield_ty) = mir. yield_ty {
0 commit comments