@@ -596,13 +596,17 @@ fn write_mir_sig(
596
596
597
597
trace ! ( "write_mir_sig: {:?}" , src. instance) ;
598
598
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
+ } ;
599
603
match ( descr, src. promoted ) {
600
604
( _, Some ( i) ) => write ! ( w, "{:?} in " , i) ?,
601
- ( Some ( Def :: Fn ( _) ) , _) | ( Some ( Def :: Method ( _) ) , _) => write ! ( w, "fn " ) ?,
602
605
( Some ( Def :: StructCtor ( ..) ) , _) => write ! ( w, "struct " ) ?,
603
606
( Some ( Def :: Const ( _) ) , _) => write ! ( w, "const " ) ?,
604
607
( Some ( Def :: Static ( _, /*is_mutbl*/ false ) ) , _) => write ! ( w, "static " ) ?,
605
608
( Some ( Def :: Static ( _, /*is_mutbl*/ true ) ) , _) => write ! ( w, "static mut " ) ?,
609
+ ( _, _) if is_function => write ! ( w, "fn " ) ?,
606
610
( None , _) => { } , // things like anon const, not an item
607
611
_ => bug ! ( "Unexpected def description {:?}" , descr) ,
608
612
}
@@ -612,27 +616,21 @@ fn write_mir_sig(
612
616
write ! ( w, "{}" , tcx. item_path_str( src. def_id( ) ) )
613
617
} ) ?;
614
618
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, "(" ) ?;
629
621
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) ?;
635
628
}
629
+
630
+ write ! ( w, ") -> {}" , mir. return_ty( ) ) ?;
631
+ } else {
632
+ assert_eq ! ( mir. arg_count, 0 ) ;
633
+ write ! ( w, ": {} =" , mir. return_ty( ) ) ?;
636
634
}
637
635
638
636
if let Some ( yield_ty) = mir. yield_ty {
0 commit comments